File: CRmgTemplate.h

package info (click to toggle)
vcmi 0.99%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 10,264 kB
  • ctags: 16,826
  • sloc: cpp: 121,945; objc: 248; sh: 193; makefile: 28; python: 13; ansic: 9
file content (98 lines) | stat: -rw-r--r-- 2,651 bytes parent folder | download
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

/*
 * CRmgTemplate.h, part of VCMI engine
 *
 * Authors: listed in file AUTHORS in main folder
 *
 * License: GNU General Public License v2.0 or later
 * Full text of license available in license.txt file, in main folder
 *
 */

#pragma once

#include "../GameConstants.h"

class CRmgTemplateZone;

/// The CRmgTemplateZoneConnection describes the connection between two zones.
class DLL_LINKAGE CRmgTemplateZoneConnection
{
public:
	CRmgTemplateZoneConnection();

	CRmgTemplateZone * getZoneA() const;
	void setZoneA(CRmgTemplateZone * value);
	CRmgTemplateZone * getZoneB() const;
	void setZoneB(CRmgTemplateZone * value);
	int getGuardStrength() const; /// Default: 0
	void setGuardStrength(int value);

private:
	CRmgTemplateZone * zoneA, * zoneB;
	int guardStrength;
};

/// The CRmgTemplate describes a random map template.
class DLL_LINKAGE CRmgTemplate
{
public:
	class CSize
	{
	public:
		CSize();
		CSize(int width, int height, bool under);

		int getWidth() const; /// Default: CMapHeader::MAP_SIZE_MIDDLE
		void setWidth(int value);
		int getHeight() const; /// Default: CMapHeader::MAP_SIZE_MIDDLE
		void setHeight(int value);
		bool getUnder() const; /// Default: true
		void setUnder(bool value);
		bool operator<=(const CSize & value) const;
		bool operator>=(const CSize & value) const;

	private:
		int width, height;
		bool under;
	};

	class CPlayerCountRange
	{
	public:
		void addRange(int lower, int upper);
		void addNumber(int value);
		bool isInRange(int count) const;
		std::set<int> getNumbers() const;

	private:
		std::list<std::pair<int, int> > range;
	};

	CRmgTemplate();
	~CRmgTemplate();

	const std::string & getName() const;
	void setName(const std::string & value);
	const CSize & getMinSize() const;
	void setMinSize(const CSize & value);
	const CSize & getMaxSize() const;
	void setMaxSize(const CSize & value);
	const CPlayerCountRange & getPlayers() const;
	void setPlayers(const CPlayerCountRange & value);
	const CPlayerCountRange & getCpuPlayers() const;
	void setCpuPlayers(const CPlayerCountRange & value);
	const std::map<TRmgTemplateZoneId, CRmgTemplateZone *> & getZones() const;
	void setZones(const std::map<TRmgTemplateZoneId, CRmgTemplateZone *> & value);
	const std::list<CRmgTemplateZoneConnection> & getConnections() const;
	void setConnections(const std::list<CRmgTemplateZoneConnection> & value);

	void validate() const; /// Tests template on validity and throws exception on failure

private:
	std::string name;
	CSize minSize, maxSize;
	CPlayerCountRange players, cpuPlayers;
	std::map<TRmgTemplateZoneId, CRmgTemplateZone *> zones;
	std::list<CRmgTemplateZoneConnection> connections;
};