mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-19 22:57:37 +02:00
Add COMBAT_MANA_BONUS for Skyship
This commit is contained in:
@@ -19,7 +19,11 @@ void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army
|
||||
{
|
||||
armyObjectID = Army->id;
|
||||
if (Hero)
|
||||
{
|
||||
heroID = Hero->id;
|
||||
initialMana = Hero->mana;
|
||||
additionalMana = Hero->valOfBonuses(BonusType::COMBAT_MANA_BONUS);
|
||||
}
|
||||
|
||||
switch(Army->ID.toEnum())
|
||||
{
|
||||
|
||||
@@ -28,6 +28,8 @@ struct DLL_LINKAGE SideInBattle : public GameCallbackHolder
|
||||
uint32_t castSpellsCount = 0; //how many spells each side has been cast this turn
|
||||
std::vector<SpellID> usedSpellsHistory; //every time hero casts spell, it's inserted here -> eagle eye skill
|
||||
int32_t enchanterCounter = 0; //tends to pass through 0, so sign is needed
|
||||
int32_t initialMana = 0;
|
||||
int32_t additionalMana = 0;
|
||||
|
||||
void init(const CGHeroInstance * Hero, const CArmedInstance * Army);
|
||||
const CArmedInstance * getArmy() const;
|
||||
@@ -41,6 +43,8 @@ struct DLL_LINKAGE SideInBattle : public GameCallbackHolder
|
||||
h & castSpellsCount;
|
||||
h & usedSpellsHistory;
|
||||
h & enchanterCounter;
|
||||
h & initialMana;
|
||||
h & additionalMana;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -192,6 +192,7 @@ class JsonNode;
|
||||
BONUS_NAME(FULL_MAP_SCOUTING) /*Skyship*/\
|
||||
BONUS_NAME(FULL_MAP_DARKNESS) /*opposite to Skyship*/\
|
||||
BONUS_NAME(TRANSMUTATION_IMMUNITY) /*blocks TRANSMUTATION bonus*/\
|
||||
BONUS_NAME(COMBAT_MANA_BONUS) /* Additional mana per combat */ \
|
||||
/* end of list */
|
||||
|
||||
|
||||
|
||||
@@ -1176,7 +1176,7 @@ void GameStatePackVisitor::visitBattleStart(BattleStart & pack)
|
||||
pack.info->battleID = gs.nextBattleID;
|
||||
pack.info->localInit();
|
||||
|
||||
if (pack.info->getDefendedTown() && pack.info->getSideHero(BattleSide::DEFENDER))
|
||||
if (pack.info->getDefendedTown() && pack.info->getSide(BattleSide::DEFENDER).heroID.hasValue())
|
||||
{
|
||||
CGTownInstance * town = gs.getTown(pack.info->townID);
|
||||
CGHeroInstance * hero = gs.getHero(pack.info->getSideHero(BattleSide::DEFENDER)->id);
|
||||
@@ -1188,6 +1188,15 @@ void GameStatePackVisitor::visitBattleStart(BattleStart & pack)
|
||||
}
|
||||
}
|
||||
|
||||
for(auto i : {BattleSide::ATTACKER, BattleSide::DEFENDER})
|
||||
{
|
||||
if (pack.info->getSide(i).heroID.hasValue())
|
||||
{
|
||||
CGHeroInstance * hero = gs.getHero(pack.info->getSideHero(i)->id);
|
||||
hero->mana = pack.info->getSide(i).initialMana + pack.info->getSide(i).additionalMana;
|
||||
}
|
||||
}
|
||||
|
||||
gs.currentBattles.push_back(std::move(pack.info));
|
||||
gs.nextBattleID = BattleID(gs.nextBattleID.getNum() + 1);
|
||||
}
|
||||
@@ -1383,6 +1392,17 @@ void GameStatePackVisitor::visitBattleCancelled(BattleCancelled & pack)
|
||||
return battle->battleID == pack.battleID;
|
||||
});
|
||||
|
||||
const auto & currentBattle = **battleIter;
|
||||
|
||||
for(auto i : {BattleSide::ATTACKER, BattleSide::DEFENDER})
|
||||
{
|
||||
if (currentBattle.getSide(i).heroID.hasValue())
|
||||
{
|
||||
CGHeroInstance * hero = gs.getHero(currentBattle.getSideHero(i)->id);
|
||||
hero->mana = currentBattle.getSide(i).initialMana;
|
||||
}
|
||||
}
|
||||
|
||||
assert(battleIter != gs.currentBattles.end());
|
||||
gs.currentBattles.erase(battleIter);
|
||||
}
|
||||
@@ -1401,14 +1421,23 @@ void GameStatePackVisitor::visitBattleResultsApplied(BattleResultsApplied & pack
|
||||
for(auto & movingPack : pack.movingArtifacts)
|
||||
movingPack.visit(*this);
|
||||
|
||||
const auto currentBattle = std::find_if(gs.currentBattles.begin(), gs.currentBattles.end(),
|
||||
[&](const auto & battle)
|
||||
{
|
||||
return battle->battleID == pack.battleID;
|
||||
});
|
||||
auto battleIter = boost::range::find_if(gs.currentBattles, [&](const auto & battle)
|
||||
{
|
||||
return battle->battleID == pack.battleID;
|
||||
});
|
||||
const auto & currentBattle = **battleIter;
|
||||
|
||||
assert(currentBattle != gs.currentBattles.end());
|
||||
gs.currentBattles.erase(currentBattle);
|
||||
for(auto i : {BattleSide::ATTACKER, BattleSide::DEFENDER})
|
||||
{
|
||||
if (currentBattle.getSide(i).heroID.hasValue())
|
||||
{
|
||||
CGHeroInstance * hero = gs.getHero(currentBattle.getSideHero(i)->id);
|
||||
hero->mana = std::min(hero->mana, currentBattle.getSide(i).initialMana);
|
||||
}
|
||||
}
|
||||
|
||||
assert(battleIter != gs.currentBattles.end());
|
||||
gs.currentBattles.erase(battleIter);
|
||||
}
|
||||
|
||||
void GameStatePackVisitor::visitBattleObstaclesChanged(BattleObstaclesChanged & pack)
|
||||
|
||||
@@ -76,7 +76,7 @@ void BattleProcessor::restartBattle(const BattleID & battleID, const CArmedInsta
|
||||
if(heroes[i])
|
||||
{
|
||||
SetMana restoreInitialMana;
|
||||
restoreInitialMana.val = lastBattleQuery->initialHeroMana[i];
|
||||
restoreInitialMana.val = battle->getSide(i).initialMana;
|
||||
restoreInitialMana.hid = heroes[i]->id;
|
||||
restoreInitialMana.mode = ChangeValueMode::ABSOLUTE;
|
||||
gameHandler->sendAndApply(restoreInitialMana);
|
||||
@@ -134,12 +134,6 @@ void BattleProcessor::startBattle(const CArmedInstance *army1, const CArmedInsta
|
||||
else
|
||||
{
|
||||
auto newBattleQuery = std::make_shared<CBattleQuery>(gameHandler, battle);
|
||||
|
||||
// store initial mana to reset if battle has been restarted
|
||||
for(auto i : {BattleSide::ATTACKER, BattleSide::DEFENDER})
|
||||
if(heroes[i])
|
||||
newBattleQuery->initialHeroMana[i] = heroes[i]->mana;
|
||||
|
||||
gameHandler->queries->addQuery(newBattleQuery);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ class CBattleQuery : public CQuery
|
||||
{
|
||||
public:
|
||||
BattleSideArray<const CArmedInstance *> belligerents;
|
||||
BattleSideArray<int> initialHeroMana;
|
||||
|
||||
BattleID battleID;
|
||||
std::optional<BattleResult> result;
|
||||
|
||||
Reference in New Issue
Block a user