Browse Source

Start implementing VISIONS and DISGUISE

AlexVinS 10 năm trước cách đây
mục cha
commit
666d7a4f45

+ 5 - 0
config/bonuses.json

@@ -128,6 +128,11 @@
 		}
 	},
 
+        "DISGUISED":
+        {
+        	"hidden": true
+        },
+
 	"EARTH_IMMUNITY":
 	{
 		"graphics":

+ 4 - 1
lib/HeroBonus.h

@@ -215,7 +215,10 @@ public:
 	BONUS_NAME(REBIRTH) /* val - percent of life restored, subtype = 0 - regular, 1 - at least one unit (sacred Phoenix) */\
 	BONUS_NAME(ADDITIONAL_UNITS) /*val of units with id = subtype will be added to hero's army at the beginning of battle */\
 	BONUS_NAME(SPOILS_OF_WAR) /*val * 10^-6 * gained exp resources of subtype will be given to hero after battle*/\
-	BONUS_NAME(BLOCK)
+	BONUS_NAME(BLOCK)\
+	BONUS_NAME(DISGUISED) /* subtype - spell level */\
+	BONUS_NAME(VISIONS) /* subtype - spell level */
+	
 
 #define BONUS_SOURCE_LIST \
 	BONUS_SOURCE(ARTIFACT)\

+ 18 - 1
lib/spells/AdventureSpellMechanics.cpp

@@ -24,7 +24,7 @@
 bool AdventureBonusingMechanics::applyAdventureEffects(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const
 {
 	const int schoolLevel = parameters.caster->getSpellSchoolLevel(owner);	
-	const int subtype = schoolLevel >= 2 ? 1 : 2; //adv or expert
+	const int subtype = spellLevelToSubtype(schoolLevel);
 
 	GiveBonus gb;
 	gb.id = parameters.caster->id.getNum();
@@ -33,6 +33,23 @@ bool AdventureBonusingMechanics::applyAdventureEffects(const SpellCastEnvironmen
 	return true;
 }
 
+int FlyMechanics::spellLevelToSubtype(const int schoolLevel) const
+{
+	return schoolLevel >= 2 ? 1 : 2; //adv or expert
+}
+
+int VisionsMechanics::spellLevelToSubtype(const int schoolLevel) const
+{
+	//0,1 schoolLevel => 0 subtype
+	//2 schoolLevel  => 1 subtype 
+	//3 schoolLevel  => 2 subtype 
+	int result = schoolLevel - 1;
+	vstd::amin(result, 0);
+	vstd::amax(result, 2);
+	return result; //adv or expert
+}
+
+
 ///SummonBoatMechanics
 bool SummonBoatMechanics::applyAdventureEffects(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const
 {

+ 20 - 0
lib/spells/AdventureSpellMechanics.h

@@ -20,10 +20,30 @@ public:
 	AdventureBonusingMechanics(CSpell * s, Bonus::BonusType _bonusTypeID): DefaultSpellMechanics(s), bonusTypeID(_bonusTypeID){};	
 protected:
 	bool applyAdventureEffects(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const override;	
+	
+	virtual int spellLevelToSubtype(const int schoolLevel) const = 0;
 private:
 	Bonus::BonusType bonusTypeID;
 };
 
+//FLY & WATER_WALK
+class FlyMechanics: public AdventureBonusingMechanics
+{
+public:	
+	FlyMechanics(CSpell * s, Bonus::BonusType _bonusTypeID): AdventureBonusingMechanics(s, _bonusTypeID){};
+protected:
+	int spellLevelToSubtype(const int schoolLevel) const override;
+};
+
+//VISIONS & DISGUISE
+class VisionsMechanics: public AdventureBonusingMechanics
+{
+public:	
+	VisionsMechanics(CSpell * s, Bonus::BonusType _bonusTypeID): AdventureBonusingMechanics(s, _bonusTypeID){};
+protected:
+	int spellLevelToSubtype(const int schoolLevel) const override;
+};
+
 class SummonBoatMechanics: public DefaultSpellMechanics 
 {
 public:

+ 4 - 2
lib/spells/ISpellMechanics.cpp

@@ -69,9 +69,9 @@ ISpellMechanics * ISpellMechanics::createMechanics(CSpell * s)
 	case SpellID::DIMENSION_DOOR:
 		return new DimensionDoorMechanics(s);
 	case SpellID::FLY:
-		return new AdventureBonusingMechanics(s, Bonus::FLYING_MOVEMENT);
+		return new FlyMechanics(s, Bonus::FLYING_MOVEMENT); //temporary
 	case SpellID::WATER_WALK:
-		return new AdventureBonusingMechanics(s, Bonus::WATER_WALKING);
+		return new FlyMechanics(s, Bonus::WATER_WALKING); //temporary
 	case SpellID::TOWN_PORTAL:
 		return new TownPortalMechanics(s);
 	case SpellID::VIEW_EARTH:
@@ -79,7 +79,9 @@ ISpellMechanics * ISpellMechanics::createMechanics(CSpell * s)
 	case SpellID::VIEW_AIR:			
 		return new ViewAirMechanics(s);
 	case SpellID::VISIONS:
+		return new VisionsMechanics(s, Bonus::VISIONS); //temporary
 	case SpellID::DISGUISE:
+		return new VisionsMechanics(s, Bonus::DISGUISED); //temporary
 	default:		
 		if(s->isRisingSpell())
 			return new SpecialRisingSpellMechanics(s);