1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

- Fixed issues with number of players selection

- Added new template for testing multiple players
This commit is contained in:
DjWarmonger 2015-05-27 18:58:14 +02:00
parent 6890ae9f02
commit 34a59a2788
3 changed files with 280 additions and 16 deletions

View File

@ -0,0 +1,239 @@
{
"Coldshadow's Fantasy":
{
"minSize" : "xl+u", "maxSize" : "xl+u",
"players" : "4-8", "cpu" : "3-6",
"zones":
{
"1":
{
"type" : "playerStart", "size" : 30, "owner" : 1,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "normal",
"mines" : {"wood" : 2, "ore" : 2, "gems" : 1, "crystal" : 1, "sulfur" : 1, "mercury" : 1, "gold" : 1},
"treasure" : [
{"min" : 7500, "max": 25000, "density": 4},
{"min" : 3000, "max": 9000, "density": 6},
{"min" : 300, "max": 3000, "density": 8}
]
},
"2":
{
"type" : "cpuStart", "size" : 30, "owner" : 2,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "weak",
"minesLikeZone" : 1,
"treasureLikeZone" : 1
},
"3":
{
"type" : "cpuStart", "size" : 30, "owner" : 3,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "weak",
"minesLikeZone" : 1,
"treasureLikeZone" : 1
},
"4":
{
"type" : "cpuStart", "size" : 30, "owner" : 4,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "weak",
"minesLikeZone" : 1,
"treasureLikeZone" : 1
},
"5":
{
"type" : "playerStart", "size" : 30, "owner" : 5,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "normal",
"minesLikeZone" : 1,
"treasureLikeZone" : 1
},
"6":
{
"type" : "cpuStart", "size" : 30, "owner" : 6,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "weak",
"minesLikeZone" : 1,
"treasureLikeZone" : 1
},
"7":
{
"type" : "cpuStart", "size" : 30, "owner" : 7,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "weak",
"minesLikeZone" : 1,
"treasureLikeZone" : 1
},
"8":
{
"type" : "cpuStart", "size" : 30, "owner" : 8,
"playerTowns" : { "castles" : 1 },
"neutralTowns" : { "towns" : 1 },
"monsters" : "weak",
"minesLikeZone" : 1,
"treasureLikeZone" : 1
},
"9":
{
"type" : "treasure", "size" : 15,
"terrainTypes" : ["subterra"], "matchTerrainToTown" : false,
"neutralTowns" : { "castles" : 1 },
"monsters" : "strong",
"mines" : {"gems" : 1, "sulfur" : 1, "mercury" : 1, "crystal" : 1},
"treasure" : [
{"min" : 45000, "max": 75000, "density": 3},
{"min" : 15000, "max": 50000, "density": 3},
{"min" : 3080, "max": 12500, "density": 4}
]
},
"10":
{
"type" : "treasure", "size" : 15,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "normal",
"minesLikeZone" : 9,
"treasureLikeZone" : 9
},
"11":
{
"type" : "treasure", "size" : 15,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "normal",
"minesLikeZone" : 9,
"treasureLikeZone" : 9
},
"12":
{
"type" : "treasure", "size" : 15,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "normal",
"minesLikeZone" : 9,
"treasureLikeZone" : 9
},
"13":
{
"type" : "treasure", "size" : 15,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "strong",
"minesLikeZone" : 9,
"treasureLikeZone" : 9
},
"14":
{
"type" : "treasure", "size" : 15,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "normal",
"minesLikeZone" : 9,
"treasureLikeZone" : 9
},
"15":
{
"type" : "treasure", "size" : 15,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "normal",
"minesLikeZone" : 9,
"treasureLikeZone" : 9
},
"16":
{
"type" : "treasure", "size" : 15,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "normal",
"minesLikeZone" : 9,
"treasureLikeZone" : 9
},
"17":
{
"type" : "junction", "size" : 30,
"terrainTypeLikeZone" : 9,
"allowedTowns" : ["neutral"],
"monsters" : "strong",
"mines" : {"gold" : 1},
"treasure" : [
{"min" : 65000, "max": 100000, "density": 3},
{"min" : 50000, "max": 100000, "density": 3},
{"min" : 10000, "max": 15000, "density": 3}
]
},
"18":
{
"type" : "junction", "size" : 30,
"terrainTypeLikeZone" : 9,
"allowedTowns" : ["neutral"],
"monsters" : "strong",
"minesLikeZone" : 17,
"treasureLikeZone" : 17
},
"19":
{
"type" : "junction", "size" : 30,
"terrainTypeLikeZone" : 9,
"allowedTowns" : ["neutral"],
"monsters" : "strong",
"minesLikeZone" : 17,
"treasureLikeZone" : 17
},
"20":
{
"type" : "junction", "size" : 30,
"terrainTypeLikeZone" : 9,
"allowedTowns" : ["neutral"],
"monsters" : "strong",
"minesLikeZone" : 17,
"treasureLikeZone" : 17
},
"21":
{
"type" : "treasure", "size" : 20,
"terrainTypeLikeZone" : 9,
"neutralTowns" : { "castles" : 1 },
"monsters" : "strong",
"treasure" : [
{"min" : 100000, "max": 130000, "density": 3},
{"min" : 100000, "max": 150000, "density": 3},
{"min" : 20000, "max": 60000, "density": 3}
]
}
},
"connections" :
[
{ "a" : "1", "b" : "9", "guard" : 36000 },
{ "a" : "2", "b" : "10", "guard" : 12000 },
{ "a" : "3", "b" : "11", "guard" : 12000 },
{ "a" : "4", "b" : "12", "guard" : 12000 },
{ "a" : "5", "b" : "13", "guard" : 36000 },
{ "a" : "6", "b" : "14", "guard" : 12000 },
{ "a" : "7", "b" : "15", "guard" : 12000 },
{ "a" : "8", "b" : "16", "guard" : 12000 },
{ "a" : "9", "b" : "17", "guard" : 75000 },
{ "a" : "10", "b" : "17", "guard" : 25000 },
{ "a" : "11", "b" : "18", "guard" : 25000 },
{ "a" : "12", "b" : "18", "guard" : 25000 },
{ "a" : "13", "b" : "19", "guard" : 75000 },
{ "a" : "14", "b" : "19", "guard" : 25000 },
{ "a" : "15", "b" : "20", "guard" : 25000 },
{ "a" : "16", "b" : "20", "guard" : 25000 },
{ "a" : "17", "b" : "18", "guard" : 50000 },
{ "a" : "19", "b" : "20", "guard" : 50000 },
{ "a" : "17", "b" : "21", "guard" : 60000 },
{ "a" : "18", "b" : "21", "guard" : 60000 },
{ "a" : "19", "b" : "21", "guard" : 60000 },
{ "a" : "20", "b" : "21", "guard" : 60000 }
]
}
}

View File

@ -0,0 +1,12 @@
{
"name" : "Coldshadow's Fantasy",
"description" : "Random map template, 4-8p XL+U",
"version" : "0.99",
"author" : "Coldshadow, ported by VCMI Team",
"contact" : "http://forum.vcmi.eu/index.php",
"modType" : "Templates",
"templates" : [
"config/defaultTemplates/coldshadowsFantasy"
],
}

View File

@ -67,11 +67,14 @@ void CMapGenOptions::setPlayerCount(si8 value)
{
assert((value >= 1 && value <= PlayerColor::PLAYER_LIMIT_I) || value == RANDOM_SIZE);
playerCount = value;
auto possibleCompPlayersCount = value;
if (compOnlyPlayerCount > possibleCompPlayersCount)
setCompOnlyPlayerCount(possibleCompPlayersCount);
humanPlayersCount = playerCount - compOnlyPlayerCount;
if (getPlayerCount() != RANDOM_SIZE && getCompOnlyPlayerCount() != RANDOM_SIZE)
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
resetPlayersMap();
}
@ -82,7 +85,7 @@ si8 CMapGenOptions::getTeamCount() const
void CMapGenOptions::setTeamCount(si8 value)
{
assert(playerCount == RANDOM_SIZE || (value >= 0 && value < playerCount) || value == RANDOM_SIZE);
assert(getPlayerCount() == RANDOM_SIZE || (value >= 0 && value < getPlayerCount()) || value == RANDOM_SIZE);
teamCount = value;
}
@ -93,9 +96,12 @@ si8 CMapGenOptions::getCompOnlyPlayerCount() const
void CMapGenOptions::setCompOnlyPlayerCount(si8 value)
{
assert(value == RANDOM_SIZE || (value >= 0 && value <= playerCount));
assert(value == RANDOM_SIZE || (value >= 0 && value <= getPlayerCount()));
compOnlyPlayerCount = value;
humanPlayersCount = playerCount - compOnlyPlayerCount;
if (getPlayerCount() != RANDOM_SIZE && getCompOnlyPlayerCount() != RANDOM_SIZE)
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
resetPlayersMap();
}
@ -136,7 +142,7 @@ void CMapGenOptions::resetPlayersMap()
int realPlayersCnt = humanPlayersCount;
int realCompOnlyPlayersCnt = (compOnlyPlayerCount == RANDOM_SIZE) ? (PlayerColor::PLAYER_LIMIT_I - realPlayersCnt) : compOnlyPlayerCount;
int totalPlayersLimit = realPlayersCnt + realCompOnlyPlayersCnt;
if(playerCount == RANDOM_SIZE || compOnlyPlayerCount == RANDOM_SIZE)
if (getPlayerCount() == RANDOM_SIZE || compOnlyPlayerCount == RANDOM_SIZE)
totalPlayersLimit = static_cast<int>(PlayerColor::PLAYER_LIMIT_I);
//FIXME: what happens with human players here?
@ -145,7 +151,7 @@ void CMapGenOptions::resetPlayersMap()
CPlayerSettings player;
player.setColor(PlayerColor(color));
auto playerType = EPlayerType::AI;
if((playerCount != RANDOM_SIZE && color >= realPlayersCnt)
if ((getPlayerCount() != RANDOM_SIZE && color >= realPlayersCnt)
|| (compOnlyPlayerCount != RANDOM_SIZE && color >= (PlayerColor::PLAYER_LIMIT_I-compOnlyPlayerCount)))
{
playerType = EPlayerType::COMP_ONLY;
@ -195,7 +201,7 @@ const std::map<std::string, CRmgTemplate *> & CMapGenOptions::getAvailableTempla
void CMapGenOptions::finalize(CRandomGenerator & rand)
{
logGlobal->infoStream() << boost::format ("RMG settings: players %d, teams %d, computer players %d, computer teams %d, water %d, monsters %d")
% playerCount % teamCount % compOnlyPlayerCount % compOnlyTeamCount % waterContent % monsterStrength;
% getPlayerCount() % getTeamCount() % getCompOnlyPlayerCount() % getCompOnlyTeamCount() % getWaterContent() % getMonsterStrength();
if(!mapTemplate)
{
@ -203,17 +209,17 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
}
assert(mapTemplate);
if(playerCount == RANDOM_SIZE)
if (getPlayerCount() == RANDOM_SIZE)
{
auto possiblePlayers = mapTemplate->getPlayers().getNumbers();
possiblePlayers.erase(possiblePlayers.begin(), possiblePlayers.lower_bound(countHumanPlayers()));
assert(!possiblePlayers.empty());
playerCount = *RandomGeneratorUtil::nextItem(possiblePlayers, rand);
setPlayerCount (*RandomGeneratorUtil::nextItem(possiblePlayers, rand));
updatePlayers();
}
if(teamCount == RANDOM_SIZE)
{
teamCount = rand.nextInt(playerCount - 1);
teamCount = rand.nextInt(getPlayerCount() - 1);
if (teamCount == 1)
teamCount = 0;
}
@ -252,7 +258,7 @@ void CMapGenOptions::updatePlayers()
{
auto it = itrev;
--it;
if(players.size() == playerCount) break;
if (players.size() == getPlayerCount()) break;
if(it->second.getPlayerType() == EPlayerType::AI)
{
players.erase(it);
@ -271,7 +277,7 @@ void CMapGenOptions::updateCompOnlyPlayers()
{
auto it = itrev;
--it;
if (players.size() <= playerCount) break;
if (players.size() <= getPlayerCount()) break;
if(it->second.getPlayerType() == EPlayerType::COMP_ONLY)
{
players.erase(it);
@ -283,7 +289,13 @@ void CMapGenOptions::updateCompOnlyPlayers()
}
// Add some comp only players if necessary
auto compOnlyPlayersToAdd = playerCount - players.size();
int compOnlyPlayersToAdd = getPlayerCount() - players.size();
if (compOnlyPlayersToAdd < 0)
{
logGlobal->errorStream() << boost::format("Incorrect number of players to add. Requested players %d, current players %d") % playerCount % players.size();
assert (compOnlyPlayersToAdd < 0);
}
for(int i = 0; i < compOnlyPlayersToAdd; ++i)
{
CPlayerSettings pSettings;
@ -310,7 +322,8 @@ PlayerColor CMapGenOptions::getNextPlayerColor() const
return i;
}
}
assert(0);
logGlobal->errorStream() << "Failed to get next player color";
assert(false);
return PlayerColor(0);
}
@ -340,9 +353,9 @@ const CRmgTemplate * CMapGenOptions::getPossibleTemplate(CRandomGenerator & rand
if(tplSize >= tpl->getMinSize() && tplSize <= tpl->getMaxSize())
{
bool isPlayerCountValid = false;
if(playerCount != RANDOM_SIZE)
if (getPlayerCount() != RANDOM_SIZE)
{
if (tpl->getPlayers().isInRange(playerCount))
if (tpl->getPlayers().isInRange(getPlayerCount()))
isPlayerCountValid = true;
}
else