mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Merge pull request #2828 from dydzio0614/commander-abilities-requirements
Commander abilities requirements
This commit is contained in:
commit
e2e4168966
@ -96,14 +96,14 @@ private:
|
||||
|
||||
};
|
||||
|
||||
CCommanderSkillIcon::CCommanderSkillIcon(std::shared_ptr<CIntObject> object_, bool isGrandmasterAbility_, std::function<void()> callback)
|
||||
CCommanderSkillIcon::CCommanderSkillIcon(std::shared_ptr<CIntObject> object_, bool isMasterAbility_, std::function<void()> callback)
|
||||
: object(),
|
||||
isGrandmasterAbility(isGrandmasterAbility_),
|
||||
isMasterAbility(isMasterAbility_),
|
||||
isSelected(false),
|
||||
callback(callback)
|
||||
{
|
||||
pos = object_->pos;
|
||||
this->isGrandmasterAbility = isGrandmasterAbility_;
|
||||
this->isMasterAbility = isMasterAbility_;
|
||||
setObject(object_);
|
||||
}
|
||||
|
||||
@ -128,16 +128,16 @@ void CCommanderSkillIcon::deselect()
|
||||
isSelected = false;
|
||||
}
|
||||
|
||||
bool CCommanderSkillIcon::getIsGrandmasterAbility()
|
||||
bool CCommanderSkillIcon::getIsMasterAbility()
|
||||
{
|
||||
return isGrandmasterAbility;
|
||||
return isMasterAbility;
|
||||
}
|
||||
|
||||
void CCommanderSkillIcon::show(Canvas &to)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
|
||||
if(isGrandmasterAbility && isSelected)
|
||||
if(isMasterAbility && isSelected)
|
||||
to.drawBorder(pos, Colors::YELLOW, 2);
|
||||
}
|
||||
|
||||
@ -921,7 +921,7 @@ void CStackWindow::setSelection(si32 newSkill, std::shared_ptr<CCommanderSkillIc
|
||||
|
||||
if(selectedIcon)
|
||||
{
|
||||
if(!selectedIcon->getIsGrandmasterAbility()) //unlike WoG, in VCMI grandmaster skill descriptions are taken from bonus descriptions
|
||||
if(!selectedIcon->getIsMasterAbility()) //unlike WoG, in VCMI master skill descriptions are taken from bonus descriptions
|
||||
{
|
||||
selectedIcon->text = getSkillDescription(oldSelection, false); //update previously selected icon's message to existing skill level
|
||||
}
|
||||
@ -932,7 +932,7 @@ void CStackWindow::setSelection(si32 newSkill, std::shared_ptr<CCommanderSkillIc
|
||||
if(newSkill < 100)
|
||||
{
|
||||
newIcon->setObject(std::make_shared<CPicture>(getSkillImage(newSkill)));
|
||||
if(!newIcon->getIsGrandmasterAbility())
|
||||
if(!newIcon->getIsMasterAbility())
|
||||
{
|
||||
newIcon->text = getSkillDescription(newSkill, true); //update currently selected icon's message to show upgrade description
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ class CCommanderArtPlace;
|
||||
class CCommanderSkillIcon : public LRClickableAreaWText //TODO: maybe bring commander skill button initialization logic inside?
|
||||
{
|
||||
std::shared_ptr<CIntObject> object; // passive object that will be used to determine clickable area
|
||||
bool isGrandmasterAbility; // refers to WoG abilities obtainable via combining grandmaster skills (for example attack + speed unlocks shoot)
|
||||
bool isSelected; // used only for programatically created border around selected "grandmaster abilities"
|
||||
bool isMasterAbility; // refers to WoG abilities obtainable via combining master skills (for example attack + speed unlocks shoot)
|
||||
bool isSelected; // used only for programatically created border around selected "master abilities"
|
||||
public:
|
||||
CCommanderSkillIcon(std::shared_ptr<CIntObject> object_, bool isGrandmasterAbility, std::function<void()> callback);
|
||||
CCommanderSkillIcon(std::shared_ptr<CIntObject> object_, bool isMasterAbility_, std::function<void()> callback);
|
||||
|
||||
std::function<void()> callback;
|
||||
|
||||
@ -43,7 +43,7 @@ public:
|
||||
|
||||
void setObject(std::shared_ptr<CIntObject> object);
|
||||
void deselect(); //TODO: consider using observer pattern instead?
|
||||
bool getIsGrandmasterAbility();
|
||||
bool getIsMasterAbility();
|
||||
|
||||
void show(Canvas &to) override;
|
||||
};
|
||||
|
@ -139,7 +139,7 @@ public:
|
||||
ui8 level; //required only to count callbacks
|
||||
std::string name; // each Commander has different name
|
||||
std::vector <ui8> secondarySkills; //ID -> level
|
||||
std::set <ui8> specialSKills;
|
||||
std::set <ui8> specialSkills;
|
||||
//std::vector <CArtifactInstance *> arts;
|
||||
void init() override;
|
||||
CCommanderInstance();
|
||||
@ -161,7 +161,7 @@ public:
|
||||
h & level;
|
||||
h & name;
|
||||
h & secondarySkills;
|
||||
h & specialSKills;
|
||||
h & specialSkills;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -803,7 +803,7 @@ void SetCommanderProperty::applyGs(CGameState *gs)
|
||||
break;
|
||||
case SPECIAL_SKILL:
|
||||
commander->accumulateBonus (std::make_shared<Bonus>(accumulatedBonus));
|
||||
commander->specialSKills.insert (additionalInfo);
|
||||
commander->specialSkills.insert (additionalInfo);
|
||||
break;
|
||||
case SECONDARY_SKILL:
|
||||
commander->secondarySkills[additionalInfo] = static_cast<ui8>(amount);
|
||||
|
@ -468,9 +468,9 @@ void CGameHandler::levelUpCommander(const CCommanderInstance * c)
|
||||
int i = 100;
|
||||
for (auto specialSkill : VLC->creh->skillRequirements)
|
||||
{
|
||||
if (c->secondarySkills.at(specialSkill.second.first) == ECommander::MAX_SKILL_LEVEL
|
||||
&& c->secondarySkills.at(specialSkill.second.second) == ECommander::MAX_SKILL_LEVEL
|
||||
&& !vstd::contains (c->specialSKills, i))
|
||||
if (c->secondarySkills.at(specialSkill.second.first) >= ECommander::MAX_SKILL_LEVEL - 1
|
||||
&& c->secondarySkills.at(specialSkill.second.second) >= ECommander::MAX_SKILL_LEVEL - 1
|
||||
&& !vstd::contains (c->specialSkills, i))
|
||||
clu.skills.push_back (i);
|
||||
++i;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user