1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-08 23:22:25 +02:00

moddable amount for mines

This commit is contained in:
Laserlicht
2025-09-29 02:00:04 +02:00
parent c9d866aed8
commit 21bc568e59
5 changed files with 24 additions and 17 deletions

View File

@@ -820,6 +820,7 @@ OptionsTab::HandicapWindow::HandicapWindow()
INCOME = 1000, INCOME = 1000,
GROWTH = 2000, 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}; 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; int i = 0;

View File

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

View File

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

View File

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

View File

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