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

Minor fix: apply Monday bonuses to heroes who have slept overnight

This commit is contained in:
Dmitry Orlov 2020-09-28 01:32:33 +03:00
parent fbb272bb27
commit 38fd05f655
5 changed files with 21 additions and 9 deletions

View File

@ -194,6 +194,7 @@ public:
void showCompInfo(ShowInInfobox * comp) override {}; void showCompInfo(ShowInInfobox * comp) override {};
void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {};
void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero) override {};
void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {};
void startBattlePrimary(const CArmedInstance * army1, const CArmedInstance * army2, int3 tile, const CGHeroInstance * hero1, const CGHeroInstance * hero2, bool creatureBank = false, const CGTownInstance * town = nullptr) override {}; //use hero=nullptr for no hero void startBattlePrimary(const CArmedInstance * army1, const CArmedInstance * army2, int3 tile, const CGHeroInstance * hero1, const CGHeroInstance * hero2, bool creatureBank = false, const CGTownInstance * town = nullptr) override {}; //use hero=nullptr for no hero
void startBattleI(const CArmedInstance * army1, const CArmedInstance * army2, int3 tile, bool creatureBank = false) override {}; //if any of armies is hero, hero will be used void startBattleI(const CArmedInstance * army1, const CArmedInstance * army2, int3 tile, bool creatureBank = false) override {}; //if any of armies is hero, hero will be used

View File

@ -80,6 +80,7 @@ public:
virtual void showCompInfo(ShowInInfobox * comp)=0; virtual void showCompInfo(ShowInInfobox * comp)=0;
virtual void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0; virtual void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0;
virtual void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero)=0;
virtual void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0; virtual void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0;
virtual void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr)=0; //use hero=nullptr for no hero virtual void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr)=0; //use hero=nullptr for no hero
virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false)=0; //if any of armies is hero, hero will be used virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false)=0; //if any of armies is hero, hero will be used

View File

@ -798,6 +798,14 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const
cb->setObjProperty (id, ObjProperty::STRUCTURE_CLEAR_VISITORS, (elem)->id); //reset visitors for Mana Vortex cb->setObjProperty (id, ObjProperty::STRUCTURE_CLEAR_VISITORS, (elem)->id); //reset visitors for Mana Vortex
} }
//get Mana Vortex or Stables bonuses
//same code is in the CGameHandler::buildStructure method
if (visitingHero != nullptr)
cb->visitCastleObjects(this, visitingHero);
if (garrisonHero != nullptr)
cb->visitCastleObjects(this, garrisonHero);
if (tempOwner == PlayerColor::NEUTRAL) //garrison growth for neutral towns if (tempOwner == PlayerColor::NEUTRAL) //garrison growth for neutral towns
{ {
std::vector<SlotID> nativeCrits; //slots std::vector<SlotID> nativeCrits; //slots
@ -1536,13 +1544,15 @@ void COPWBonus::onHeroVisit (const CGHeroInstance * h) const
} }
break; break;
case ETownType::DUNGEON: //Mana Vortex case ETownType::DUNGEON: //Mana Vortex
if (visitors.empty() && h->mana <= h->manaLimit() * 2) if (visitors.empty())
{ {
cb->setManaPoints (heroID, 2 * h->manaLimit()); if (h->mana < h->manaLimit() * 2)
cb->setManaPoints(heroID, 2 * h->manaLimit());
//TODO: investigate line below //TODO: investigate line below
//cb->setObjProperty (town->id, ObjProperty::VISITED, true); //cb->setObjProperty (town->id, ObjProperty::VISITED, true);
iw.text << VLC->generaltexth->allTexts[579]; iw.text << VLC->generaltexth->allTexts[579];
cb->showInfoDialog(&iw); cb->showInfoDialog(&iw);
//extra visit penalty if hero alredy had double mana points (or even more?!)
town->addHeroToStructureVisitors(h, id); town->addHeroToStructureVisitors(h, id);
} }
break; break;

View File

@ -2508,13 +2508,13 @@ void CGameHandler::heroVisitCastle(const CGTownInstance * obj, const CGHeroInsta
vc.tid = obj->id; vc.tid = obj->id;
vc.flags |= 1; vc.flags |= 1;
sendAndApply(&vc); sendAndApply(&vc);
vistiCastleObjects (obj, hero); visitCastleObjects(obj, hero);
giveSpells (obj, hero); giveSpells(obj, hero);
checkVictoryLossConditionsForPlayer(hero->tempOwner); //transported artifact? checkVictoryLossConditionsForPlayer(hero->tempOwner); //transported artifact?
} }
void CGameHandler::vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h) void CGameHandler::visitCastleObjects(const CGTownInstance * t, const CGHeroInstance * h)
{ {
std::vector<CGTownBuilding*>::const_iterator i; std::vector<CGTownBuilding*>::const_iterator i;
for (i = t->bonusingBuildings.begin(); i != t->bonusingBuildings.end(); i++) for (i = t->bonusingBuildings.begin(); i != t->bonusingBuildings.end(); i++)
@ -3161,9 +3161,9 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
sendAndApply(&fw); sendAndApply(&fw);
if (t->visitingHero) if (t->visitingHero)
vistiCastleObjects (t, t->visitingHero); visitCastleObjects(t, t->visitingHero);
if (t->garrisonHero) if (t->garrisonHero)
vistiCastleObjects (t, t->garrisonHero); visitCastleObjects(t, t->garrisonHero);
checkVictoryLossConditionsForPlayer(t->tempOwner); checkVictoryLossConditionsForPlayer(t->tempOwner);
return true; return true;
@ -3828,7 +3828,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl
if (t) if (t)
{ {
vistiCastleObjects (t, nh); visitCastleObjects(t, nh);
giveSpells (t,nh); giveSpells (t,nh);
} }
return true; return true;

View File

@ -181,7 +181,7 @@ public:
void setPortalDwelling(const CGTownInstance * town, bool forced, bool clear); void setPortalDwelling(const CGTownInstance * town, bool forced, bool clear);
void visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h); void visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h);
bool teleportHero(ObjectInstanceID hid, ObjectInstanceID dstid, ui8 source, PlayerColor asker = PlayerColor::NEUTRAL); bool teleportHero(ObjectInstanceID hid, ObjectInstanceID dstid, ui8 source, PlayerColor asker = PlayerColor::NEUTRAL);
void vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h); void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero);
void levelUpHero(const CGHeroInstance * hero, SecondarySkill skill);//handle client respond and send one more request if needed void levelUpHero(const CGHeroInstance * hero, SecondarySkill skill);//handle client respond and send one more request if needed
void levelUpHero(const CGHeroInstance * hero);//initial call - check if hero have remaining levelups & handle them void levelUpHero(const CGHeroInstance * hero);//initial call - check if hero have remaining levelups & handle them
void levelUpCommander (const CCommanderInstance * c, int skill); //secondary skill 1 to 6, special skill : skill - 100 void levelUpCommander (const CCommanderInstance * c, int skill); //secondary skill 1 to 6, special skill : skill - 100