new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / src / variants / chess / rook.cpp
blob1f98bb11dae5137639cf98bdeda220b2e802d25f
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 "rook.h"
12 #include <core/move.h>
13 #include <core/pathinfo.h>
14 #include <core/state.h>
15 #include <core/board.h>
17 namespace Chess {
19 Rook::Rook() { }
21 QString Rook::name() const { return "rook"; }
23 bool Rook::canMove(const Piece& piece, const Piece& target,
24 Move& move, const IState* state) const {
25 PathInfo path = state->board()->path(move.src(), move.dst());
26 return path.parallel() && path.clear() && target.color() != piece.color();
29 int Rook::index() const { return 50; }
31 Rook* Rook::self() {
32 static Rook s_instance;
33 return &s_instance;