1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Feature: Magic Well should work in the fan towns

This commit is contained in:
Dmitry Orlov 2021-02-01 18:35:15 +03:00
parent 093076c6d0
commit 3cb88b6964
4 changed files with 19 additions and 4 deletions

View File

@ -53,7 +53,8 @@
"hasNotProduced" : "The %s has not produced anything yet.", "hasNotProduced" : "The %s has not produced anything yet.",
"hasProduced" : "The %s produced %d %s this week.", "hasProduced" : "The %s produced %d %s this week.",
"greetingCustomBonus" : "%s gives you +%d %s%s", "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" : "logicalExpressions" :
{ {

View File

@ -323,7 +323,7 @@ public:
BONUS_NAME(GARGOYLE) /* gargoyle is special than NON_LIVING, cannot be rised or healed */ \ 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_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(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 */ /* end of list */

View File

@ -1812,6 +1812,13 @@ void CTownBonus::applyBonuses(CGHeroInstance * h, const BonusList & bonuses) con
GiveBonus gb; GiveBonus gb;
InfoWindow iw; 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.bonus = * bonus;
gb.id = h->id.getNum(); gb.id = h->id.getNum();
cb->giveHeroBonus(&gb); cb->giveHeroBonus(&gb);
@ -1895,8 +1902,15 @@ const std::string CGTownBuilding::getVisitingBonusGreeting() const
return bonusGreeting; 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" auto bonusGreeting = std::string(VLC->generaltexth->localizedTexts["townHall"]["greetingCustomBonus"].String()); //"%s gives you +%d %s%s"
std::string param = ""; std::string param = "";
std::string until = ""; std::string until = "";

View File

@ -140,7 +140,7 @@ protected:
BuildingSubID::EBuildingSubID bType; BuildingSubID::EBuildingSubID bType;
const std::string getVisitingBonusGreeting() const; 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 class DLL_LINKAGE COPWBonus : public CGTownBuilding