Change Board::get() to return a pointer.
[tagua/yd.git] / src / core / defaultpolicy.cpp
blobc40b2d0d316939c7539ace2b66063c5c79af6906
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 const Piece* piece = state->board()->get(p);
19 if (piece == NULL || *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;