|
|
@@ -38,53 +38,6 @@
|
|
|
#include "../lib/mapObjects/CGHeroInstance.h"
|
|
|
#include "../lib/NetPacksBase.h"
|
|
|
|
|
|
-TConstBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector & selector, const CSelector & limit, const CBonusSystemNode * root, const std::string & cachingStr) const
|
|
|
-{
|
|
|
- TBonusListPtr out(new BonusList());
|
|
|
- TConstBonusListPtr heroBonuses = hero->getAllBonuses(selector, limit, hero, cachingStr);
|
|
|
- TConstBonusListPtr bonusesFromPickedUpArtifact;
|
|
|
-
|
|
|
- const auto pickedArtInst = cww->getPickedArtifact();
|
|
|
-
|
|
|
- if(pickedArtInst)
|
|
|
- bonusesFromPickedUpArtifact = pickedArtInst->getAllBonuses(selector, limit, hero);
|
|
|
- else
|
|
|
- bonusesFromPickedUpArtifact = TBonusListPtr(new BonusList());
|
|
|
-
|
|
|
- for(const auto & b : *heroBonuses)
|
|
|
- out->push_back(b);
|
|
|
-
|
|
|
- for(const auto & b : *bonusesFromPickedUpArtifact)
|
|
|
- *out -= b;
|
|
|
- return out;
|
|
|
-}
|
|
|
-
|
|
|
-int64_t CHeroWithMaybePickedArtifact::getTreeVersion() const
|
|
|
-{
|
|
|
- return hero->getTreeVersion(); //this assumes that hero and artifact belongs to main bonus tree
|
|
|
-}
|
|
|
-
|
|
|
-si32 CHeroWithMaybePickedArtifact::manaLimit() const
|
|
|
-{
|
|
|
- //TODO: reduplicate code with CGHeroInstance
|
|
|
- return si32(getPrimSkillLevel(PrimarySkill::KNOWLEDGE) * (valOfBonuses(BonusType::MANA_PER_KNOWLEDGE)));
|
|
|
-}
|
|
|
-
|
|
|
-const IBonusBearer * CHeroWithMaybePickedArtifact::getBonusBearer() const
|
|
|
-{
|
|
|
- return this;
|
|
|
-}
|
|
|
-
|
|
|
-FactionID CHeroWithMaybePickedArtifact::getFaction() const
|
|
|
-{
|
|
|
- return hero->getFaction();
|
|
|
-}
|
|
|
-
|
|
|
-CHeroWithMaybePickedArtifact::CHeroWithMaybePickedArtifact(CWindowWithArtifacts * Cww, const CGHeroInstance * Hero)
|
|
|
- : hero(Hero), cww(Cww)
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
void CHeroSwitcher::clickPressed(const Point & cursorPosition)
|
|
|
{
|
|
|
//TODO: do not recreate window
|
|
|
@@ -114,8 +67,7 @@ CHeroSwitcher::CHeroSwitcher(CHeroWindow * owner_, Point pos_, const CGHeroInsta
|
|
|
}
|
|
|
|
|
|
CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
|
|
|
- : CStatusbarWindow(PLAYER_COLORED, "HeroScr4"),
|
|
|
- heroWArt(this, hero)
|
|
|
+ : CStatusbarWindow(PLAYER_COLORED, "HeroScr4")
|
|
|
{
|
|
|
auto & heroscrn = CGI->generaltexth->heroscrn;
|
|
|
|
|
|
@@ -268,7 +220,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded)
|
|
|
//primary skills support
|
|
|
for(size_t g=0; g<primSkillAreas.size(); ++g)
|
|
|
{
|
|
|
- primSkillAreas[g]->bonusValue = heroWArt.getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(g));
|
|
|
+ primSkillAreas[g]->bonusValue = curHero->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(g));
|
|
|
primSkillValues[g]->setText(std::to_string(primSkillAreas[g]->bonusValue));
|
|
|
}
|
|
|
|
|
|
@@ -294,7 +246,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded)
|
|
|
expValue->setText(expstr.str());
|
|
|
|
|
|
std::ostringstream manastr;
|
|
|
- manastr << curHero->mana << '/' << heroWArt.manaLimit();
|
|
|
+ manastr << curHero->mana << '/' << curHero->manaLimit();
|
|
|
manaValue->setText(manastr.str());
|
|
|
|
|
|
//printing experience - original format does not support ui64
|
|
|
@@ -307,7 +259,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded)
|
|
|
spellPointsArea->text = CGI->generaltexth->allTexts[205];
|
|
|
boost::replace_first(spellPointsArea->text, "%s", curHero->getNameTranslated());
|
|
|
boost::replace_first(spellPointsArea->text, "%d", std::to_string(curHero->mana));
|
|
|
- boost::replace_first(spellPointsArea->text, "%d", std::to_string(heroWArt.manaLimit()));
|
|
|
+ boost::replace_first(spellPointsArea->text, "%d", std::to_string(curHero->manaLimit()));
|
|
|
|
|
|
//if we have exchange window with this curHero open
|
|
|
bool noDismiss=false;
|
|
|
@@ -343,8 +295,8 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded)
|
|
|
formations->setSelected(curHero->formation == EArmyFormation::TIGHT ? 1 : 0);
|
|
|
formations->addCallback([=](int value){ LOCPLINT->cb->setFormation(curHero, value);});
|
|
|
|
|
|
- morale->set(&heroWArt);
|
|
|
- luck->set(&heroWArt);
|
|
|
+ morale->set(curHero);
|
|
|
+ luck->set(curHero);
|
|
|
|
|
|
if(redrawNeeded)
|
|
|
redraw();
|
|
|
@@ -390,5 +342,5 @@ void CHeroWindow::commanderWindow()
|
|
|
void CHeroWindow::updateGarrisons()
|
|
|
{
|
|
|
garr->recreateSlots();
|
|
|
- morale->set(&heroWArt);
|
|
|
+ morale->set(curHero);
|
|
|
}
|