mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Moved the starting ressources into a json file.
This commit is contained in:
parent
3519cca2c9
commit
b3a3cabd5b
31
config/startres.json
Normal file
31
config/startres.json
Normal file
@ -0,0 +1,31 @@
|
||||
// Starting ressources, ordered by difficulty level (0 to 4)
|
||||
{
|
||||
"difficulty":
|
||||
[
|
||||
{
|
||||
"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 }
|
||||
},
|
||||
|
||||
{
|
||||
"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 }
|
||||
},
|
||||
|
||||
{
|
||||
"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 }
|
||||
},
|
||||
|
||||
{
|
||||
"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 }
|
||||
}
|
||||
|
||||
{
|
||||
"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 }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
0 30 15 30 15 15 15 30000 0
|
||||
0 5 2 5 2 2 2 5000 0
|
||||
1 20 10 20 10 10 10 20000 0
|
||||
1 10 4 10 4 4 4 7500 0
|
||||
2 15 7 15 7 7 7 15000 0
|
||||
2 15 7 15 7 7 7 10000 0
|
||||
3 10 4 10 4 4 4 10000 0
|
||||
3 15 7 15 7 7 7 10000 0
|
||||
4 0 0 0 0 0 0 0 0
|
||||
4 15 7 15 7 7 7 10000 0
|
||||
|
||||
Resources on start. Format:
|
||||
Difficulty wood mercury ore sulfur crystal gems gold mithril
|
||||
|
||||
first line: for human players
|
||||
second line: for AI players
|
@ -30,6 +30,7 @@
|
||||
#include <numeric>
|
||||
#include "CMapInfo.h"
|
||||
#include "BattleState.h"
|
||||
#include "../lib/JsonNode.h"
|
||||
|
||||
boost::rand48 ran;
|
||||
class CGObjectInstance;
|
||||
@ -1185,24 +1186,30 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
|
||||
/******************RESOURCES****************************************************/
|
||||
TResources startresAI, startresHuman;
|
||||
std::ifstream tis(DATA_DIR "/config/startres.txt");
|
||||
int k;
|
||||
for (int j=0; j<scenarioOps->difficulty * 2; j++)
|
||||
{
|
||||
tis >> k;
|
||||
for (int z=0;z<RESOURCE_QUANTITY;z++)
|
||||
tis>>k;
|
||||
}
|
||||
tis >> k;
|
||||
for (int i=0; i<RESOURCE_QUANTITY; i++)
|
||||
tis >> startresHuman[i];
|
||||
const JsonNode config(DATA_DIR "/config/startres.json");
|
||||
const JsonVector &vector = config["difficulty"].Vector();
|
||||
const JsonNode &level = vector[scenarioOps->difficulty];
|
||||
const JsonNode &human = level["human"];
|
||||
const JsonNode &ai = level["ai"];
|
||||
|
||||
tis >> k;
|
||||
for (int i=0; i<RESOURCE_QUANTITY; i++)
|
||||
tis >> startresAI[i];
|
||||
startresHuman[0] = human["wood"].Float();
|
||||
startresHuman[1] = human["mercury"].Float();
|
||||
startresHuman[2] = human["ore"].Float();
|
||||
startresHuman[3] = human["sulfur"].Float();
|
||||
startresHuman[4] = human["crystal"].Float();
|
||||
startresHuman[5] = human["gems"].Float();
|
||||
startresHuman[6] = human["gold"].Float();
|
||||
startresHuman[7] = human["mithril"].Float();
|
||||
|
||||
startresAI[0] = ai["wood"].Float();
|
||||
startresAI[1] = ai["mercury"].Float();
|
||||
startresAI[2] = ai["ore"].Float();
|
||||
startresAI[3] = ai["sulfur"].Float();
|
||||
startresAI[4] = ai["crystal"].Float();
|
||||
startresAI[5] = ai["gems"].Float();
|
||||
startresAI[6] = ai["gold"].Float();
|
||||
startresAI[7] = ai["mithril"].Float();
|
||||
|
||||
tis.close();
|
||||
tis.clear();
|
||||
for (std::map<ui8,PlayerState>::iterator i = players.begin(); i!=players.end(); i++)
|
||||
{
|
||||
PlayerState &p = i->second;
|
||||
|
Loading…
Reference in New Issue
Block a user