1 //       _________ __                 __
2 //      /   _____//  |_____________ _/  |______     ____  __ __  ______
3 //      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
4 //      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ |
5 //     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
6 //             \/                  \/          \//_____/            \/
7 //  ______________________                           ______________________
8 //                        T H E   W A R   B E G I N S
9 //         Stratagus - A free fantasy real time strategy game engine
10 //
11 /**@name resource.h - The resource header file. */
12 //
13 //      (c) Copyright 1999-2019 by Vladi Belperchinov-Shabanski,
14 //		Jimmy Salmon and Andrettin
15 //
16 //      This program is free software; you can redistribute it and/or modify
17 //      it under the terms of the GNU General Public License as published by
18 //      the Free Software Foundation; only version 2 of the License.
19 //
20 //      This program is distributed in the hope that it will be useful,
21 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
22 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 //      GNU General Public License for more details.
24 //
25 //      You should have received a copy of the GNU General Public License
26 //      along with this program; if not, write to the Free Software
27 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 //      02111-1307, USA.
29 //
30 
31 #ifndef __RESOURCE_H__
32 #define __RESOURCE_H__
33 
34 /*----------------------------------------------------------------------------
35 --  Includes
36 ----------------------------------------------------------------------------*/
37 
38 #include "data_type.h"
39 
40 #include <map>
41 #include <string>
42 #include <vector>
43 
44 /*----------------------------------------------------------------------------
45 --  Declarations
46 ----------------------------------------------------------------------------*/
47 
48 struct lua_State;
49 
50 /**
51 **  Indices into costs/resource/income array.
52 */
53 enum CostType {
54 	TimeCost,                               /// time in game cycles
55 
56 	// standard
57 	CopperCost,                             /// copper resource
58 	WoodCost,                               /// wood  resource
59 	OilCost,                                /// oil   resource
60 	// extensions
61 	IronCost,								/// iron resource
62 	StoneCost,								/// stone resource
63 	CoalCost,								/// coal resource
64 
65 	ResearchCost,							/// research resource
66 	PrestigeCost,							/// prestige resource
67 	GoldCost,                               /// gold resource
68 	SilverCost,								/// silver resource
69 	MithrilCost,							/// mithril resource
70 	LimestoneCost,							/// limestone resource
71 	JewelryCost,							/// jewelry resource
72 	FurnitureCost,							/// furniture resource
73 	LeatherCost,							/// leather resource
74 	DiamondsCost,							/// diamonds resource
75 	EmeraldsCost,							/// emeralds resource
76 	LeadershipCost,							/// leadership resource
77 	TradeCost,								/// trade resource, generated by trader units (converted to copper when delivered)
78 
79 	MaxCosts                                /// how many different costs
80 };
81 
82 #define FoodCost MaxCosts
83 #define ScoreCost (MaxCosts + 1)
84 #define ManaResCost (MaxCosts + 2)
85 #define FreeWorkersCount (MaxCosts + 3)
86 
87 class CResource : public CDataType
88 {
89 public:
90 	static CResource *GetResource(const std::string &ident, const bool should_find = true);
91 	static CResource *GetOrAddResource(const std::string &ident);
92 	static void ClearResources();
93 
94 	static std::vector<CResource *> Resources;
95 	static std::map<std::string, CResource *> ResourcesByIdent;
96 
97 	virtual void ProcessConfigData(const CConfigData *config_data) override;
98 	bool IsMineResource() const;
99 
100 	std::string Name;
101 	std::string ActionName;
102 	int ID = -1;
103 	int DefaultIncome = 100;
104 	int DefaultAmount = 1000;
105 	int DefaultMaxAmount = -1;
106 	int FinalResource = -1;
107 	int FinalResourceConversionRate = 100;
108 	int BasePrice = 0;
109 	int DemandElasticity = 100;
110 	int InputResource = 0;
111 	bool LuxuryResource = false;
112 	bool Hidden = false;
113 	std::vector<CResource *> ChildResources; //resources (other than this one) that have this resource as their final resource
114 };
115 
116 /**
117 **  Default resources for a new player.
118 */
119 extern int DefaultResources[MaxCosts];
120 
121 /**
122 **  Default resources for a new player with low resources.
123 */
124 extern int DefaultResourcesLow[MaxCosts];
125 
126 /**
127 **  Default resources for a new player with mid resources.
128 */
129 extern int DefaultResourcesMedium[MaxCosts];
130 
131 /**
132 **  Default resources for a new player with high resources.
133 */
134 extern int DefaultResourcesHigh[MaxCosts];
135 
136 /**
137 **  Default names for the resources.
138 */
139 extern std::string DefaultResourceNames[MaxCosts];
140 
141 extern std::vector<int> LuxuryResources;
142 
143 extern int GetResourceIdByName(const char *resourceName);
144 extern int GetResourceIdByName(lua_State *l, const char *resourceName);
145 extern std::string GetResourceNameById(int resource_id);
146 
147 #endif
148