diff --git a/lib/mapObjects/CArmedInstance.cpp b/lib/mapObjects/CArmedInstance.cpp index adc47a7a5..74eb49aea 100644 --- a/lib/mapObjects/CArmedInstance.cpp +++ b/lib/mapObjects/CArmedInstance.cpp @@ -107,7 +107,7 @@ void CArmedInstance::updateMoraleBonusFromArmy() undeadModifier = new Bonus(Bonus::PERMANENT, Bonus::MORALE, Bonus::ARMY, -1, UNDEAD_MODIFIER_ID, VLC->generaltexth->arraytxt[116]); undeadModifier->description = undeadModifier->description.substr(0, undeadModifier->description.size()-2);//trim value addNewBonus(undeadModifier); - } + } } else if(undeadModifier) removeBonus(undeadModifier); @@ -131,3 +131,13 @@ CBonusSystemNode * CArmedInstance::whatShouldBeAttached() { return this; } + +void CArmedInstance::writeJsonOptions(JsonNode& json) const +{ + +} + +void CArmedInstance::readJsonOptions(const JsonNode& json) +{ + +} diff --git a/lib/mapObjects/CArmedInstance.h b/lib/mapObjects/CArmedInstance.h index 0ebe2abc1..bf22a527a 100644 --- a/lib/mapObjects/CArmedInstance.h +++ b/lib/mapObjects/CArmedInstance.h @@ -40,4 +40,7 @@ public: h & static_cast(*this); h & static_cast(*this); } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 025920192..f6d5947bb 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -103,16 +103,16 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const { std::string hoverName; if(hero->hasVisions(this, 0)) - { + { MetaString ms; ms << stacks.begin()->second->count; ms << " " ; ms.addTxt(MetaString::CRE_PL_NAMES,subID); - + ms << "\n"; - + int decision = takenAction(hero, true); - + switch (decision) { case FIGHT: @@ -123,19 +123,19 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const break; case JOIN_FOR_FREE: ms.addTxt(MetaString::GENERAL_TXT,243); - break; + break; default: //decision = cost in gold VLC->generaltexth->allTexts[244]; - ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision); + ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision); break; - } + } - ms.toString(hoverName); + ms.toString(hoverName); } else { - hoverName = getHoverText(hero->tempOwner); - } + hoverName = getHoverText(hero->tempOwner); + } const JsonNode & texts = VLC->generaltexth->localizedTexts["adventureMap"]["monsterThreat"]; @@ -557,6 +557,17 @@ int CGCreature::getNumberOfStacks(const CGHeroInstance *hero) const return split; } +void CGCreature::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGCreature::readJsonOptions(const JsonNode& json) +{ + +} + +//CGMine void CGMine::onHeroVisit( const CGHeroInstance * h ) const { int relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); @@ -693,6 +704,17 @@ void CGMine::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) con cb->startBattleI(hero, this); } +void CGMine::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGMine::readJsonOptions(const JsonNode& json) +{ + +} + + std::string CGResource::getHoverText(PlayerColor player) const { return VLC->generaltexth->restypes[subID]; @@ -777,6 +799,17 @@ void CGResource::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) cb->startBattleI(hero, this); } +void CGResource::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGResource::readJsonOptions(const JsonNode& json) +{ + +} + + CGTeleport::CGTeleport() : type(UNKNOWN), channel(TeleportChannelID()) { @@ -1223,6 +1256,16 @@ void CGArtifact::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) cb->startBattleI(hero, this); } +void CGArtifact::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGArtifact::readJsonOptions(const JsonNode& json) +{ + +} + void CGWitchHut::initObj() { if (allowedAbilities.empty()) //this can happen for RMG. regular maps load abilities from map file @@ -1280,6 +1323,17 @@ std::string CGWitchHut::getHoverText(const CGHeroInstance * hero) const return hoverName; } +void CGWitchHut::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGWitchHut::readJsonOptions(const JsonNode& json) +{ + +} + + void CGMagicWell::onHeroVisit( const CGHeroInstance * h ) const { int message; @@ -1419,6 +1473,17 @@ std::string CGShrine::getHoverText(const CGHeroInstance * hero) const return hoverName; } +void CGShrine::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGShrine::readJsonOptions(const JsonNode& json) +{ + +} + + void CGSignBottle::initObj() { //if no text is set than we pick random from the predefined ones @@ -1445,11 +1510,15 @@ void CGSignBottle::onHeroVisit( const CGHeroInstance * h ) const cb->removeObject(this); } -//TODO: remove -//void CGScholar::giveAnyBonus( const CGHeroInstance * h ) const -//{ -// -//} +void CGSignBottle::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGSignBottle::readJsonOptions(const JsonNode& json) +{ + +} void CGScholar::onHeroVisit( const CGHeroInstance * h ) const { @@ -1524,6 +1593,16 @@ void CGScholar::initObj() } } +void CGScholar::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGScholar::readJsonOptions(const JsonNode& json) +{ + +} + void CGGarrison::onHeroVisit (const CGHeroInstance *h) const { int ally = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); @@ -1560,6 +1639,16 @@ void CGGarrison::battleFinished(const CGHeroInstance *hero, const BattleResult & onHeroVisit(hero); } +void CGGarrison::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGGarrison::readJsonOptions(const JsonNode& json) +{ + +} + void CGMagi::initObj() { if (ID == Obj::EYE_OF_MAGI) @@ -1674,7 +1763,7 @@ void CGShipyard::getOutOffsets( std::vector &offsets ) const int3(-3,0,0), int3(1,0,0), //AB int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL - }; + }; } void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const @@ -1696,6 +1785,17 @@ void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const } } +void CGShipyard::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGShipyard::readJsonOptions(const JsonNode& json) +{ + +} + + void CCartographer::onHeroVisit( const CGHeroInstance * h ) const { //if player has not bought map of this subtype yet and underground exist for stalagmite cartographer @@ -1860,3 +1960,13 @@ void CGLighthouse::giveBonusTo( PlayerColor player ) const gb.bonus.sid = id.getNum(); cb->sendAndApply(&gb); } + +void CGLighthouse::writeJsonOptions(JsonNode& json) const +{ + +} + +void CGLighthouse::readJsonOptions(const JsonNode& json) +{ + +} diff --git a/lib/mapObjects/MiscObjects.h b/lib/mapObjects/MiscObjects.h index bff8630c4..d2387b12d 100644 --- a/lib/mapObjects/MiscObjects.h +++ b/lib/mapObjects/MiscObjects.h @@ -82,6 +82,9 @@ public: } protected: void setPropertyDer(ui8 what, ui32 val) override; + + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; private: void fight(const CGHeroInstance *h) const; @@ -107,6 +110,9 @@ public: h & static_cast(*this); h & message; } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGWitchHut : public CPlayersVisited @@ -124,6 +130,9 @@ public: h & static_cast(*this); h & allowedAbilities & ability; } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGScholar : public CGObjectInstance @@ -133,7 +142,6 @@ public: EBonusType bonusType; ui16 bonusID; //ID of skill/spell -// void giveAnyBonus(const CGHeroInstance * h) const; //TODO: remove CGScholar() : bonusType(EBonusType::RANDOM){}; void onHeroVisit(const CGHeroInstance * h) const override; void initObj() override; @@ -142,6 +150,9 @@ public: h & static_cast(*this); h & bonusType & bonusID; } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGGarrison : public CArmedInstance @@ -158,6 +169,9 @@ public: h & static_cast(*this); h & removableUnits; } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGArtifact : public CArmedInstance @@ -182,6 +196,9 @@ public: h & static_cast(*this); h & message & storedArtifact; } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGResource : public CArmedInstance @@ -204,6 +221,9 @@ public: h & static_cast(*this); h & amount & message; } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGShrine : public CPlayersVisited @@ -220,6 +240,9 @@ public: h & static_cast(*this);; h & spell; } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGMine : public CArmedInstance @@ -247,6 +270,9 @@ public: h & producedResource & producedQuantity; } ui32 defaultResProduction(); +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; struct DLL_LINKAGE TeleportChannel @@ -411,6 +437,9 @@ public: h & static_cast(*this); h & static_cast(*this); } +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; }; class DLL_LINKAGE CGMagi : public CGObjectInstance @@ -477,4 +506,7 @@ public: h & static_cast(*this); } void giveBonusTo( PlayerColor player ) const; +protected: + void writeJsonOptions(JsonNode & json) const override; + void readJsonOptions(const JsonNode & json) override; };