1 // Copyright (C) 2002, 2003 Michael Bartl
2 // Copyright (C) 2002, 2003, 2004, 2005, 2006 Ulf Lorenz
3 // Copyright (C) 2004, 2006 Andrea Paternesi
4 // Copyright (C) 2004 John Farrell
5 // Copyright (C) 2004 Bryan Duff
6 // Copyright (C) 2006, 2007, 2008, 2009 Ben Asselstine
7 // Copyright (C) 2007, 2008 Ole Laursen
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 3 of the License, or
12 // (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU Library General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 #include "real_player.h"
31 #include "playerlist.h"
32 #include "stacklist.h"
35 #include "herotemplates.h"
37 #include "xmlhelper.h"
38 #include "GameScenarioOptions.h"
43 //#define debug(x) {cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<endl<<flush;}
46 RealPlayer::RealPlayer(string name, guint32 armyset, Gdk::Color color, int width,
47 int height, Player::Type type, int player_no)
48 :Player(name, armyset, color, width, height, type, player_no),
49 d_abort_requested(false)
53 RealPlayer::RealPlayer(const Player& player)
57 d_abort_requested = false;
60 RealPlayer::RealPlayer(XML_Helper* helper)
61 :Player(helper), d_abort_requested(false)
65 RealPlayer::~RealPlayer()
69 bool RealPlayer::save(XML_Helper* helper) const
71 // This may seem a bit dumb, but allows derived players (especially
72 // AI's) to save additional data, such as character types or so.
74 retval &= helper->openTag(Player::d_tag);
75 retval &= Player::save(helper);
76 retval &= helper->closeTag();
81 void RealPlayer::abortTurn()
86 bool RealPlayer::startTurn()
91 void RealPlayer::endTurn()
93 History *history = new History_EndTurn();
96 Action *action = new Action_EndTurn;
100 void RealPlayer::invadeCity(City* c)
102 // For the realplayer, this function doesn't do a lot. However, an AI
103 // player has to decide here what to do (occupy, raze, pillage)
106 bool RealPlayer::chooseHero(HeroProto *hero, City* c, int gold)
108 // For the realplayer, this function doesn't do a lot. However, an AI
109 // player has to decide here what to do (accept/deny hero)
113 Reward *RealPlayer::chooseReward(Ruin *ruin, Sage *sage, Stack *stack)
115 // For the realplayer, this function doesn't do a lot. However, an AI
116 // player has to decide here what to do (pick a reward from sage)
120 bool RealPlayer::chooseTreachery (Stack *stack, Player *player, Vector <int> pos)
122 // For the realplayer, this function doesn't do a lot. However, an AI
123 // player has to decide here what to do (fight a friend or not)
127 Army::Stat RealPlayer::chooseStat(Hero *hero)
129 // For the realplayer, this function doesn't do a lot. However, an AI
130 // player has to decide here what to do (pick strength/moves/sight stat)
131 return Army::STRENGTH;
134 bool RealPlayer::chooseQuest(Hero *hero)
136 //we decide interactively with the gui, not by this method.
137 // For the realplayer, this function doesn't do a lot. However, an AI
138 // player has to decide here what to do (get a quest for the hero or not)
142 void RealPlayer::heroGainsLevel(Hero* a)
144 // the standard human player just asks the GUI what to do
145 Army::Stat stat = sheroGainsLevel.emit(a);
146 doHeroGainsLevel(a, stat);
148 Action_Level* item = new Action_Level();
149 item->fillData(a, stat);