c5f345d4b52387b1bf6eb73a5dcfef3b8bbb7c70
[tagua/yd.git] / src / core / behaviour.h
blobc5f345d4b52387b1bf6eb73a5dcfef3b8bbb7c70
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 */
10 #ifndef CORE__BEHAVIOUR_H
11 #define CORE__BEHAVIOUR_H
13 #include "export.h"
14 #include "point.h"
16 class IColor;
17 class IState;
18 class Move;
20 /**
21 * @brief Encapsulates general rules on piece movement.
23 class TAGUA_EXPORT IBehaviour {
24 public:
25 virtual ~IBehaviour();
27 /**
28 * Perform a capture on a given square. In variants with drops, this
29 * adds the captured piece to the opponent pool. In games like chess,
30 * this does nothing.
32 virtual void captureOn(IState* state, const Point& square) const = 0;
34 /**
35 * Set the moving piece in its destination square, without affecting
36 * the current turn or flags.
37 * This is a helper function normally called by move.
39 virtual void move(IState* state, const Move& m) const = 0;
41 /**
42 * Set next turn as the current turn.
44 virtual void advanceTurn(IState* state) const = 0;
46 /**
47 * @return The square where a given move would capture if executed.
49 virtual Point captureSquare(const IState* state, const Move& m) const = 0;
51 /**
52 * @return The opponent of @a color.
54 virtual const IColor* opponent(const IColor* player) const = 0;
56 /**
57 * Players can have associated directions. For example, in chess,
58 * white pieces move towards the 8th rank.
59 * Associated directions are often used during move validation.
60 * @return Direction associated with @a player.
62 virtual Point direction(const IColor* player) const = 0;
65 #endif // CORE__BEHAVIOUR_H