Initial porting to the new component API.
[tagua/yd.git] / src / core / state.h
blob45e76b0ad4dd727e90c20044606d2a31e23f3ba9
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 "taguaobject.h"
16 class Board;
17 class IColor;
18 class Move;
20 /**
21 * @brief The state of the game in a given moment of time.
23 * A State component encapsulates the global state of the game, i.e.
24 * what pieces are on the board or on the pool, and game flags like
25 * the en-passant square for chess.
27 * A State component also provides methods to setup the initial
28 * configuration and to make a move.
30 class TAGUA_EXPORT IState {
31 public:
32 virtual ~IState();
34 virtual IState* clone() const = 0;
36 /**
37 * Setup the initial configuration of pieces and reset all flags.
39 virtual void setup() = 0;
41 /**
42 * @return The piece board.
44 virtual const Board* board() const = 0;
45 virtual Board* board() = 0;
47 /**
48 * @return The player who plays next.
50 virtual const IColor* turn() const = 0;
52 /**
53 * Change the current turn.
55 virtual void setTurn(const IColor* turn) = 0;
57 /**
58 * @return Whether two states are equal.
60 virtual bool equals(IState* other) const = 0;
62 /**
63 * Make this state equal to the given one.
65 virtual void assign(const IState* other) = 0;
67 /**
68 * Play a move.
70 virtual void move(const Move& move) = 0;
72 /**
73 * @return Current flags.
75 virtual TaguaObject flags() const = 0;
77 /**
78 * @return The opponent of @a color.
80 virtual const IColor* opponent(const IColor* color) const = 0;
82 /**
83 * Set next turn as the current turn.
85 virtual void advanceTurn() = 0;
88 #endif // CORE__STATE_H