3 #include "defaultstate.h"
4 #include "defaulttype.h"
6 std::vector
<const Point
*> DefaultState::theoreticalMoves(const Piece
& piece
,
7 const Point
& src
) const {
8 std::vector
<const Point
*> destinations
;
10 const IBehaviour
* behaviour
= this->behaviour();
11 if (!behaviour
) return destinations
; // empty
13 const std::vector
<MoveDefinition
> * defs
=
14 dynamic_cast<const DefaultType
*>(piece
.type())->movesDefinitions();
15 if (!defs
) return destinations
; // empty
17 //kDebug() << "looking at moves from " << src;
18 for (unsigned direction
=0; direction
< defs
->size(); direction
++)
20 (*defs
)[direction
].distance
? (distance
<= (*defs
)[direction
].distance
) : 1;
22 Point
* candidate
= new Point(src
.x
+ ((*defs
)[direction
].x
* distance
*
23 -behaviour
->direction(piece
.color()).y
),
24 src
.y
+ ((*defs
)[direction
].y
* distance
*
25 behaviour
->direction(piece
.color()).y
));
26 if (!board()->valid(*candidate
)) {
27 // end of board: don't look further in that direction
32 destinations
.push_back(candidate
);
34 // stop looking in direction if there is a piece blocking move here
35 const Piece otherPiece
= board()->get(*candidate
);
36 if (otherPiece
!= Piece())