refresh bdc45694d411cad215e68161e75bb9f1a8a39e47
[tagua/yd.git] / src / variants / shogi / faces / silver.cpp
blobd12d500772f1b9d97179828cdb3126871891a469
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 "silver.h"
12 #include <core/behaviour.h>
13 #include <core/move.h>
14 #include <core/state.h>
16 namespace Shogi {
17 namespace Faces {
19 Silver::Silver() { }
21 QString Silver::name() const { return "silver"; }
23 bool Silver::canMove(const Piece& piece, const Piece&,
24 Move& move, const IState* state) const {
25 const IBehaviour* behaviour = state->behaviour();
26 if (!behaviour) return false;
27 return (abs(move.delta().x) == abs(move.delta().y) && abs(move.delta().x) == 1)
28 || (move.delta().y == behaviour->direction(piece.color()).y && abs(move.delta().x) <= 1);
31 int Silver::index() const { return 50; }
33 Silver* Silver::self() {
34 static Silver s_instance;
35 return &s_instance;