1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

code review

This commit is contained in:
Laserlicht
2025-07-31 00:11:43 +02:00
parent 2894297b36
commit df545e47f9
5 changed files with 19 additions and 28 deletions

View File

@@ -519,10 +519,10 @@
/// Strength of generic creature specialties ( "creature" : "creatureName" ) per level /// Strength of generic creature specialties ( "creature" : "creatureName" ) per level
"specialtyCreatureGrowth" : 5, "specialtyCreatureGrowth" : 5,
/// Amount of advanced or expert skills selectable (if any) /// Maximum amount of skills that can be offered to hero on levelup
"skillSelectionAmountUpgr" : 1, "levelupTotalSkillsAmount" : 2,
/// Amount of basic skills selectable (if fewer advanced or expert skills than expected they will also filled up with basic skills) /// Maximum amount of advanced or expert skills that can be offered to hero on levelup
"skillSelectionAmount" : 1 "levelupUpgradedSkillsAmount" : 1
}, },
"towns": "towns":

View File

@@ -52,8 +52,8 @@
"specialtyCreatureGrowth" : { "type" : "number" }, "specialtyCreatureGrowth" : { "type" : "number" },
"specialtySecondarySkillGrowth" : { "type" : "number" }, "specialtySecondarySkillGrowth" : { "type" : "number" },
"baseScoutingRange" : { "type" : "number" }, "baseScoutingRange" : { "type" : "number" },
"skillSelectionAmountUpgr" : { "type" : "number" }, "levelupTotalSkillsAmount" : { "type" : "number" },
"skillSelectionAmount" : { "type" : "number" } "levelupUpgradedSkillsAmount" : { "type" : "number" }
} }
}, },
"towns" : { "towns" : {

View File

@@ -86,8 +86,8 @@ const std::vector<GameSettings::SettingOption> GameSettings::settingProperties =
{EGameSettings::HEROES_SKILL_PER_HERO, "heroes", "skillPerHero" }, {EGameSettings::HEROES_SKILL_PER_HERO, "heroes", "skillPerHero" },
{EGameSettings::HEROES_SPECIALTY_CREATURE_GROWTH, "heroes", "specialtyCreatureGrowth" }, {EGameSettings::HEROES_SPECIALTY_CREATURE_GROWTH, "heroes", "specialtyCreatureGrowth" },
{EGameSettings::HEROES_SPECIALTY_SECONDARY_SKILL_GROWTH, "heroes", "specialtySecondarySkillGrowth" }, {EGameSettings::HEROES_SPECIALTY_SECONDARY_SKILL_GROWTH, "heroes", "specialtySecondarySkillGrowth" },
{EGameSettings::HEROES_SKILL_SELECTION_AMOUNT_UPGR, "heroes", "skillSelectionAmountUpgr" }, {EGameSettings::LEVEL_UP_TOTAL_SKILLS_AMOUNT, "heroes", "levelupTotalSkillsAmount" },
{EGameSettings::HEROES_SKILL_SELECTION_AMOUNT, "heroes", "skillSelectionAmount" }, {EGameSettings::LEVEL_UP_UPGRADED_SKILLS_AMOUNT, "heroes", "levelupUpgradedSkillsAmount" },
{EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" }, {EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" },
{EGameSettings::MAP_FORMAT_CHRONICLES, "mapFormat", "chronicles" }, {EGameSettings::MAP_FORMAT_CHRONICLES, "mapFormat", "chronicles" },
{EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS, "mapFormat", "hornOfTheAbyss" }, {EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS, "mapFormat", "hornOfTheAbyss" },

View File

@@ -59,8 +59,8 @@ enum class EGameSettings
HEROES_SKILL_PER_HERO, HEROES_SKILL_PER_HERO,
HEROES_SPECIALTY_CREATURE_GROWTH, HEROES_SPECIALTY_CREATURE_GROWTH,
HEROES_SPECIALTY_SECONDARY_SKILL_GROWTH, HEROES_SPECIALTY_SECONDARY_SKILL_GROWTH,
HEROES_SKILL_SELECTION_AMOUNT_UPGR, LEVEL_UP_TOTAL_SKILLS_AMOUNT,
HEROES_SKILL_SELECTION_AMOUNT, LEVEL_UP_UPGRADED_SKILLS_AMOUNT,
INTERFACE_PLAYER_COLORED_BACKGROUND, INTERFACE_PLAYER_COLORED_BACKGROUND,
MAP_FORMAT_ARMAGEDDONS_BLADE, MAP_FORMAT_ARMAGEDDONS_BLADE,
MAP_FORMAT_CHRONICLES, MAP_FORMAT_CHRONICLES,

View File

@@ -1413,28 +1413,19 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelupSkillCandidates(IGameRando
none.erase(elem.first); none.erase(elem.first);
} }
for(;;) int maxUpgradedSkills = cb->getSettings().getInteger(EGameSettings::LEVEL_UP_UPGRADED_SKILLS_AMOUNT);
{ while (skills.size() < maxUpgradedSkills && !basicAndAdv.empty())
if(skills.size() >= cb->getSettings().getInteger(EGameSettings::HEROES_SKILL_SELECTION_AMOUNT_UPGR) || basicAndAdv.empty())
break;
if (!basicAndAdv.empty())
{ {
skills.push_back(gameRandomizer.rollSecondarySkillForLevelup(this, basicAndAdv)); skills.push_back(gameRandomizer.rollSecondarySkillForLevelup(this, basicAndAdv));
basicAndAdv.erase(skills.back()); basicAndAdv.erase(skills.back());
} }
}
for(;;)
{
if(skills.size() >= cb->getSettings().getInteger(EGameSettings::HEROES_SKILL_SELECTION_AMOUNT) + cb->getSettings().getInteger(EGameSettings::HEROES_SKILL_SELECTION_AMOUNT_UPGR) || none.empty())
break;
if (!none.empty()) int maxTotalSkills = cb->getSettings().getInteger(EGameSettings::LEVEL_UP_TOTAL_SKILLS_AMOUNT);
while (skills.size() < maxTotalSkills && !none.empty())
{ {
skills.push_back(gameRandomizer.rollSecondarySkillForLevelup(this, none)); skills.push_back(gameRandomizer.rollSecondarySkillForLevelup(this, none));
none.erase(skills.back()); none.erase(skills.back());
} }
}
return skills; return skills;
} }