1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Ban Navigation on maps without water

This commit is contained in:
Tomasz Zieliński
2023-07-18 10:54:36 +02:00
parent 025b0814c8
commit 03b3771f19
5 changed files with 24 additions and 1 deletions

View File

@@ -164,7 +164,8 @@
"effects" : { "effects" : {
"main" : { "val" : 150 } "main" : { "val" : 150 }
} }
} },
"onlyOnWaterMap" : true
}, },
"leadership" : { "leadership" : {
"index" : 6, "index" : 6,

View File

@@ -199,6 +199,8 @@ CSkill * CSkillHandler::loadFromJson(const std::string & scope, const JsonNode &
auto * skill = new CSkill(SecondarySkill((si32)index), identifier, major, minor); auto * skill = new CSkill(SecondarySkill((si32)index), identifier, major, minor);
skill->modScope = scope; skill->modScope = scope;
skill->onlyOnWaterMap = json["onlyOnWaterMap"].Bool();
VLC->generaltexth->registerString(scope, skill->getNameTextID(), json["name"].String()); VLC->generaltexth->registerString(scope, skill->getNameTextID(), json["name"].String());
switch(json["gainChance"].getType()) switch(json["gainChance"].getType())
{ {

View File

@@ -80,6 +80,8 @@ public:
void updateFrom(const JsonNode & data); void updateFrom(const JsonNode & data);
void serializeJson(JsonSerializeFormat & handler); void serializeJson(JsonSerializeFormat & handler);
bool onlyOnWaterMap;
template <typename Handler> void serialize(Handler & h, const int version) template <typename Handler> void serialize(Handler & h, const int version)
{ {
h & id; h & id;
@@ -88,6 +90,7 @@ public:
h & levels; h & levels;
h & obligatoryMajor; h & obligatoryMajor;
h & obligatoryMinor; h & obligatoryMinor;
h & onlyOnWaterMap;
} }
friend class CSkillHandler; friend class CSkillHandler;

View File

@@ -585,6 +585,7 @@ void CMap::banWaterContent()
banWaterHeroes(); banWaterHeroes();
banWaterArtifacts(); banWaterArtifacts();
banWaterSpells(); banWaterSpells();
banWaterSkills();
} }
void CMap::banWaterSpells() void CMap::banWaterSpells()
@@ -617,6 +618,21 @@ void CMap::banWaterArtifacts()
} }
} }
void CMap::banWaterSkills()
{
for (int j = 0; j < allowedAbilities.size(); j++)
{
if (allowedAbilities[j])
{
auto* skill = dynamic_cast<const CSkill*>(VLC->skills()->getByIndex(j));
if (skill->onlyOnWaterMap && !isWaterMap())
{
allowedAbilities[j] = false;
}
}
}
}
void CMap::banWaterHeroes() void CMap::banWaterHeroes()
{ {
for (int j = 0; j < allowedHeroes.size(); j++) for (int j = 0; j < allowedHeroes.size(); j++)

View File

@@ -112,6 +112,7 @@ public:
void banWaterHeroes(); void banWaterHeroes();
void banHero(const HeroTypeID& id); void banHero(const HeroTypeID& id);
void banWaterSpells(); void banWaterSpells();
void banWaterSkills();
void banWaterContent(); void banWaterContent();
/// Gets object of specified type on requested position /// Gets object of specified type on requested position