new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / src / variants / chess / knight.cpp
blob67bcc8fb60ca38acbcd8ff1399b315ef92c7b864
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 "knight.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 Knight::Knight() { }
21 QString Knight::name() const { return "knight"; }
23 bool Knight::canMove(const Piece&, const Piece&,
24 Move& move, const IState*) const {
25 return (abs(move.delta().x) == 1 && abs(move.delta().y) == 2) ||
26 (abs(move.delta().y) == 1 && abs(move.delta().x) == 2);
29 int Knight::index() const { return 30; }
31 Knight* Knight::self() {
32 static Knight s_instance;
33 return &s_instance;