1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #2828 from dydzio0614/commander-abilities-requirements

Commander abilities requirements
This commit is contained in:
Ivan Savenko 2023-09-14 14:57:19 +03:00 committed by GitHub
commit e2e4168966
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 20 deletions

View File

@ -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_),
isSelected(false),
callback(callback)
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
}

View File

@ -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;
};

View File

@ -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;
}
};

View File

@ -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);

View File

@ -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;
}