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 CHESS__CASTLINGRULES_H
11 #define CHESS__CASTLINGRULES_H
13 #include <core/component.h>
14 #include <core/point.h>
23 class ICastlingRules
{
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
{
35 ICastlingRules
* m_delegator
;
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
;
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;
61 #endif // CHESS__CASTLINGRULES_H