1 // Copyright (C) 2003, 2004, 2005, 2006 Ulf Lorenz
2 // Copyright (C) 2007, 2008 Ben Asselstine
3 // Copyright (C) 2007, 2008 Ole Laursen
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.
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.
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
23 #include <sigc++/trackable.h>
24 #include <sigc++/connection.h>
25 #include "playerlist.h"
29 \brief The class to pass turns around the players
31 \note This class takes care of calling the correct players in the correct
32 order. The problem is, no other class really has the scope of doing
33 this whole stuff. The playerlist and the game object aren't the
34 right candidates (they are busy with other things) and the former
35 algorithm of each player calling the next one produces a huge
36 stackload if two ai players fight each other. Plus, you want to do
37 several actions at the end or the beginning of each player's turn
38 or each round and therefore want a central place for this code.
41 class NextTurn: public sigc::trackable
47 @param turnmode setting for the private variable d_turnmode
48 @param random_turns change the order every round
50 NextTurn(bool turnmode, bool random_turns);
58 \brief start a new game
60 This function starts with the currently active player, or the first
61 if there is none active. For starting a game. This should be the
62 lowest of all scenario-related functions in the stack.
64 virtual void start()=0;
67 \brief go on to the next player
69 This function starts the next to the active player's turn. Used when
70 a human player has pushed the next_turn button.
72 virtual void endTurn()=0;
78 void setContinuingTurn() { continuing_turn = true; };
81 \brief signals for announcing events
83 sigc::signal<void, Player*> splayerStart;
85 // emitted whenever a new player's turn starts.
86 sigc::signal<void, Player*> snextTurn;
88 //! Signal which is emitted whenever a new round starts
89 sigc::signal<void> snextRound;
91 //! Signal as a workaround for a display bug; updates the screen
92 sigc::signal<void> supdating;
94 //! Signal when we're done doing next-turn duties.
95 sigc::signal<void> srequestAbort;
99 /** \brief determines whether armies are healed/produced at the
100 * beginning of a round or at the beginning of each player's turn.
102 * If the value is set to true, the production/healing of armies takes
103 * place at the beginning of each player's turn (which is fairer); else
104 * all armies of all playes are healed when a new game round starts.
105 * The latter setting is a bit unfair, because the last player knows
106 * that his armies are healed immediately when he has finished his turn
107 * while the other player's armies may have to survive some attacks,
108 * but it may be useful in some circumstances.
114 //! If set to true, the game is interrupted at the next occasion
117 // whether we're starting a turn again from loading a game
118 bool continuing_turn;
122 sigc::connection abort;