mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
vcmi: made some CSpell properties private
There are getters for it.
This commit is contained in:
parent
4d67a7e3d1
commit
344593e891
@ -271,7 +271,16 @@ std::shared_ptr<IImage> BattleStacksController::getStackAmountBox(const CStack *
|
||||
int effectsPositivness = 0;
|
||||
|
||||
for(const auto & spellID : activeSpells)
|
||||
effectsPositivness += CGI->spellh->objects.at(spellID)->positiveness;
|
||||
{
|
||||
auto positiveness = CGI->spells()->getByIndex(spellID)->getPositiveness();
|
||||
if(!boost::logic::indeterminate(positiveness))
|
||||
{
|
||||
if(positiveness)
|
||||
effectsPositivness++;
|
||||
else
|
||||
effectsPositivness--;
|
||||
}
|
||||
}
|
||||
|
||||
if (effectsPositivness > 0)
|
||||
return amountPositive;
|
||||
|
@ -74,9 +74,9 @@ class SpellbookSpellSorter
|
||||
public:
|
||||
bool operator()(const CSpell * A, const CSpell * B)
|
||||
{
|
||||
if(A->level < B->level)
|
||||
if(A->getLevel() < B->getLevel())
|
||||
return true;
|
||||
if(A->level > B->level)
|
||||
if(A->getLevel() > B->getLevel())
|
||||
return false;
|
||||
|
||||
|
||||
@ -562,7 +562,7 @@ void CSpellWindow::SpellArea::hover(bool on)
|
||||
if(mySpell)
|
||||
{
|
||||
if(on)
|
||||
owner->statusBar->write(boost::str(boost::format("%s (%s)") % mySpell->getNameTranslated() % CGI->generaltexth->allTexts[171+mySpell->level]));
|
||||
owner->statusBar->write(boost::str(boost::format("%s (%s)") % mySpell->getNameTranslated() % CGI->generaltexth->allTexts[171+mySpell->getLevel()]));
|
||||
else
|
||||
owner->statusBar->clear();
|
||||
}
|
||||
@ -609,12 +609,12 @@ void CSpellWindow::SpellArea::setSpell(const CSpell * spell)
|
||||
if(schoolLevel > 0)
|
||||
{
|
||||
boost::format fmt("%s/%s");
|
||||
fmt % CGI->generaltexth->allTexts[171 + mySpell->level];
|
||||
fmt % CGI->generaltexth->allTexts[171 + mySpell->getLevel()];
|
||||
fmt % CGI->generaltexth->levels[3+(schoolLevel-1)];//lines 4-6
|
||||
level->setText(fmt.str());
|
||||
}
|
||||
else
|
||||
level->setText(CGI->generaltexth->allTexts[171 + mySpell->level]);
|
||||
level->setText(CGI->generaltexth->allTexts[171 + mySpell->getLevel()]);
|
||||
|
||||
cost->color = secondLineColor;
|
||||
boost::format costfmt("%s: %d");
|
||||
|
@ -1082,7 +1082,7 @@ void CGameState::initTowns()
|
||||
for(ui32 z=0; z<vti->obligatorySpells.size();z++)
|
||||
{
|
||||
const auto * s = vti->obligatorySpells[z].toSpell();
|
||||
vti->spells[s->level-1].push_back(s->id);
|
||||
vti->spells[s->getLevel()-1].push_back(s->id);
|
||||
vti->possibleSpells -= s->id;
|
||||
}
|
||||
while(!vti->possibleSpells.empty())
|
||||
@ -1110,7 +1110,7 @@ void CGameState::initTowns()
|
||||
sel=0;
|
||||
|
||||
const auto * s = vti->possibleSpells[sel].toSpell();
|
||||
vti->spells[s->level-1].push_back(s->id);
|
||||
vti->spells[s->getLevel()-1].push_back(s->id);
|
||||
vti->possibleSpells -= s->id;
|
||||
}
|
||||
vti->possibleSpells.clear();
|
||||
|
@ -213,7 +213,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
||||
|
||||
for(auto spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
||||
{
|
||||
if(map.isAllowedSpell(spell->id) && spell->level == i + 1)
|
||||
if(map.isAllowedSpell(spell->id) && spell->getLevel() == i + 1)
|
||||
{
|
||||
out.push_back(spell->id);
|
||||
}
|
||||
@ -328,7 +328,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
||||
std::vector <CSpell *> spells;
|
||||
for(auto spell : VLC->spellh->objects)
|
||||
{
|
||||
if(map.isAllowedSpell(spell->id) && spell->level == i)
|
||||
if(map.isAllowedSpell(spell->id) && spell->getLevel() == i)
|
||||
spells.push_back(spell);
|
||||
}
|
||||
|
||||
|
@ -187,17 +187,10 @@ public:
|
||||
|
||||
using BTVector = std::vector<BonusType>;
|
||||
|
||||
si32 level;
|
||||
|
||||
std::map<SpellSchool, bool> school;
|
||||
|
||||
si32 power; //spell's power
|
||||
|
||||
std::map<FactionID, si32> probabilities; //% chance to gain for castles
|
||||
|
||||
bool combat; //is this spell combat (true) or adventure (false)
|
||||
bool creatureAbility; //if true, only creatures can use this spell
|
||||
si8 positiveness; //1 if spell is positive for influenced stacks, 0 if it is indifferent, -1 if it's negative
|
||||
bool onlyOnWaterMap; //Spell will be banned on maps without water
|
||||
std::vector<SpellID> counteredSpells; //spells that are removed when effect of this spell is placed on creature (for bless-curse, haste-slow, and similar pairs)
|
||||
|
||||
@ -364,6 +357,12 @@ private:
|
||||
|
||||
std::vector<LevelInfo> levels;
|
||||
|
||||
si32 level;
|
||||
si32 power; //spell's power
|
||||
bool combat; //is this spell combat (true) or adventure (false)
|
||||
bool creatureAbility; //if true, only creatures can use this spell
|
||||
si8 positiveness; //1 if spell is positive for influenced stacks, 0 if it is indifferent, -1 if it's negative
|
||||
|
||||
std::unique_ptr<spells::ISpellMechanicsFactory> mechanics;//(!) do not serialize
|
||||
std::unique_ptr<IAdventureSpellMechanics> adventureMechanics;//(!) do not serialize
|
||||
};
|
||||
|
@ -738,7 +738,7 @@ std::unique_ptr<IAdventureSpellMechanics> IAdventureSpellMechanics::createMechan
|
||||
case SpellID::VIEW_AIR:
|
||||
return std::make_unique<ViewAirMechanics>(s);
|
||||
default:
|
||||
return s->combat ? std::unique_ptr<IAdventureSpellMechanics>() : std::make_unique<AdventureSpellMechanics>(s);
|
||||
return s->isCombat() ? std::unique_ptr<IAdventureSpellMechanics>() : std::make_unique<AdventureSpellMechanics>(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1620,7 +1620,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
cs1.learn = true;
|
||||
cs1.hid = toHero;//giving spells to first hero
|
||||
for (auto it : h1->getSpellsInSpellbook())
|
||||
if (h2Lvl >= it.toSpell()->level && !h2->spellbookContainsSpell(it))//hero can learn it and don't have it yet
|
||||
if (h2Lvl >= it.toSpell()->getLevel() && !h2->spellbookContainsSpell(it))//hero can learn it and don't have it yet
|
||||
cs1.spells.insert(it);//spell to learn
|
||||
|
||||
ChangeSpells cs2;
|
||||
@ -1628,7 +1628,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
cs2.hid = fromHero;
|
||||
|
||||
for (auto it : h2->getSpellsInSpellbook())
|
||||
if (h1Lvl >= it.toSpell()->level && !h1->spellbookContainsSpell(it))
|
||||
if (h1Lvl >= it.toSpell()->getLevel() && !h1->spellbookContainsSpell(it))
|
||||
cs2.spells.insert(it);
|
||||
|
||||
if (!cs1.spells.empty() || !cs2.spells.empty())//create a message
|
||||
|
Loading…
Reference in New Issue
Block a user