mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Reading treasure values from config.
This commit is contained in:
parent
62e9f13b08
commit
fdb81f4d5c
@ -9,26 +9,31 @@
|
||||
"1" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 1,
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true,
|
||||
"treasure" : {"min" : 1000, "max": 3000}
|
||||
},
|
||||
"2" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 2,
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true,
|
||||
"treaureLikeZone" : 1
|
||||
},
|
||||
"3" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 3,
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true,
|
||||
"treaureLikeZone" : 1
|
||||
},
|
||||
"4" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 4,
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true,
|
||||
"treaureLikeZone" : 1
|
||||
},
|
||||
"5" :
|
||||
{
|
||||
"type" : "treasure", "size" : 2, "terrainTypes" : [ "sand" ], "neutralTowns" : { "castles" : 1 }
|
||||
"type" : "treasure", "size" : 2, "terrainTypes" : [ "sand" ], "neutralTowns" : { "castles" : 1 },
|
||||
"treasure" : {"min" : 5000, "max": 10000}
|
||||
}
|
||||
},
|
||||
"connections" :
|
||||
@ -48,24 +53,29 @@
|
||||
"1" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 1,
|
||||
"playerTowns" : { "castles" : 1 }
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treasure" : {"min" : 500, "max": 2000}
|
||||
},
|
||||
"2" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 2,
|
||||
"playerTowns" : { "castles" : 1 }
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treaureLikeZone" : 1
|
||||
},
|
||||
"3" :
|
||||
{
|
||||
"type" : "treasure", "size" : 2, "neutralTowns" : { "towns" : 1 }, "townTypeLikeZone" : "1"
|
||||
"type" : "treasure", "size" : 2, "neutralTowns" : { "towns" : 1 }, "townTypeLikeZone" : "1",
|
||||
"treasure" : {"min" : 1500, "max": 4000}
|
||||
},
|
||||
"4" :
|
||||
{
|
||||
"type" : "treasure", "size" : 2, "neutralTowns" : { "towns" : 1 }, "townTypeLikeZone" : "2"
|
||||
"type" : "treasure", "size" : 2, "neutralTowns" : { "towns" : 1 }, "townTypeLikeZone" : "2",
|
||||
"treaureLikeZone" : 3
|
||||
},
|
||||
"5" :
|
||||
{
|
||||
"type" : "treasure", "size" : 3, "neutralTowns" : { "castles" : 1 }, "terrainTypes" : [ "sand" ]
|
||||
"type" : "treasure", "size" : 3, "neutralTowns" : { "castles" : 1 }, "terrainTypes" : [ "sand" ],
|
||||
"treasure" : {"min" : 6000, "max": 12000}
|
||||
}
|
||||
},
|
||||
"connections" :
|
||||
@ -87,27 +97,30 @@
|
||||
"1" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 3, "owner" : 1,
|
||||
"playerTowns" : { "castles" : 1 }
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treasure" : {"min" : 300, "max": 3000}
|
||||
},
|
||||
"2" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 3, "owner" : 2,
|
||||
"playerTowns" : { "castles" : 1 }
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treaureLikeZone" : 1
|
||||
},
|
||||
"3" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 3, "owner" : 3,
|
||||
"playerTowns" : { "castles" : 1 }
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treaureLikeZone" : 1
|
||||
},
|
||||
"4" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1" },
|
||||
"5" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1" },
|
||||
"6" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2" },
|
||||
"7" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2" },
|
||||
"8" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3" },
|
||||
"9" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3" },
|
||||
"10" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 } },
|
||||
"11" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 } },
|
||||
"12" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 } }
|
||||
"4" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasure" : {"min" : 3000, "max": 10000} },
|
||||
"5" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treaureLikeZone" : 4},
|
||||
"6" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2", "treaureLikeZone" : 4 },
|
||||
"7" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2", "treaureLikeZone" : 4 },
|
||||
"8" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treaureLikeZone" : 4 },
|
||||
"9" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treaureLikeZone" : 4 },
|
||||
"10" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasure" : {"min" : 10000, "max": 25000} },
|
||||
"11" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treaureLikeZone" : 10 },
|
||||
"12" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treaureLikeZone" : 10 }
|
||||
},
|
||||
"connections" :
|
||||
[
|
||||
|
@ -63,9 +63,32 @@ void CJsonRmgTemplateLoader::loadTemplates()
|
||||
zone->setMatchTerrainToTown(zoneNode["matchTerrainToTown"].Bool());
|
||||
zone->setTerrainTypes(parseTerrainTypes(zoneNode["terrainTypes"].Vector(), zone->getDefaultTerrainTypes()));
|
||||
zone->setTownsAreSameType((zoneNode["townsAreSameType"].Bool()));
|
||||
//TODO: do these lines even do anything?
|
||||
if(!zoneNode["terrainTypeLikeZone"].isNull()) zone->setTerrainTypeLikeZone(boost::lexical_cast<int>(zoneNode["terrainTypeLikeZone"].String()));
|
||||
if(!zoneNode["townTypeLikeZone"].isNull()) zone->setTownTypeLikeZone(boost::lexical_cast<int>(zoneNode["townTypeLikeZone"].String()));
|
||||
|
||||
//treasures
|
||||
if (!zoneNode["treasure"].isNull())
|
||||
{
|
||||
//TODO: parse vector of different treasure settings
|
||||
auto treasureInfo = zoneNode["treasure"].Struct();
|
||||
{
|
||||
CTreasureInfo ti;
|
||||
ti.min = treasureInfo["min"].Float();
|
||||
ti.max = treasureInfo["max"].Float();
|
||||
ti.density = 1; //TODO: use me
|
||||
zone->addTreasureInfo(ti);
|
||||
}
|
||||
}
|
||||
if (!zoneNode["treasureLikeZone"].isNull())
|
||||
{
|
||||
//TODO: check if the zone with that index exists
|
||||
for (auto treasureInfo : zones[zoneNode["treasureLikeZone"].Float()]->getTreasureInfo())
|
||||
{
|
||||
zone->addTreasureInfo(treasureInfo);
|
||||
}
|
||||
}
|
||||
|
||||
zones[zone->getId()] = zone;
|
||||
}
|
||||
tpl->setZones(zones);
|
||||
|
@ -282,6 +282,17 @@ std::vector<TRmgTemplateZoneId> CRmgTemplateZone::getConnections() const
|
||||
{
|
||||
return connections;
|
||||
}
|
||||
|
||||
void CRmgTemplateZone::addTreasureInfo(CTreasureInfo & info)
|
||||
{
|
||||
treasureInfo.push_back(info);
|
||||
}
|
||||
|
||||
std::vector<CTreasureInfo> CRmgTemplateZone::getTreasureInfo()
|
||||
{
|
||||
return treasureInfo;
|
||||
}
|
||||
|
||||
float3 CRmgTemplateZone::getCenter() const
|
||||
{
|
||||
return center;
|
||||
@ -449,8 +460,17 @@ void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
||||
bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos)
|
||||
{
|
||||
//TODO: read treasure values from template
|
||||
const int maxValue = 5000;
|
||||
const int minValue = 1500;
|
||||
|
||||
//default values
|
||||
int maxValue = 5000;
|
||||
int minValue = 1500;
|
||||
|
||||
//TODO: choose random treasure info based on density
|
||||
if (treasureInfo.size())
|
||||
{
|
||||
maxValue = treasureInfo.front().max;
|
||||
minValue = treasureInfo.front().min;
|
||||
}
|
||||
|
||||
static const Res::ERes woodOre[] = {Res::ERes::WOOD, Res::ERes::ORE};
|
||||
static const Res::ERes preciousRes[] = {Res::ERes::CRYSTAL, Res::ERes::GEMS, Res::ERes::MERCURY, Res::ERes::SULFUR};
|
||||
|
@ -53,6 +53,14 @@ private:
|
||||
ETerrainType terrain;
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CTreasureInfo
|
||||
{
|
||||
public:
|
||||
ui32 min;
|
||||
ui32 max;
|
||||
ui16 density;
|
||||
};
|
||||
|
||||
/// The CRmgTemplateZone describes a zone in a template.
|
||||
class DLL_LINKAGE CRmgTemplateZone
|
||||
{
|
||||
@ -121,6 +129,8 @@ public:
|
||||
|
||||
void addConnection(TRmgTemplateZoneId otherZone);
|
||||
std::vector<TRmgTemplateZoneId> getConnections() const;
|
||||
void addTreasureInfo(CTreasureInfo & info);
|
||||
std::vector<CTreasureInfo> getTreasureInfo();
|
||||
|
||||
private:
|
||||
//template info
|
||||
@ -135,6 +145,8 @@ private:
|
||||
std::set<ETerrainType> terrainTypes;
|
||||
boost::optional<TRmgTemplateZoneId> terrainTypeLikeZone, townTypeLikeZone;
|
||||
|
||||
std::vector<CTreasureInfo> treasureInfo;
|
||||
|
||||
//content info
|
||||
std::vector<int3> shape; //TODO: remove
|
||||
std::vector<std::pair<CGObjectInstance*, ui32>> requiredObjects;
|
||||
|
Loading…
Reference in New Issue
Block a user