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 #include "behaviour.h"
12 #include <core/board.h>
13 #include <core/piece.h>
14 #include <core/poolcollection.h>
15 #include <core/pool.h>
16 #include <core/state.h>
20 Behaviour::Behaviour(const IBehaviour
* behaviour
)
21 : Delegators::Behaviour(behaviour
) { }
23 void Behaviour::captureOn(IState
* state
, const Point
& square
) const {
24 Piece
* captured
= state
->board()->get(square
);
25 if (captured
!= NULL
&& *captured
!= Piece()) {
26 if (captured
->get("promoted").toBool()) {
28 // FIXME: generalize this, and use Crazyhouse::Behaviour instead ?
29 //captured->setType(pawn);
31 state
->pools()->pool(opponent(captured
->color()))->insert(-1, *captured
);
33 m_behaviour
->captureOn(state
, square
);