mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-15 13:33:36 +02:00
Restructured difficulty config
This commit is contained in:
parent
0de912e67b
commit
cb3bbc6680
@ -1,89 +1,70 @@
|
||||
// Starting resources, ordered by difficulty level (0 to 4)
|
||||
//Configured difficulty
|
||||
{
|
||||
"startres":
|
||||
[
|
||||
"human":
|
||||
{
|
||||
"pawn":
|
||||
{
|
||||
"human": { "wood" : 30, "mercury": 15, "ore": 30, "sulfur": 15, "crystal": 15, "gems": 15, "gold": 30000, "mithril": 0 },
|
||||
"ai": { "wood" : 5, "mercury": 2, "ore": 5, "sulfur": 2, "crystal": 2, "gems": 2, "gold": 5000, "mithril": 0 }
|
||||
"resources": { "wood" : 30, "mercury": 15, "ore": 30, "sulfur": 15, "crystal": 15, "gems": 15, "gold": 30000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"knight":
|
||||
{
|
||||
"human": { "wood" : 20, "mercury": 10, "ore": 20, "sulfur": 10, "crystal": 10, "gems": 10, "gold": 20000, "mithril": 0 },
|
||||
"ai": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 7500, "mithril": 0 }
|
||||
"resources": { "wood" : 20, "mercury": 10, "ore": 20, "sulfur": 10, "crystal": 10, "gems": 10, "gold": 20000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"rook":
|
||||
{
|
||||
"human": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 15000, "mithril": 0 },
|
||||
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
||||
"resources": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 15000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"queen":
|
||||
{
|
||||
"human": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 10000, "mithril": 0 },
|
||||
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
||||
"resources": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 10000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"king":
|
||||
{
|
||||
"human": { "wood" : 0, "mercury": 0, "ore": 0 , "sulfur": 0, "crystal": 0, "gems": 0, "gold": 0, "mithril": 0 },
|
||||
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
||||
"resources": { "wood" : 0, "mercury": 0, "ore": 0 , "sulfur": 0, "crystal": 0, "gems": 0, "gold": 0, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
}
|
||||
],
|
||||
"battleBonus":
|
||||
[
|
||||
},
|
||||
"ai":
|
||||
{
|
||||
"pawn":
|
||||
{
|
||||
"resources": { "wood" : 5, "mercury": 2, "ore": 5, "sulfur": 2, "crystal": 2, "gems": 2, "gold": 5000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"knight":
|
||||
{
|
||||
"ai":
|
||||
[
|
||||
{
|
||||
"type" : "STACK_HEALTH",
|
||||
"val" : 50,
|
||||
"valueType" : "PERCENT_TO_ALL",
|
||||
"duration" : "ONE_BATTLE",
|
||||
"sourceType" : "OTHER"
|
||||
}
|
||||
],
|
||||
"resources": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 7500, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"rook":
|
||||
{
|
||||
"ai":
|
||||
[
|
||||
{
|
||||
"type" : "STACK_HEALTH",
|
||||
"val" : 100,
|
||||
"valueType" : "PERCENT_TO_ALL",
|
||||
"duration" : "ONE_BATTLE",
|
||||
"sourceType" : "OTHER"
|
||||
}
|
||||
],
|
||||
"resources": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"queen":
|
||||
{
|
||||
"ai":
|
||||
[
|
||||
{
|
||||
"type" : "STACK_HEALTH",
|
||||
"val" : 150,
|
||||
"valueType" : "PERCENT_TO_ALL",
|
||||
"duration" : "ONE_BATTLE",
|
||||
"sourceType" : "OTHER"
|
||||
},
|
||||
],
|
||||
"resources": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
},
|
||||
|
||||
"king":
|
||||
{
|
||||
"ai":
|
||||
[
|
||||
{
|
||||
"type" : "STACK_HEALTH",
|
||||
"val" : 200,
|
||||
"valueType" : "PERCENT_TO_ALL",
|
||||
"duration" : "ONE_BATTLE",
|
||||
"sourceType" : "OTHER"
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
]
|
||||
"resources": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 },
|
||||
"globalBonuses": [],
|
||||
"battleBonuses": []
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ namespace GameConstants
|
||||
};
|
||||
|
||||
const std::string ALIGNMENT_NAMES [3] = {"good", "evil", "neutral"};
|
||||
|
||||
const std::string DIFFICULTY_NAMES [5] = {"pawn", "knight", "rook", "queen", "king"};
|
||||
}
|
||||
|
||||
namespace NPrimarySkill
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "../VCMI_Lib.h"
|
||||
#include "../battle/BattleInfo.h"
|
||||
#include "../campaign/CampaignState.h"
|
||||
#include "../constants/StringConstants.h"
|
||||
#include "../filesystem/ResourcePath.h"
|
||||
#include "../mapObjectConstructors/AObjectTypeHandler.h"
|
||||
#include "../mapObjectConstructors/CObjectClassesHandler.h"
|
||||
@ -450,13 +451,12 @@ void CGameState::init(const IMapService * mapService, StartInfo * si, Load::Prog
|
||||
initPlayerStates();
|
||||
if (campaign)
|
||||
campaign->placeCampaignHeroes();
|
||||
initBattleBonuses();
|
||||
removeHeroPlaceholders();
|
||||
initGrailPosition();
|
||||
initRandomFactionsForPlayers();
|
||||
randomizeMapObjects();
|
||||
placeStartingHeroes();
|
||||
initStartingResources();
|
||||
initDifficulty();
|
||||
initHeroes();
|
||||
initStartingBonus();
|
||||
initTowns();
|
||||
@ -658,29 +658,41 @@ void CGameState::initGlobalBonuses()
|
||||
VLC->creh->loadCrExpBon(globalEffects);
|
||||
}
|
||||
|
||||
void CGameState::initBattleBonuses()
|
||||
void CGameState::initDifficulty()
|
||||
{
|
||||
logGlobal->debug("\tLoading battle bonuses up resources");
|
||||
logGlobal->debug("\tLoading difficulty settings");
|
||||
const JsonNode config(JsonPath::builtin("config/difficulty.json"));
|
||||
|
||||
const JsonVector &vector = config["battleBonus"].Vector();
|
||||
const JsonNode &level = vector[scenarioOps->difficulty];
|
||||
const JsonNode & bonusesAI(level["ai"]);
|
||||
const JsonNode & bonusesHuman(level["human"]);
|
||||
const JsonNode & difficultyAI(level["ai"][GameConstants::DIFFICULTY_NAMES[scenarioOps->difficulty]]);
|
||||
const JsonNode & difficultyHuman(level["human"][GameConstants::DIFFICULTY_NAMES[scenarioOps->difficulty]]);
|
||||
|
||||
auto setDifficulty = [](PlayerState & state, const JsonNode & json)
|
||||
{
|
||||
//set starting resources
|
||||
state.resources = TResources(json["resources"]);
|
||||
|
||||
//set global bonuses
|
||||
for(auto & jsonBonus : json["globalBonuses"].Vector())
|
||||
if(auto bonus = JsonUtils::parseBonus(jsonBonus))
|
||||
state.addNewBonus(bonus);
|
||||
|
||||
//set battle bonuses
|
||||
for(auto & jsonBonus : json["battleBonuses"].Vector())
|
||||
if(auto bonus = JsonUtils::parseBonus(jsonBonus))
|
||||
state.battleBonuses.push_back(*bonus);
|
||||
|
||||
};
|
||||
|
||||
for (auto & elem : players)
|
||||
{
|
||||
PlayerState &p = elem.second;
|
||||
if(p.human)
|
||||
{
|
||||
for(auto & jsonBonus : bonusesHuman.Vector())
|
||||
p.battleBonuses.push_back(*JsonUtils::parseBonus(jsonBonus));
|
||||
}
|
||||
else
|
||||
{
|
||||
for(auto & jsonBonus : bonusesAI.Vector())
|
||||
p.battleBonuses.push_back(*JsonUtils::parseBonus(jsonBonus));
|
||||
}
|
||||
setDifficulty(p, p.human ? difficultyHuman : difficultyAI);
|
||||
}
|
||||
|
||||
if (campaign)
|
||||
campaign->initStartingResources();
|
||||
}
|
||||
|
||||
void CGameState::initGrailPosition()
|
||||
@ -839,30 +851,6 @@ void CGameState::removeHeroPlaceholders()
|
||||
}
|
||||
}
|
||||
|
||||
void CGameState::initStartingResources()
|
||||
{
|
||||
logGlobal->debug("\tSetting up resources");
|
||||
const JsonNode config(JsonPath::builtin("config/difficulty.json"));
|
||||
const JsonVector &vector = config["startres"].Vector();
|
||||
const JsonNode &level = vector[scenarioOps->difficulty];
|
||||
|
||||
TResources startresAI(level["ai"]);
|
||||
TResources startresHuman(level["human"]);
|
||||
|
||||
for (auto & elem : players)
|
||||
{
|
||||
PlayerState &p = elem.second;
|
||||
|
||||
if (p.human)
|
||||
p.resources = startresHuman;
|
||||
else
|
||||
p.resources = startresAI;
|
||||
}
|
||||
|
||||
if (campaign)
|
||||
campaign->initStartingResources();
|
||||
}
|
||||
|
||||
void CGameState::initHeroes()
|
||||
{
|
||||
for(auto hero : map->heroesOnMap) //heroes instances initialization
|
||||
|
@ -184,7 +184,6 @@ private:
|
||||
void initNewGame(const IMapService * mapService, bool allowSavingRandomMap, Load::ProgressAccumulator & progressTracking);
|
||||
void checkMapChecksum();
|
||||
void initGlobalBonuses();
|
||||
void initBattleBonuses();
|
||||
void initGrailPosition();
|
||||
void initRandomFactionsForPlayers();
|
||||
void randomizeMapObjects();
|
||||
@ -193,7 +192,7 @@ private:
|
||||
void placeStartingHeroes();
|
||||
void placeStartingHero(const PlayerColor & playerColor, const HeroTypeID & heroTypeId, int3 townPos);
|
||||
void removeHeroPlaceholders();
|
||||
void initStartingResources();
|
||||
void initDifficulty();
|
||||
void initHeroes();
|
||||
void placeHeroesInTowns();
|
||||
void initFogOfWar();
|
||||
|
Loading…
x
Reference in New Issue
Block a user