Initial porting to the new component API.
[tagua/yd.git] / src / core / defaultpolicy.cpp
bloba57e8352ffda4138de638d3383ae2044378f445b
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 #include "defaultpolicy.h"
11 #include "board.h"
12 #include "piece.h"
13 #include "state.h"
15 InteractionType DefaultPolicy::movable(const IState* state,
16 const TurnTest& test,
17 const Point& p) const {
18 Piece piece = state->board()->get(p);
19 if (piece == Piece() || !test(piece.color()))
20 return NoAction;
22 return piece.color() == state->turn() ? Moving : Premoving;
25 InteractionType DefaultPolicy::droppable(const IState* state,
26 const TurnTest& test,
27 const IColor* pool) const {
28 if (!test(pool))
29 return NoAction;
31 return pool == state->turn() ? Moving : Premoving;