Ported shogi.
[tagua/yd.git] / src / hlvariant / crazyhouse / move.h
blobf7a130a6535f8a3fc3d3ab296fde97767aaaaec2
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@sns.it>
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 #ifndef HLVARIANT__CRAZYHOUSE__MOVE_H
12 #define HLVARIANT__CRAZYHOUSE__MOVE_H
14 #include "point.h"
16 namespace HLVariant {
17 namespace Crazyhouse {
19 template <typename _Move, typename _Piece>
20 class MoveMixin : public _Move {
21 public:
22 typedef _Move Move;
23 typedef _Piece Piece;
24 private:
25 typedef typename Piece::Color Color;
27 Color m_pool;
28 int m_index;
29 Piece m_drop;
30 public:
31 MoveMixin();
32 MoveMixin(const Point& from, const Point& to, int promotionType = -1);
33 MoveMixin(Color pool, int index, const Point& to);
35 Piece drop() const;
36 void setDrop(const Piece& piece);
38 Color pool() const;
39 int index() const;
42 // IMPLEMENTATION
44 template <typename Move, typename Piece>
45 MoveMixin<Move, Piece>::MoveMixin()
46 : m_pool(Piece::INVALID_COLOR)
47 , m_index(-1) { }
49 template <typename Move, typename Piece>
50 MoveMixin<Move, Piece>::MoveMixin(const Point& from, const Point& to, int promotionType)
51 : Move(from, to, promotionType)
52 , m_pool(Piece::INVALID_COLOR)
53 , m_index(-1) { }
55 template <typename Move, typename Piece>
56 MoveMixin<Move, Piece>::MoveMixin(Color pool, int index, const Point& to)
57 : Move(Point::invalid(), to)
58 , m_pool(pool)
59 , m_index(index) { }
61 template <typename Move, typename Piece>
62 Piece MoveMixin<Move, Piece>::drop() const {
63 return m_drop;
66 template <typename Move, typename Piece>
67 void MoveMixin<Move, Piece>::setDrop(const Piece& drop) {
68 m_drop = drop;
71 template <typename Move, typename Piece>
72 typename Piece::Color MoveMixin<Move, Piece>::pool() const {
73 return m_pool;
76 template <typename Move, typename Piece>
77 int MoveMixin<Move, Piece>::index() const {
78 return m_index;
81 }; // namespace Crazyhouse
82 }; // namespace HLVariant
84 #endif // HLVARIANT__CRAZYHOUSE__MOVE_H