new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / src / variants / chess / castlingrules.h
blobf35f062d8fb4beddeadb182e181c07efa3708987
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 CHESS__CASTLINGRULES_H
11 #define CHESS__CASTLINGRULES_H
13 #include <core/component.h>
14 #include <core/point.h>
16 class IColor;
17 class IState;
18 class Move;
19 class Piece;
21 namespace Chess {
23 class ICastlingRules {
24 public:
25 virtual ~ICastlingRules();
27 virtual bool canCastle(const Piece& piece, Move& move, const IState* state) const = 0;
28 virtual bool handleCastling(const Piece& piece, const Move& move, IState* state) const = 0;
29 virtual void setDelegator(Component* rules) = 0;
30 virtual Point kingStartingPosition(const IState* state, const IColor* player) const = 0;
33 class CastlingRules : public Component, public ICastlingRules {
34 Q_OBJECT
35 ICastlingRules* m_delegator;
36 public:
37 CastlingRules();
39 virtual bool canCastle(const Piece& piece, Move& move, const IState* state) const;
40 virtual bool handleCastling(const Piece& piece, const Move& move, IState* state) const;
41 virtual void setDelegator(Component* rules);
42 virtual Point kingStartingPosition(const IState* state, const IColor* player) const;
45 class CastlingRulesAdaptor : public ICastlingRules {
46 Component* m_component;
47 bool m_own;
48 public:
49 CastlingRulesAdaptor(Component* component, bool own = true);
50 virtual ~CastlingRulesAdaptor();
52 virtual bool canCastle(const Piece& piece, Move& move, const IState* state) const;
53 virtual bool handleCastling(const Piece& piece, const Move& move, IState* state) const;
54 virtual void setDelegator(Component* rules);
55 virtual Point kingStartingPosition(const IState* state, const IColor* player) const;
59 } // namespace Chess
61 #endif // CHESS__CASTLINGRULES_H