mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
code review
This commit is contained in:
@@ -2247,7 +2247,9 @@ bool CGameHandler::spellResearch(ObjectInstanceID tid, SpellID spellAtSlot, bool
|
||||
{
|
||||
CGTownInstance *t = gs->getTown(tid);
|
||||
|
||||
if(!(getSettings().getBoolean(EGameSettings::TOWNS_SPELL_RESEARCH) && t->spellResearchAllowed) && complain("Spell research not allowed!"))
|
||||
if(!getSettings().getBoolean(EGameSettings::TOWNS_SPELL_RESEARCH) && complain("Spell research not allowed!"))
|
||||
return false;
|
||||
if (!t->spellResearchAllowed && complain("Spell research not allowed in this town!"))
|
||||
return false;
|
||||
|
||||
int level = -1;
|
||||
@@ -2260,8 +2262,7 @@ bool CGameHandler::spellResearch(ObjectInstanceID tid, SpellID spellAtSlot, bool
|
||||
|
||||
auto spells = t->spells.at(level);
|
||||
|
||||
int today = getDate(Date::DAY);
|
||||
bool researchLimitExceeded = t->spellResearchActionsPerDay.find(today) != t->spellResearchActionsPerDay.end() && t->spellResearchActionsPerDay.at(today) >= getSettings().getValue(EGameSettings::TOWNS_SPELL_RESEARCH_PER_DAY).Vector()[level].Float();
|
||||
bool researchLimitExceeded = t->spellResearchCounterDay >= getSettings().getValue(EGameSettings::TOWNS_SPELL_RESEARCH_PER_DAY).Vector()[level].Float();
|
||||
if(researchLimitExceeded && complain("Already researched today!"))
|
||||
return false;
|
||||
|
||||
@@ -2275,7 +2276,7 @@ bool CGameHandler::spellResearch(ObjectInstanceID tid, SpellID spellAtSlot, bool
|
||||
|
||||
auto costBase = TResources(getSettings().getValue(EGameSettings::TOWNS_SPELL_RESEARCH_COST).Vector()[level]);
|
||||
auto costExponent = getSettings().getValue(EGameSettings::TOWNS_SPELL_RESEARCH_COST_EXPONENT_PER_RESEARCH).Vector()[level].Float();
|
||||
auto cost = costBase * std::pow(t->spellResearchCounter + 1, costExponent);
|
||||
auto cost = costBase * std::pow(t->spellResearchAcceptedCounter + 1, costExponent);
|
||||
|
||||
if(!getPlayerState(t->getOwner())->resources.canAfford(cost) && complain("Spell replacement cannot be afforded!"))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user