refresh bdc45694d411cad215e68161e75bb9f1a8a39e47
[tagua/yd.git] / src / variants / shogi / faces / pawn.cpp
blob55e9f428e0b28a7a4152c54fbe0cdbf1c2b7b6f2
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include "pawn.h"
12 #include <core/behaviour.h>
13 #include <core/move.h>
14 #include <core/pathinfo.h>
15 #include <core/state.h>
16 #include <core/board.h>
17 #include <core/taguacast.h>
19 namespace Shogi {
20 namespace Faces {
22 Pawn::Pawn() { }
24 QString Pawn::name() const { return "pawn"; }
26 bool Pawn::canMove(const Piece& piece, const Piece&,
27 Move& move, const IState* state) const {
28 const IBehaviour* behaviour = state->behaviour();
29 if (!behaviour) return false;
31 return move.delta() == behaviour->direction(piece.color());
34 int Pawn::index() const { return 10; }
36 Pawn* Pawn::self() {
37 static Pawn s_instance;
38 return &s_instance;