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.
10 #ifndef CORE__BEHAVIOUR_H
11 #define CORE__BEHAVIOUR_H
13 #include "component.h"
22 * @brief Encapsulates general rules on piece movement.
24 class TAGUA_EXPORT IBehaviour
: public Component
{
26 virtual ~IBehaviour();
29 * Perform a capture on a given square. In variants with drops, this
30 * adds the captured piece to the opponent pool. In games like chess,
33 virtual void captureOn(IState
* state
, const Point
& square
) const = 0;
36 * Set the moving piece in its destination square, without affecting
37 * the current turn or flags.
38 * This is a helper function normally called by move.
40 virtual void move(IState
* state
, const Move
& m
) const = 0;
43 * Set next turn as the current turn.
45 virtual void advanceTurn(IState
* state
) const = 0;
48 * @return The square where a given move would capture if executed.
50 virtual Point
captureSquare(const IState
* state
, const Move
& m
) const = 0;
53 * @return The opponent of @a color.
55 virtual const IColor
* opponent(const IColor
* player
) const = 0;
58 * Players can have associated directions. For example, in chess,
59 * white pieces move towards the 8th rank.
60 * Associated directions are often used during move validation.
61 * @return Direction associated with @a player.
63 virtual Point
direction(const IColor
* player
) const = 0;
65 virtual void setDelegator(IBehaviour
* behaviour
) = 0;
68 #endif // CORE__BEHAVIOUR_H