mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Created battleStartpos.json from battleStartpos.txt.
This commit is contained in:
parent
c03a5eb4d2
commit
00adba18c9
81
config/battleStartpos.json
Normal file
81
config/battleStartpos.json
Normal file
@ -0,0 +1,81 @@
|
||||
{
|
||||
"battle_positions": [
|
||||
{
|
||||
"name" : "attackerLoose", // loose formation, attacker
|
||||
"levels": [
|
||||
[ 86 ],
|
||||
[ 35, 137 ],
|
||||
[ 35, 86, 137 ],
|
||||
[ 1, 69, 103, 171 ],
|
||||
[ 1, 35, 86, 137, 171 ],
|
||||
[ 1, 35, 69, 103, 137, 171 ],
|
||||
[ 1, 35, 69, 86, 103, 137, 171 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name" : "defenderLoose", // loose formation, defender
|
||||
"levels": [
|
||||
[ 100 ],
|
||||
[ 49, 151 ],
|
||||
[ 49, 100, 151 ],
|
||||
[ 15, 83, 117, 185 ],
|
||||
[ 15, 49, 100, 151, 185 ],
|
||||
[ 15, 49, 83, 117, 151, 185 ],
|
||||
[ 15, 49, 83, 100, 117, 151, 185 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name" : "attackerTight", // tight formation, attacker
|
||||
"levels": [
|
||||
[ 86 ],
|
||||
[ 69, 103 ],
|
||||
[ 69, 86, 103 ],
|
||||
[ 52, 69, 103, 120 ],
|
||||
[ 52, 69, 86, 103, 120 ],
|
||||
[ 35, 52, 69, 103, 120, 137 ],
|
||||
[ 35, 52, 69, 86, 103, 120, 137 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name" : "defenderTight", // tight formation, defender
|
||||
"levels": [
|
||||
[ 100 ],
|
||||
[ 83, 117 ],
|
||||
[ 83, 100, 117 ],
|
||||
[ 66, 83, 117, 134 ],
|
||||
[ 66, 83, 100, 117, 134 ],
|
||||
[ 49, 66, 83, 117, 134, 151 ],
|
||||
[ 49, 66, 83, 100, 117, 134, 151 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name" : "attackerCreBank", // creature bank, attacker
|
||||
"levels": [
|
||||
[ 57 ],
|
||||
[ 57, 61 ],
|
||||
[ 57, 61, 90 ],
|
||||
[ 57, 61, 90, 93 ],
|
||||
[ 57, 61, 90, 93, 96 ],
|
||||
[ 57, 61, 90, 93, 96, 125 ],
|
||||
[ 57, 61, 90, 93, 96, 125, 129 ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name" : "defenderCreBank", // creature bank, defender
|
||||
"levels": [
|
||||
[ 15 ],
|
||||
[ 15, 185 ],
|
||||
[ 15, 185, 171 ],
|
||||
[ 15, 185, 171, 1 ],
|
||||
[ 15, 185, 171, 1, 100 ],
|
||||
[ 15, 185, 171, 1, 100, 86 ],
|
||||
[ 15, 185, 171, 1, 100, 86, 8 ]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
//loose_formation
|
||||
//attacker
|
||||
86
|
||||
35 137
|
||||
35 86 137
|
||||
1 69 103 171
|
||||
1 35 86 137 171
|
||||
1 35 69 103 137 171
|
||||
1 35 69 86 103 137 171
|
||||
//defender
|
||||
100
|
||||
49 151
|
||||
49 100 151
|
||||
15 83 117 185
|
||||
15 49 100 151 185
|
||||
15 49 83 117 151 185
|
||||
15 49 83 100 117 151 185
|
||||
//tight_formation
|
||||
//atacker
|
||||
86
|
||||
69 103
|
||||
69 86 103
|
||||
52 69 103 120
|
||||
52 69 86 103 120
|
||||
35 52 69 103 120 137
|
||||
35 52 69 86 103 120 137
|
||||
//defender
|
||||
100
|
||||
83 117
|
||||
83 100 117
|
||||
66 83 117 134
|
||||
66 83 100 117 134
|
||||
49 66 83 117 134 151
|
||||
49 66 83 100 117 134 151
|
||||
//creature_bank
|
||||
//attacker
|
||||
57
|
||||
57 61
|
||||
57 61 90
|
||||
57 61 90 93
|
||||
57 61 90 93 96
|
||||
57 61 90 93 96 125
|
||||
57 61 90 93 96 125 129
|
||||
//defender
|
||||
15
|
||||
15 185
|
||||
15 185 171
|
||||
15 185 171 1
|
||||
15 185 171 1 100
|
||||
15 185 171 1 100 86
|
||||
15 185 171 1 100 86 8
|
@ -16,6 +16,7 @@
|
||||
#include "CSpellHandler.h"
|
||||
#include "CTownHandler.h"
|
||||
#include "NetPacks.h"
|
||||
#include "../lib/JsonNode.h"
|
||||
|
||||
/*
|
||||
* BattleState.h, part of VCMI engine
|
||||
@ -1372,16 +1373,17 @@ void BattleInfo::localInit()
|
||||
namespace CGH
|
||||
{
|
||||
using namespace std;
|
||||
static void readItTo(ifstream & input, vector< vector<int> > & dest) //reads 7 lines, i-th one containing i integers, and puts it to dest
|
||||
|
||||
static void readBattlePositions(const JsonNode &node, vector< vector<int> > & dest)
|
||||
{
|
||||
for(int j=0; j<7; ++j)
|
||||
BOOST_FOREACH(const JsonNode &level, node.Vector())
|
||||
{
|
||||
std::vector<int> pom;
|
||||
for(int g=0; g<j+1; ++g)
|
||||
BOOST_FOREACH(const JsonNode &value, level.Vector())
|
||||
{
|
||||
int hlp; input>>hlp;
|
||||
pom.push_back(hlp);
|
||||
pom.push_back(value.Float());
|
||||
}
|
||||
|
||||
dest.push_back(pom);
|
||||
}
|
||||
}
|
||||
@ -1419,31 +1421,18 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const
|
||||
}
|
||||
|
||||
//reading battleStartpos
|
||||
std::ifstream positions;
|
||||
positions.open(DATA_DIR "/config/battleStartpos.txt", std::ios_base::in|std::ios_base::binary);
|
||||
if(!positions.is_open())
|
||||
{
|
||||
tlog1<<"Unable to open battleStartpos.txt!"<<std::endl;
|
||||
}
|
||||
std::string dump;
|
||||
positions>>dump; positions>>dump;
|
||||
std::vector< std::vector<int> > attackerLoose, defenderLoose, attackerTight, defenderTight, attackerCreBank, defenderCreBank;
|
||||
CGH::readItTo(positions, attackerLoose);
|
||||
positions>>dump;
|
||||
CGH::readItTo(positions, defenderLoose);
|
||||
positions>>dump;
|
||||
positions>>dump;
|
||||
CGH::readItTo(positions, attackerTight);
|
||||
positions>>dump;
|
||||
CGH::readItTo(positions, defenderTight);
|
||||
positions>>dump;
|
||||
positions>>dump;
|
||||
CGH::readItTo(positions, attackerCreBank);
|
||||
positions>>dump;
|
||||
CGH::readItTo(positions, defenderCreBank);
|
||||
positions.close();
|
||||
//battleStartpos read
|
||||
const JsonNode config(DATA_DIR "/config/battleStartpos.json");
|
||||
const JsonVector &positions = config["battle_positions"].Vector();
|
||||
|
||||
CGH::readBattlePositions(positions[0]["levels"], attackerLoose);
|
||||
CGH::readBattlePositions(positions[1]["levels"], defenderLoose);
|
||||
CGH::readBattlePositions(positions[2]["levels"], attackerTight);
|
||||
CGH::readBattlePositions(positions[3]["levels"], defenderTight);
|
||||
CGH::readBattlePositions(positions[4]["levels"], attackerCreBank);
|
||||
CGH::readBattlePositions(positions[5]["levels"], defenderCreBank);
|
||||
|
||||
//battleStartpos read
|
||||
int k = 0; //stack serial
|
||||
for(TSlots::const_iterator i = armies[0]->Slots().begin(); i!=armies[0]->Slots().end(); i++, k++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user