initial commit, lordsawar source, slightly modified
[lordsawar] / src / NextTurn.cpp
1 // Copyright (C) 2003, 2004, 2005 Ulf Lorenz
2 // Copyright (C) 2007, 2008 Ben Asselstine
3 // Copyright (C) 2007, 2008 Ole Laursen
4 //
5 //  This program is free software; you can redistribute it and/or modify
6 //  it under the terms of the GNU General Public License as published by
7 //  the Free Software Foundation; either version 3 of the License, or
8 //  (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU Library General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
18 //  02110-1301, USA.
19
20 #include "NextTurn.h"
21 #include "playerlist.h"
22
23 using namespace std;
24 #define debug(x) {cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<flush<<endl;}
25 //#define debug(x)
26
27 NextTurn::NextTurn(bool turnmode, bool random_turns)
28     :d_turnmode(turnmode), d_random_turns (random_turns), d_stop(false)
29 {
30   continuing_turn = false;
31   
32   Player *active = Playerlist::getActiveplayer();
33   abort = srequestAbort.connect(sigc::mem_fun(active, &Player::abortTurn));
34 }
35
36 void NextTurn::stop() 
37 {
38   d_stop = true;
39   srequestAbort.emit();
40 }
41
42 void NextTurn::nextPlayer()
43 {
44   Playerlist::getInstance()->nextPlayer();
45   Player *active = Playerlist::getActiveplayer();
46             
47   abort.disconnect();
48   abort = srequestAbort.connect(sigc::mem_fun(active, &Player::abortTurn));
49 }
50
51 NextTurn::~NextTurn()
52 {
53 }
54