Browse Source

moddable amount for mines

Laserlicht 3 weeks ago
parent
commit
21bc568e59

+ 1 - 0
client/lobby/OptionsTab.cpp

@@ -820,6 +820,7 @@ OptionsTab::HandicapWindow::HandicapWindow()
 		INCOME = 1000,
 		GROWTH = 2000,
 	};
+	// TODO: configurable resources
 	auto columns = std::vector<int>{EGameResID::GOLD, EGameResID::WOOD, EGameResID::MERCURY, EGameResID::ORE, EGameResID::SULFUR, EGameResID::CRYSTAL, EGameResID::GEMS, Columns::INCOME, Columns::GROWTH};
 
 	int i = 0;

+ 14 - 7
config/objects/moddables.json

@@ -287,7 +287,8 @@
 				"sounds" : {
 					"ambient" : ["LOOPLUMB"]
 				},
-				"resource" : "wood"
+				"resource" : "wood",
+				"defaultQuantity": 2
 			},
 			"alchemistLab" : {
 				"index" : 1,
@@ -298,7 +299,8 @@
 				"sounds" : {
 					"ambient" : ["LOOPSTAR"]
 				},
-				"resource" : "mercury"
+				"resource" : "mercury",
+				"defaultQuantity": 1
 			},
 			"orePit" : {
 				"index" : 2,
@@ -309,7 +311,8 @@
 				"sounds" : {
 					"ambient" : ["LOOPSULF"]
 				},
-				"resource" : "ore"
+				"resource" : "ore",
+				"defaultQuantity": 2
 			},
 			"sulfurDune" : {
 				"index" : 3,
@@ -320,7 +323,8 @@
 				"sounds" : {
 					"ambient" : ["LOOPSULF"]
 				},
-				"resource" : "sulfur"
+				"resource" : "sulfur",
+				"defaultQuantity": 1
 			},
 			"crystalCavern" : {
 				"index" : 4,
@@ -332,7 +336,8 @@
 					"ambient" : ["LOOPCRYS"]
 				},
 				"battleground": "subterranean",
-				"resource" : "crystal"
+				"resource" : "crystal",
+				"defaultQuantity": 1
 			},
 			"gemPond" : {
 				"index" : 5,
@@ -343,7 +348,8 @@
 				"sounds" : {
 					"ambient" : ["LOOPGEMP"]
 				},
-				"resource" : "gems"
+				"resource" : "gems",
+				"defaultQuantity": 1
 			},
 			"goldMine" : {
 				"index" : 6,
@@ -355,7 +361,8 @@
 					"ambient" : ["LOOPMINE"]
 				},
 				"battleground": "subterranean",
-				"resource" : "gold"
+				"resource" : "gold",
+				"defaultQuantity": 1000
 			},
 			"abandoned" :	{
 				"index" : 7,

+ 6 - 0
lib/mapObjectConstructors/CommonConstructors.cpp

@@ -100,6 +100,7 @@ void MineInstanceConstructor::initTypeData(const JsonNode & input)
 	{
 		resourceType = GameResID(index);
 	});
+	defaultQuantity = !config["defaultQuantity"].isNull() ? config["defaultQuantity"].Integer() : 1;
 
 	if (!config["name"].isNull())
 		LIBRARY->generaltexth->registerString(config.getModScope(), getNameTextID(), config["name"]);
@@ -113,6 +114,11 @@ GameResID MineInstanceConstructor::getResourceType() const
 	return resourceType;
 }
 
+ui32 MineInstanceConstructor::getDefaultQuantity() const
+{
+	return defaultQuantity;
+}
+
 std::string MineInstanceConstructor::getDescriptionTextID() const
 {
 	return TextIdentifier(getBaseTextID(), "description").get();

+ 2 - 0
lib/mapObjectConstructors/CommonConstructors.h

@@ -66,10 +66,12 @@ class DLL_LINKAGE MineInstanceConstructor : public CDefaultObjectTypeHandler<CGM
 {
 	JsonNode config;
 	GameResID resourceType;
+	ui32 defaultQuantity;
 public:
 	void initTypeData(const JsonNode & input) override;
 
 	GameResID getResourceType() const;
+	ui32 getDefaultQuantity() const;
 	std::string getDescriptionTextID() const;
 	std::string getDescriptionTranslated() const;
 };

+ 1 - 10
lib/mapObjects/MiscObjects.cpp

@@ -209,16 +209,7 @@ void CGMine::flagMine(IGameEventCallback & gameEvents, const PlayerColor & playe
 
 ui32 CGMine::defaultResProduction() const
 {
-	switch(producedResource.toEnum())
-	{
-	case EGameResID::WOOD:
-	case EGameResID::ORE:
-		return 2;
-	case EGameResID::GOLD:
-		return 1000;
-	default:
-		return 1;
-	}
+	return getResourceHandler()->getDefaultQuantity();
 }
 
 ui32 CGMine::getProducedQuantity() const