new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / src / entities / userentity.h
blob1d81ea0b426f1218d18a9d5279d4629c6dec081f
1 /*
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.
9 */
11 #ifndef USERENTITY_H
12 #define USERENTITY_H
14 #ifndef GAMEBASEDRULES_H
15 #define GAMEBASEDRULES_H
17 #include <core/interactiontype.h>
18 #include <core/move.h>
19 #include <core/piece.h>
20 #include <core/turnpolicy.h>
22 #include "entity.h"
23 #include "agent.h"
25 class PGN;
27 class UserEntity : public Entity
28 , public Agent {
29 protected:
30 TurnPolicy::Collection m_turn_test;
31 bool m_editing_tools;
32 public:
33 UserEntity(const GamePtr& game);
34 virtual TurnPolicy::Collection& turnTest() { return m_turn_test; }
35 virtual void enableEditingTools(bool value);
37 /**
38 * Return a PGN for the game.
40 virtual QString save() const = 0;
42 /**
43 * Load the content of a PGN inside the game.
45 virtual void loadPGN(const PGN& pgn) = 0;
47 virtual bool testMove(Move& m) const = 0;
49 virtual bool testPremove(const Move& m) const = 0;
50 virtual void executeMove(const Move& move) = 0;
51 virtual void addPremove(const Move& m) = 0;
52 virtual void cancelPremove() = 0;
53 virtual void handleRightClick(const Point&) const;
55 virtual InteractionType validTurn(const Point&) const = 0;
56 virtual InteractionType validTurn(const IColor*) const = 0;
57 virtual bool movable(const Point&) const = 0;
58 virtual bool oneClickMoves() const { return false; }
60 /**
61 * Jump to the end of the game.
63 virtual bool gotoFirst() = 0;
65 /**
66 * Jump to the beginning of the game.
68 virtual bool gotoLast() = 0;
70 /**
71 * Jump to an arbitrary index.
73 virtual bool goTo(const Index& index) = 0;
75 /**
76 * Go forward one move in the game.
78 virtual bool forward() = 0;
80 /**
81 * Go back one move in the game.
83 virtual bool back() = 0;
85 /**
86 * Undo the last editing action.
88 virtual bool undo() = 0;
90 /**
91 * Redo the last editing action.
93 virtual bool redo() = 0;
95 /**
96 * Remove the current position.
98 virtual bool truncate() = 0;
101 * Promote the current variation to mainline.
103 virtual bool promoteVariation() = 0;
106 * Move hint.
108 virtual Piece moveHint(const Move&) const { return Piece(); }
110 virtual bool canDetach() const;
114 #endif // GAMEBASEDRULES_H
117 #endif // USERENTITY_H