2011-12-14 00:35:28 +03:00
|
|
|
#pragma once
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* StartInfo.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Struct which describes the name, the color, the starting bonus of a player
|
2009-04-16 14:14:13 +03:00
|
|
|
struct PlayerSettings
|
|
|
|
{
|
2010-07-31 16:55:05 +03:00
|
|
|
enum Ebonus {brandom=-1,bartifact, bgold, bresource};
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
si32 castle, hero, //ID, if -1 then random, if -2 then none
|
|
|
|
heroPortrait; //-1 if default, else ID
|
|
|
|
std::string heroName;
|
|
|
|
si8 bonus; //usees enum type Ebonus
|
|
|
|
ui8 color; //from 0 -
|
|
|
|
ui8 handicap;//0-no, 1-mild, 2-severe
|
2010-10-24 14:35:14 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
std::string name;
|
2010-10-24 14:35:14 +03:00
|
|
|
ui8 human; //0 - AI, non-0 serves as player id
|
2009-04-16 14:14:13 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & castle;
|
|
|
|
h & hero;
|
|
|
|
h & heroPortrait;
|
|
|
|
h & heroName;
|
|
|
|
h & bonus;
|
|
|
|
h & color;
|
|
|
|
h & handicap;
|
|
|
|
h & name;
|
|
|
|
h & human;
|
|
|
|
}
|
2009-08-17 11:50:31 +03:00
|
|
|
|
|
|
|
PlayerSettings()
|
|
|
|
{
|
|
|
|
bonus = brandom;
|
|
|
|
castle = -2;
|
|
|
|
heroPortrait = -1;
|
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Struct which describes the difficulty, the turn time,.. of a heroes match.
|
2009-04-16 14:14:13 +03:00
|
|
|
struct StartInfo
|
|
|
|
{
|
2010-12-22 22:14:40 +02:00
|
|
|
enum EMode {NEW_GAME, LOAD_GAME, CAMPAIGN, DUEL, INVALID = 255};
|
2010-08-18 12:50:25 +03:00
|
|
|
|
2010-10-24 14:35:14 +03:00
|
|
|
ui8 mode; //uses EMode enum
|
2009-04-16 14:14:13 +03:00
|
|
|
ui8 difficulty; //0=easy; 4=impossible
|
2010-12-20 23:22:53 +02:00
|
|
|
bmap<int, PlayerSettings> playerInfos; //color indexed
|
2009-04-16 14:14:13 +03:00
|
|
|
ui8 turnTime; //in minutes, 0=unlimited
|
|
|
|
std::string mapname;
|
2010-10-24 14:35:14 +03:00
|
|
|
ui8 whichMapInCampaign; //used only for mode CAMPAIGN
|
|
|
|
ui8 choosenCampaignBonus; //used only for mode CAMPAIGN
|
2009-04-16 14:14:13 +03:00
|
|
|
PlayerSettings & getIthPlayersSettings(int no)
|
|
|
|
{
|
2010-08-03 14:36:52 +03:00
|
|
|
if(playerInfos.find(no) != playerInfos.end())
|
|
|
|
return playerInfos[no];
|
2009-04-16 14:14:13 +03:00
|
|
|
tlog1 << "Cannot find info about player " << no <<". Throwing...\n";
|
|
|
|
throw std::string("Cannot find info about player");
|
2010-02-16 18:35:24 +02:00
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2010-10-24 14:35:14 +03:00
|
|
|
PlayerSettings *getPlayersSettings(const ui8 nameID)
|
2010-02-16 18:35:24 +02:00
|
|
|
{
|
2010-12-20 23:22:53 +02:00
|
|
|
for(bmap<int, PlayerSettings>::iterator it=playerInfos.begin(); it != playerInfos.end(); ++it)
|
2010-10-24 14:35:14 +03:00
|
|
|
if(it->second.human == nameID)
|
2010-08-03 14:36:52 +03:00
|
|
|
return &it->second;
|
2010-02-16 18:35:24 +02:00
|
|
|
|
|
|
|
return NULL;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2010-02-16 18:35:24 +02:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & mode;
|
|
|
|
h & difficulty;
|
|
|
|
h & playerInfos;
|
|
|
|
h & turnTime;
|
|
|
|
h & mapname;
|
2010-02-18 14:34:44 +02:00
|
|
|
h & whichMapInCampaign;
|
2010-07-31 16:55:05 +03:00
|
|
|
h & choosenCampaignBonus;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2010-10-24 14:35:14 +03:00
|
|
|
|
|
|
|
StartInfo()
|
|
|
|
{
|
|
|
|
mode = INVALID;
|
2011-04-26 16:30:29 +03:00
|
|
|
choosenCampaignBonus = -1;
|
2010-10-24 14:35:14 +03:00
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|