889b4f2100e0ab1f74db9844e910f68184dd6b27
[tagua/yd.git] / src / core / defaulttype.cpp
blob889b4f2100e0ab1f74db9844e910f68184dd6b27
1 #include "defaultstate.h"
2 #include "defaulttype.h"
3 #include "move.h"
5 #include <KDebug>
7 bool DefaultType::canMove(const Piece& piece, const Piece&,
8 Move& move, const IState* state) const {
9 const DefaultState* dstate = dynamic_cast<const DefaultState*>(state);
10 if (dstate == NULL) {
11 kDebug() << "use of a non-DefaultState-derived state with DefaultType";
12 return false;
14 std::vector<const Point*> moves = dstate->theoreticalMoves(piece, move.src());
15 std::vector<const Point*>::const_iterator it;
16 for (it = moves.begin(); it != moves.end(); it++) {
17 if (move.dst() == **it)
18 return true;
19 delete *it;
22 // delete remaining points in the vector
23 for (; it != moves.end(); it++)
24 delete *it;
26 return false;