From 31dff8f8da99974223613c4a268ff0cc9706c614 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 31 Aug 2024 15:28:58 +0000 Subject: [PATCH] Add coastVisitable property to rewardables, update schemas --- config/schemas/rewardable.json | 10 ++++++---- lib/CPlayerState.h | 2 +- lib/mapObjects/CRewardableObject.cpp | 5 +++++ lib/mapObjects/CRewardableObject.h | 2 ++ lib/rewardable/Configuration.cpp | 1 + lib/rewardable/Configuration.h | 6 ++++++ lib/rewardable/Info.cpp | 1 + 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config/schemas/rewardable.json b/config/schemas/rewardable.json index eaa54aff4..150349a92 100644 --- a/config/schemas/rewardable.json +++ b/config/schemas/rewardable.json @@ -99,7 +99,7 @@ } }, - "guards" : {}, //TODO + "guards" : { "$ref" : "#/definitions/identifierWithValueList" }, "limiter" : { "$ref" : "#/definitions/limiter" }, "message" : { "$ref" : "#/definitions/message" }, @@ -293,14 +293,16 @@ "type" : "boolean" }, + "coastVisitable": { + "type" : "boolean" + }, + "visitMode": { "enum" : [ "unlimited", "once", "hero", "bonus", "limiter", "player" ], "type" : "string" }, - "visitLimiter": { - "type" : "object" - }, + "visitLimiter": { "$ref" : "#/definitions/limiter" }, "selectMode": { "enum" : [ "selectFirst", "selectPlayer", "selectRandom", "selectAll" ], diff --git a/lib/CPlayerState.h b/lib/CPlayerState.h index 3da93f139..96a0ba790 100644 --- a/lib/CPlayerState.h +++ b/lib/CPlayerState.h @@ -176,7 +176,7 @@ public: h & fogOfWarMap; h & static_cast(*this); - if (h.version >= Handler::Version::TEAM_STATE_SCOUTED_OBJECTS) + if (h.version >= Handler::Version::REWARDABLE_BANKS) h & scoutedObjects; } diff --git a/lib/mapObjects/CRewardableObject.cpp b/lib/mapObjects/CRewardableObject.cpp index 674edf70b..3a26738f5 100644 --- a/lib/mapObjects/CRewardableObject.cpp +++ b/lib/mapObjects/CRewardableObject.cpp @@ -517,4 +517,9 @@ void CRewardableObject::initializeGuards() } } +bool CRewardableObject::isCoastVisitable() const +{ + return configuration.coastVisitable; +} + VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CRewardableObject.h b/lib/mapObjects/CRewardableObject.h index 99bbef46d..39a658ad2 100644 --- a/lib/mapObjects/CRewardableObject.h +++ b/lib/mapObjects/CRewardableObject.h @@ -76,6 +76,8 @@ public: void initObj(vstd::RNG & rand) override; + bool isCoastVisitable() const override; + void initializeGuards(); void setPropertyDer(ObjProperty what, ObjPropertyID identifier) override; diff --git a/lib/rewardable/Configuration.cpp b/lib/rewardable/Configuration.cpp index 9eb95649a..e866d627d 100644 --- a/lib/rewardable/Configuration.cpp +++ b/lib/rewardable/Configuration.cpp @@ -103,6 +103,7 @@ void Rewardable::Configuration::serializeJson(JsonSerializeFormat & handler) handler.serializeStruct("resetParameters", resetParameters); handler.serializeBool("canRefuse", canRefuse); handler.serializeBool("showScoutedPreview", showScoutedPreview); + handler.serializeBool("coastVisitable", coastVisitable); handler.serializeInt("infoWindowType", infoWindowType); } diff --git a/lib/rewardable/Configuration.h b/lib/rewardable/Configuration.h index a6237f4ca..d4ed53db0 100644 --- a/lib/rewardable/Configuration.h +++ b/lib/rewardable/Configuration.h @@ -162,6 +162,8 @@ struct DLL_LINKAGE Configuration /// if true - right-clicking object will show preview of object rewards bool showScoutedPreview = false; + bool coastVisitable = false; + /// if true - object info will shown in infobox (like resource pickup) EInfoWindowMode infoWindowType = EInfoWindowMode::AUTO; @@ -190,6 +192,10 @@ struct DLL_LINKAGE Configuration h & canRefuse; h & showScoutedPreview; h & infoWindowType; + if (h.version >= Handler::Version::BANK_UNIT_PLACEMENT) + h & coastVisitable; + else + coastVisitable = false; } }; diff --git a/lib/rewardable/Info.cpp b/lib/rewardable/Info.cpp index 9805f82e1..abf8fc56c 100644 --- a/lib/rewardable/Info.cpp +++ b/lib/rewardable/Info.cpp @@ -394,6 +394,7 @@ void Rewardable::Info::configureObject(Rewardable::Configuration & object, vstd: object.canRefuse = parameters["canRefuse"].Bool(); object.showScoutedPreview = parameters["showScoutedPreview"].Bool(); + object.coastVisitable = parameters["coastVisitable"].Bool(); if(parameters["showInInfobox"].isNull()) object.infoWindowType = EInfoWindowMode::AUTO;