2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #ifndef HLVARIANT__DUMMY__LEGALITYCHECK_H
12 #define HLVARIANT__DUMMY__LEGALITYCHECK_H
14 #include "../chess/legalitycheck.h"
15 #include "interactiontype.h"
16 #include "turnpolicy.h"
21 template <typename _GameState
>
24 typedef _GameState GameState
;
26 typedef typename
GameState::Board Board
;
27 typedef typename
GameState::Move Move
;
28 typedef typename
Board::Piece Piece
;
30 const GameState
& m_state
;
32 LegalityCheck(const GameState
&);
33 virtual ~LegalityCheck();
35 virtual bool legal(Move
&) const;
36 virtual InteractionType
movable(const TurnTest
&, const Point
&);
37 virtual InteractionType
droppable(const TurnTest
&, int);
42 template <typename GameState
>
43 LegalityCheck
<GameState
>::LegalityCheck(const GameState
& state
)
46 template <typename GameState
>
47 LegalityCheck
<GameState
>::~LegalityCheck() { }
49 template <typename GameState
>
50 bool LegalityCheck
<GameState
>::legal(Move
& move
) const {
51 if (move
.drop() == Piece() &&
54 move
.setDrop(m_state
.pools().pool(move
.pool()).get(move
.index()));
60 template <typename GameState
>
61 InteractionType LegalityCheck
<GameState
>::movable(const TurnTest
& test
, const Point
& p
) {
62 Piece piece
= m_state
.board().get(p
);
63 return piece
!= Piece() && test(piece
.color()) ? Moving
: NoAction
;
66 template <typename GameState
>
67 InteractionType LegalityCheck
<GameState
>::droppable(const TurnTest
& test
, int index
) {
68 return test(index
) ? Moving
: NoAction
;
73 } // namespace HLVariant
76 #endif // HLVARIANT__DUMMY__LEGALITYCHECK_H