Implemented variant actions.
[tagua/yd.git] / src / controllers / editgame.h
blob836fe69b8a15855860bf7028fa3f7fc186f4853b
1 /*
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.
9 */
11 #ifndef EDITGAMECONTROLLER_H
12 #define EDITGAMECONTROLLER_H
14 #include <set>
15 #include "abstract.h"
16 #include "agentgroup.h"
17 #include "tagua.h"
19 class Entity;
20 class Engine;
21 class Agent;
22 class ICSConnection;
23 class UserEntity;
24 class GraphicalGame;
25 class GraphicalSystem;
28 /**
29 * @brief A controller to edit or play games.
31 * EditGameController is used to play games, either locally or
32 * on an ICS server. A pair of entities @code m_players, representing
33 * the two players, is mantained as well as a set of additional entities,
34 * @code m_entities.
35 * If an entity needs to be notified about how the game progresses, one
36 * should register it as an agent, adding it to @code m_agents.
38 class EditGameController : public Controller {
39 void init(AbstractPosition::Ptr);
40 boost::shared_ptr<Agent> m_clock_agent;
41 boost::shared_ptr<Agent> m_update_agent;
42 protected:
43 virtual void onNavigation();
45 boost::shared_ptr<UserEntity> m_entity;
46 boost::shared_ptr<GraphicalSystem> m_graphical;
47 AgentGroup m_agents;
48 VariantPtr m_variant;
49 boost::shared_ptr<GraphicalGame> m_game;
50 virtual boost::shared_ptr<UserEntity> entity() const { return m_entity; }
51 boost::shared_ptr<Entity> m_players[2];
52 std::set<boost::shared_ptr<Entity> > m_entities;
53 public:
54 EditGameController(ChessTable*, const VariantPtr& variant,
55 AbstractPosition::Ptr startingPos = AbstractPosition::Ptr());
56 ~EditGameController();
57 virtual void setPromotionType(int);
59 virtual QString variant() const;
60 EntityToken addPlayingEngine(int side, const boost::shared_ptr<Engine>& engine);
61 // EntityToken addAnalysingEngine(const boost::shared_ptr<Engine>& engine);
62 void removeEntity(const EntityToken& token);
63 bool addICSPlayer(int side, int game_number, const boost::shared_ptr<ICSConnection>& connection);
64 bool setExaminationMode(int game_number, const boost::shared_ptr<ICSConnection>& connection);
65 bool setObserveMode(int game_number, const boost::shared_ptr<ICSConnection>& connection);
67 virtual void loadPGN(const PGN&);
69 virtual void createCtrlAction();
70 virtual void destroyCtrlAction();
72 virtual boost::shared_ptr<Controller> end();
73 virtual void detach();
77 #endif