Finalize support for delegating behaviours.
[tagua/yd.git] / src / core / behaviour.h
blob7438e74015f452f64cdd9558f2a4a8df6f46a0f8
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 "component.h"
14 #include "export.h"
15 #include "point.h"
17 class IColor;
18 class IState;
19 class Move;
21 /**
22 * @brief Encapsulates general rules on piece movement.
24 class TAGUA_EXPORT IBehaviour: public Component {
25 Q_OBJECT
26 public:
27 virtual ~IBehaviour();
29 /**
30 * Perform a capture on a given square. In variants with drops, this
31 * adds the captured piece to the opponent pool. In games like chess,
32 * this does nothing.
34 virtual void captureOn(IState* state, const Point& square) const = 0;
36 /**
37 * Set the moving piece in its destination square, without affecting
38 * the current turn or flags.
39 * This is a helper function normally called by move.
41 virtual void move(IState* state, const Move& m) const = 0;
43 /**
44 * Set next turn as the current turn.
46 virtual void advanceTurn(IState* state) const = 0;
48 /**
49 * @return The square where a given move would capture if executed.
51 virtual Point captureSquare(const IState* state, const Move& m) const = 0;
53 /**
54 * @return The opponent of @a color.
56 virtual const IColor* opponent(const IColor* player) const = 0;
58 /**
59 * Players can have associated directions. For example, in chess,
60 * white pieces move towards the 8th rank.
61 * Associated directions are often used during move validation.
62 * @return Direction associated with @a player.
64 virtual Point direction(const IColor* player) const = 0;
66 virtual void setDelegator(IBehaviour* behaviour) = 0;
69 #endif // CORE__BEHAVIOUR_H