Make component interfaces inherit Component.
[tagua/yd.git] / src / core / state.h
blobe4714fe583f036654520b0255469620367ccaf05
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
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 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef CORE__STATE_H
12 #define CORE__STATE_H
14 #include "component.h"
15 #include "taguaobject.h"
17 class Board;
18 class IBehaviour;
19 class IColor;
20 class IPoolCollection;
21 class Move;
23 /**
24 * @brief The state of the game in a given moment of time.
26 * A State component encapsulates the global state of the game, i.e.
27 * what pieces are on the board or on the pool, and game flags like
28 * the en-passant square for chess.
30 * A State component also provides methods to setup the initial
31 * configuration and to make a move.
33 class TAGUA_EXPORT IState: public Component {
34 public:
35 virtual ~IState();
37 virtual IState* clone() const = 0;
39 /**
40 * Setup the initial configuration of pieces and reset all flags.
42 virtual void setup() = 0;
44 /**
45 * @return The piece board.
47 virtual const Board* board() const = 0;
48 virtual Board* board() = 0;
50 /**
51 * @return The player who plays next.
53 virtual const IColor* turn() const = 0;
55 /**
56 * Change the current turn.
58 virtual void setTurn(const IColor* turn) = 0;
60 /**
61 * @return Whether two states are equal.
63 virtual bool equals(IState* other) const = 0;
65 /**
66 * Make this state equal to the given one.
68 virtual void assign(const IState* other) = 0;
70 /**
71 * Play a move.
73 virtual void move(const Move& move) = 0;
75 /**
76 * @return Current flags.
78 virtual TaguaObject* flags() = 0;
79 virtual const TaguaObject* flags() const = 0;
81 /**
82 * @return The absolute index of the n-th rank for a given player.
84 virtual int rank(int n, const IColor* turn) const = 0;
86 /**
87 * @return The pool collection associated to this state.
89 virtual const IPoolCollection* pools() const = 0;
90 virtual IPoolCollection* pools() = 0;
92 /**
93 * @return The behaviour object associated to this state.
95 virtual const IBehaviour* behaviour() const = 0;
97 virtual void setDelegator(IState* state) = 0;
100 #endif // CORE__STATE_H