File: autohostmanager.h

package info (click to toggle)
springlobby 0.267%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,780 kB
  • sloc: cpp: 79,169; ansic: 61,599; python: 927; sh: 735; perl: 238; xml: 52; makefile: 42; sed: 16
file content (103 lines) | stat: -rw-r--r-- 2,124 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* This file is part of the Springlobby (GPL v2 or later), see COPYING */

#ifndef AUTOHOSTMANAGER_H
#define AUTOHOSTMANAGER_H

#include <string>
class IBattle;


class AutohostHandler
{
public:
	AutohostHandler();
	virtual ~AutohostHandler();

	virtual void Balance(){};
	virtual void SetRandomMap(){};
	virtual void SetMap(const std::string& /*map*/){};
	virtual void ClearStartBoxes(){};
	virtual void AddStartBox(int /*posx*/, int /*posy*/, int /*w*/, int /*h*/){};
	virtual void Notify(){};
	virtual void Promote(){};
	virtual void Ring(){};
	virtual void Start(){};
	void SetBattle(IBattle* battle);

protected:
	virtual void Send(const std::string& /*cmd*/);
	virtual void SayFounder(const std::string& /*cmd*/);

private:
	IBattle* m_battle;


	friend class AutohostManager;
};

class SpringieHandler : public AutohostHandler
{
public:
	SpringieHandler();
	~SpringieHandler();

	void Balance() override;
	void SetRandomMap() override;
	void SetMap(const std::string& map) override;
	void ClearStartBoxes() override;
	void AddStartBox(int posx, int posy, int w, int h) override;
	void Notify() override;
	void Promote() override;
	void Ring() override;
	void Start() override;
};

class SpadsHandler : virtual public AutohostHandler
{
public:
	SpadsHandler();
	~SpadsHandler();

	void Balance() override;
	void SetRandomMap() override;
	void SetMap(const std::string& map) override;
	void ClearStartBoxes() override;
	void AddStartBox(int posx, int posy, int w, int h) override;
	void Notify() override;
	void Promote() override;
	void Ring() override;
	void Start() override;
};

class AutohostManager
{
public:
	enum AutohostType {
		AUTOHOSTTYPE_NONE,
		AUTOHOSTTYPE_UNKNOWN,
		AUTOHOSTTYPE_SPRINGIE,
		AUTOHOSTTYPE_SPADS
	};

	AutohostManager();
	~AutohostManager();

	void SetBattle(IBattle* bt);
	bool RecognizeAutohost(const std::string& type);

	AutohostType GetAutohostType();

	AutohostHandler& GetAutohostHandler();

private:
	void Configure();

	SpringieHandler m_springie;
	SpadsHandler m_spads;
	AutohostHandler m_emptyhandler;

	AutohostType m_type;
	IBattle* m_battle;
};

#endif // AUTOHOSTMANAGER_H