3 #include <core/behaviour.h>
4 #include <core/promotionmanager.h>
5 #include <core/state.h>
12 bool Type::canMove(const Piece
& piece
, const Piece
& target
,
13 Move
& move
, const IState
* state
) const {
14 bool valid
= DefaultType::canMove(piece
, target
, move
, state
);
18 IBehaviour
* behaviour
= const_cast<IBehaviour
*>(state
->behaviour());
21 Q_ASSERT(QMetaObject::invokeMethod(behaviour
, "mayPromote",
22 Q_RETURN_ARG(bool, may_promote
),
23 Q_ARG(const IState
*, state
),
24 Q_ARG(const Move
, move
))); // FIXME: Move& ?
26 move
.setType("promotion");
27 const PromotionManager
* pm
;
28 Q_ASSERT(QMetaObject::invokeMethod(behaviour
, "promotionManager",
29 Q_RETURN_ARG(const PromotionManager
*, pm
)));
30 const IType
* newtype
= pm
->getPromotion(piece
.type());
31 kDebug() << "promoting to" << newtype
->name();
32 move
.setPromotion(newtype
);