2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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.
14 #ifndef GAMEBASEDRULES_H
15 #define GAMEBASEDRULES_H
22 #include "turnpolicy.h"
26 class UserEntity
: public Entity
29 TurnPolicy::Collection m_turn_test
;
32 UserEntity(const GamePtr
& game
);
33 virtual TurnPolicy::Collection
& turnTest() { return m_turn_test
; }
34 virtual void enableEditingTools(bool value
);
37 * Return a PGN for the game.
39 virtual QString
save() const = 0;
42 * Load the content of a PGN inside the game.
44 virtual void loadPGN(const PGN
& pgn
) = 0;
46 virtual NormalUserMove
createMove(const Point
& from
, const Point
& to
) const;
47 virtual DropUserMove
createDrop(int pool
, int index
, const Point
& to
) const;
49 virtual AbstractMove::Ptr
testMove(const NormalUserMove
& m
) const = 0;
50 virtual AbstractMove::Ptr
testMove(const DropUserMove
& m
) const = 0;
52 virtual bool testPremove(const NormalUserMove
& m
) const = 0;
53 virtual bool testPremove(const DropUserMove
&) const = 0;
55 virtual void executeMove(AbstractMove::Ptr move
) = 0;
56 virtual void addPremove(const NormalUserMove
& m
) = 0;
57 virtual void addPremove(const DropUserMove
& m
) = 0;
58 virtual void cancelPremove() = 0;
59 virtual void handleRightClick(const Point
&) const;
61 virtual InteractionType
validTurn(const Point
&) const = 0;
62 virtual InteractionType
validTurn(int) const = 0;
63 virtual bool movable(const Point
&) const = 0;
64 virtual bool oneClickMoves() const { return false; }
67 * Jump to the end of the game.
69 virtual bool gotoFirst() = 0;
72 * Jump to the beginning of the game.
74 virtual bool gotoLast() = 0;
77 * Jump to an arbitrary index.
79 virtual bool goTo(const Index
& index
) = 0;
82 * Go forward one move in the game.
84 virtual bool forward() = 0;
87 * Go back one move in the game.
89 virtual bool back() = 0;
92 * Undo the last editing action.
94 virtual bool undo() = 0;
97 * Redo the last editing action.
99 virtual bool redo() = 0;
102 * Remove the current position.
104 virtual bool truncate() = 0;
107 * Promote the current variation to mainline.
109 virtual bool promoteVariation() = 0;
113 * @sa AbstractPosition::moveHint
115 virtual AbstractPiece::Ptr
moveHint(AbstractMove::Ptr
) const { return AbstractPiece::Ptr(); }
117 virtual bool canDetach() const;
121 #endif // GAMEBASEDRULES_H
124 #endif // USERENTITY_H