mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
not use separate function
This commit is contained in:
parent
79f5d260a4
commit
b402619351
@ -13,7 +13,6 @@
|
||||
#include "VCMI_Lib.h"
|
||||
#include "GameConstants.h"
|
||||
#include "GameSettings.h"
|
||||
#include "MinimalPrimarySkill.h"
|
||||
#include "bonuses/BonusList.h"
|
||||
#include "bonuses/Bonus.h"
|
||||
#include "bonuses/IBonusBearer.h"
|
||||
@ -87,7 +86,7 @@ int AFactionMember::getPrimSkillLevel(PrimarySkill id) const
|
||||
static const std::string keyAllSkills = "type_PRIMARY_SKILL";
|
||||
auto allSkills = getBonusBearer()->getBonuses(selectorAllSkills, keyAllSkills);
|
||||
auto ret = allSkills->valOfBonuses(Selector::subtype()(BonusSubtypeID(id)));
|
||||
auto minSkillValue = getPrimarySkillMinimum(id);
|
||||
auto minSkillValue = VLC->settings()->getVector(EGameSettings::HEROES_MINIMAL_PRIMARY_SKILLS)[id.getNum()];
|
||||
return std::max(ret, minSkillValue); //otherwise, some artifacts may cause negative skill value effect, sp=0 works in old saves
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "GameSettings.h"
|
||||
#include "CSkillHandler.h"
|
||||
#include "BattleFieldHandler.h"
|
||||
#include "MinimalPrimarySkill.h"
|
||||
#include "bonuses/Limiters.h"
|
||||
#include "bonuses/Updaters.h"
|
||||
#include "entities/faction/CFaction.h"
|
||||
@ -231,7 +230,7 @@ void CHeroClassHandler::fillPrimarySkillData(const JsonNode & node, CHeroClass *
|
||||
{
|
||||
const auto & skillName = NPrimarySkill::names[pSkill.getNum()];
|
||||
auto currentPrimarySkillValue = static_cast<int>(node["primarySkills"][skillName].Integer());
|
||||
int primarySkillLegalMinimum = getPrimarySkillMinimum(pSkill);
|
||||
int primarySkillLegalMinimum = VLC->settings()->getVector(EGameSettings::HEROES_MINIMAL_PRIMARY_SKILLS)[pSkill.getNum()];
|
||||
|
||||
if(currentPrimarySkillValue < primarySkillLegalMinimum)
|
||||
{
|
||||
|
@ -275,7 +275,6 @@ set(lib_MAIN_SRCS
|
||||
IHandlerBase.cpp
|
||||
LoadProgress.cpp
|
||||
LogicalExpression.cpp
|
||||
MimialPrimarySkill.cpp
|
||||
ObstacleHandler.cpp
|
||||
StartInfo.cpp
|
||||
ResourceSet.cpp
|
||||
@ -697,7 +696,6 @@ set(lib_MAIN_HEADERS
|
||||
int3.h
|
||||
LoadProgress.h
|
||||
LogicalExpression.h
|
||||
MinimalPrimarySkill.h
|
||||
ObstacleHandler.h
|
||||
Point.h
|
||||
Rect.h
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* MinimalPrimarySkill.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "MinimalPrimarySkill.h"
|
||||
#include "VCMI_Lib.h"
|
||||
#include "GameSettings.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
const std::vector<int> DEFAULT_MINIMAL_PSKILLS= {0, 0, 1, 1};
|
||||
const std::map<PrimarySkill, int> PSKILL_INDEX_MAP = {
|
||||
{PrimarySkill::ATTACK, 0},
|
||||
{PrimarySkill::DEFENSE, 1},
|
||||
{PrimarySkill::SPELL_POWER, 2},
|
||||
{PrimarySkill::KNOWLEDGE, 3}
|
||||
};
|
||||
|
||||
int getPrimarySkillMinimum(PrimarySkill pSkill)
|
||||
{
|
||||
auto minialPSkills = VLC->settings()->getVector(EGameSettings::HEROES_MINIMAL_PRIMARY_SKILLS);
|
||||
if(minialPSkills.size() != DEFAULT_MINIMAL_PSKILLS.size())
|
||||
logGlobal->error("gameConfig.json: heroes/minimalPrimarySkills format error. need a vector with 4 elements.");
|
||||
int index = PSKILL_INDEX_MAP.at(pSkill);
|
||||
return minialPSkills.size() > index ? minialPSkills[index] : DEFAULT_MINIMAL_PSKILLS[index];
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
* MinimalPrimarySkill.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GameConstants.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
int getPrimarySkillMinimum(PrimarySkill pSkill);
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
Loading…
Reference in New Issue
Block a user