2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 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.
11 #include "variants/progressive.h"
13 #include "variants/chess.h"
14 #include "variants/xchess/position.h"
15 #include "moveserializer.impl.h"
16 #include "xchess/animator.impl.h"
17 #include "highlevel.h"
19 class ProgressivePosition : public ChessPosition {
23 ProgressivePosition();
24 ProgressivePosition(const OptList& l);
25 ProgressivePosition(const ChessPosition&);
26 ProgressivePosition(Piece::Color turn, bool wk, bool wq,
27 bool bk, bool bq, const Point& ep);
28 virtual ProgressivePosition* clone() const { return new ProgressivePosition(*this); }
30 virtual void switchTurn() {
33 if(m_move_ordinal >= m_progression || check(Piece::oppositeColor(turn()))) {
36 ChessPosition::switchTurn();
40 virtual void setTurn(Piece::Color turn) {
41 ChessPosition::setTurn(turn);
47 ProgressivePosition::ProgressivePosition()
49 , m_move_ordinal(0) { }
50 ProgressivePosition::ProgressivePosition(const OptList& /*l*/)
52 , m_move_ordinal(0) { }
53 ProgressivePosition::ProgressivePosition(const ChessPosition& other)
54 : ChessPosition(other)
56 , m_move_ordinal(0) { }
57 ProgressivePosition::ProgressivePosition(Piece::Color turn, bool wk, bool wq,
58 bool bk, bool bq, const Point& ep)
59 : ChessPosition(turn, wk, wq, bk, bq, ep)
61 , m_move_ordinal(0) { }
63 class ProgressiveVariantInfo {
65 typedef ProgressivePosition Position;
66 typedef Position::Piece Piece;
67 typedef Position::Move Move;
68 typedef SimpleAnimator<ProgressiveVariantInfo> Animator;
69 static const bool m_simple_moves = false;
70 static void forallPieces(PieceFunction& f);
71 static int moveListLayout(){ return 4; }
72 static const char *m_name;
73 static const char *m_theme_proxy;
74 static OptList positionOptions() { return OptList(); }
77 const char *ProgressiveVariantInfo::m_name = "Progressive";
78 const char *ProgressiveVariantInfo::m_theme_proxy = "Chess";
80 void ProgressiveVariantInfo::forallPieces(PieceFunction& f) {
81 ChessVariant::forallPieces(f);
84 VariantInfo* ProgressiveVariant::static_variant_info = 0;
86 VariantInfo* ProgressiveVariant::info() {
87 if (!static_variant_info)
88 static_variant_info = new WrappedVariantInfo<ProgressiveVariantInfo>;
89 return static_variant_info;