diff --git a/config/translate.json b/config/translate.json index ecbb0e044..0071d4971 100644 --- a/config/translate.json +++ b/config/translate.json @@ -53,7 +53,8 @@ "hasNotProduced" : "The %s has not produced anything yet.", "hasProduced" : "The %s produced %d %s this week.", "greetingCustomBonus" : "%s gives you +%d %s%s", - "greetingCustomUntil" : " until next battle." + "greetingCustomUntil" : " until next battle.", + "greetingInTownMagicWell" : "%s has restored your spell points to maximum." }, "logicalExpressions" : { diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index d1f1c7c89..20a34d979 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -323,7 +323,7 @@ public: BONUS_NAME(GARGOYLE) /* gargoyle is special than NON_LIVING, cannot be rised or healed */ \ BONUS_NAME(SPECIAL_ADD_VALUE_ENCHANT) /*specialty spell like Aenin has, increased effect of spell, additionalInfo = value to add*/\ BONUS_NAME(SPECIAL_FIXED_VALUE_ENCHANT) /*specialty spell like Melody has, constant spell effect (i.e. 3 luck), additionalInfo = value to fix.*/\ - + BONUS_NAME(TOWN_MAGIC_WELL) /*one-time pseudo-bonus to implement Magic Well in the town*/ \ /* end of list */ diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 92f0be651..10ac13d48 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -1812,6 +1812,13 @@ void CTownBonus::applyBonuses(CGHeroInstance * h, const BonusList & bonuses) con GiveBonus gb; InfoWindow iw; + if(bonus->type == Bonus::TOWN_MAGIC_WELL) + { + if(h->mana >= h->manaLimit()) + return; + cb->setManaPoints(h->id, h->manaLimit()); + bonus->duration = Bonus::ONE_DAY; + } gb.bonus = * bonus; gb.id = h->id.getNum(); cb->giveHeroBonus(&gb); @@ -1895,8 +1902,15 @@ const std::string CGTownBuilding::getVisitingBonusGreeting() const return bonusGreeting; } -const std::string CGTownBuilding::getCustomBonusGreeting(const Bonus & bonus) +const std::string CGTownBuilding::getCustomBonusGreeting(const Bonus & bonus) const { + if(bonus.type == Bonus::TOWN_MAGIC_WELL) + { + auto bonusGreeting = std::string(VLC->generaltexth->localizedTexts["townHall"]["greetingInTownMagicWell"].String()); + auto buildingName = town->town->getSpecialBuilding(bType)->Name(); + boost::algorithm::replace_first(bonusGreeting, "%s", buildingName); + return bonusGreeting; + } auto bonusGreeting = std::string(VLC->generaltexth->localizedTexts["townHall"]["greetingCustomBonus"].String()); //"%s gives you +%d %s%s" std::string param = ""; std::string until = ""; diff --git a/lib/mapObjects/CGTownInstance.h b/lib/mapObjects/CGTownInstance.h index 1cfbe30c8..681b73161 100644 --- a/lib/mapObjects/CGTownInstance.h +++ b/lib/mapObjects/CGTownInstance.h @@ -140,7 +140,7 @@ protected: BuildingSubID::EBuildingSubID bType; const std::string getVisitingBonusGreeting() const; - static const std::string getCustomBonusGreeting(const Bonus & bonus); + const std::string getCustomBonusGreeting(const Bonus & bonus) const; }; class DLL_LINKAGE COPWBonus : public CGTownBuilding