Browse Source

Fix discovered issues, remove not implemented ideas

Ivan Savenko 5 months ago
parent
commit
6859ab7c36

+ 3 - 2
lib/mapObjects/CRewardableObject.cpp

@@ -53,9 +53,10 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *hero) const
 	}
 	}
 
 
 	if (!isGuarded())
 	if (!isGuarded())
+	{
 		doHeroVisit(hero);
 		doHeroVisit(hero);
-
-	if (configuration.forceCombat)
+	}
+	else if (configuration.forceCombat)
 	{
 	{
 		doStartBattle(hero);
 		doStartBattle(hero);
 	}
 	}

+ 0 - 5
lib/rewardable/Configuration.h

@@ -71,9 +71,6 @@ struct DLL_LINKAGE ResetInfo
 	/// if true - re-randomize rewards on a new week
 	/// if true - re-randomize rewards on a new week
 	bool rewards;
 	bool rewards;
 	
 	
-	/// Reset object after visit by a hero, whether hero accepted reward or not
-	bool resetAfterVisit = false;
-
 	void serializeJson(JsonSerializeFormat & handler);
 	void serializeJson(JsonSerializeFormat & handler);
 	
 	
 	template <typename Handler> void serialize(Handler &h)
 	template <typename Handler> void serialize(Handler &h)
@@ -81,8 +78,6 @@ struct DLL_LINKAGE ResetInfo
 		h & period;
 		h & period;
 		h & visitors;
 		h & visitors;
 		h & rewards;
 		h & rewards;
-		if (h.version >= Handler::Version::REWARDABLE_EXTENSIONS)
-			h & resetAfterVisit;
 	}
 	}
 };
 };
 
 

+ 7 - 1
lib/rewardable/Info.cpp

@@ -134,6 +134,8 @@ void Rewardable::Info::configureLimiter(Rewardable::Configuration & object, vstd
 	limiter.heroExperience = randomizer.loadValue(source["heroExperience"], rng, variables);
 	limiter.heroExperience = randomizer.loadValue(source["heroExperience"], rng, variables);
 	limiter.heroLevel = randomizer.loadValue(source["heroLevel"], rng, variables);
 	limiter.heroLevel = randomizer.loadValue(source["heroLevel"], rng, variables);
 	limiter.canLearnSkills = source["canLearnSkills"].Bool();
 	limiter.canLearnSkills = source["canLearnSkills"].Bool();
+	limiter.commanderAlive = source["commanderAlive"].Bool();
+	limiter.hasExtraCreatures = source["hasExtraCreatures"].Bool();
 
 
 	limiter.manaPercentage = randomizer.loadValue(source["manaPercentage"], rng, variables);
 	limiter.manaPercentage = randomizer.loadValue(source["manaPercentage"], rng, variables);
 	limiter.manaPoints = randomizer.loadValue(source["manaPoints"], rng, variables);
 	limiter.manaPoints = randomizer.loadValue(source["manaPoints"], rng, variables);
@@ -143,9 +145,12 @@ void Rewardable::Info::configureLimiter(Rewardable::Configuration & object, vstd
 	limiter.primary = randomizer.loadPrimaries(source["primary"], rng, variables);
 	limiter.primary = randomizer.loadPrimaries(source["primary"], rng, variables);
 	limiter.secondary = randomizer.loadSecondaries(source["secondary"], rng, variables);
 	limiter.secondary = randomizer.loadSecondaries(source["secondary"], rng, variables);
 	limiter.artifacts = randomizer.loadArtifacts(source["artifacts"], rng, variables);
 	limiter.artifacts = randomizer.loadArtifacts(source["artifacts"], rng, variables);
+	limiter.availableSlots = randomizer.loadArtifactSlots(source["availableSlots"], rng, variables);
 	limiter.spells  = randomizer.loadSpells(source["spells"], rng, variables);
 	limiter.spells  = randomizer.loadSpells(source["spells"], rng, variables);
+	limiter.scrolls  = randomizer.loadSpells(source["scrolls"], rng, variables);
 	limiter.canLearnSpells  = randomizer.loadSpells(source["canLearnSpells"], rng, variables);
 	limiter.canLearnSpells  = randomizer.loadSpells(source["canLearnSpells"], rng, variables);
 	limiter.creatures = randomizer.loadCreatures(source["creatures"], rng, variables);
 	limiter.creatures = randomizer.loadCreatures(source["creatures"], rng, variables);
+	limiter.canReceiveCreatures = randomizer.loadCreatures(source["canReceiveCreatures"], rng, variables);
 	
 	
 	limiter.players = randomizer.loadColors(source["colors"], rng, variables);
 	limiter.players = randomizer.loadColors(source["colors"], rng, variables);
 	limiter.heroes = randomizer.loadHeroes(source["heroes"], rng);
 	limiter.heroes = randomizer.loadHeroes(source["heroes"], rng);
@@ -185,11 +190,12 @@ void Rewardable::Info::configureReward(Rewardable::Configuration & object, vstd:
 
 
 	reward.grantedArtifacts = randomizer.loadArtifacts(source["artifacts"], rng, variables);
 	reward.grantedArtifacts = randomizer.loadArtifacts(source["artifacts"], rng, variables);
 	reward.takenArtifacts = randomizer.loadArtifacts(source["takenArtifacts"], rng, variables);
 	reward.takenArtifacts = randomizer.loadArtifacts(source["takenArtifacts"], rng, variables);
-	reward.takenArtifactSlots = randomizer.loadArtifactSlots(source["takenArtifactsSlots"], rng, variables);
+	reward.takenArtifactSlots = randomizer.loadArtifactSlots(source["takenArtifactSlots"], rng, variables);
 	reward.grantedScrolls = randomizer.loadSpells(source["scrolls"], rng, variables);
 	reward.grantedScrolls = randomizer.loadSpells(source["scrolls"], rng, variables);
 	reward.takenScrolls = randomizer.loadSpells(source["takenScrolls"], rng, variables);
 	reward.takenScrolls = randomizer.loadSpells(source["takenScrolls"], rng, variables);
 	reward.spells = randomizer.loadSpells(source["spells"], rng, variables);
 	reward.spells = randomizer.loadSpells(source["spells"], rng, variables);
 	reward.creatures = randomizer.loadCreatures(source["creatures"], rng, variables);
 	reward.creatures = randomizer.loadCreatures(source["creatures"], rng, variables);
+	reward.takenCreatures = randomizer.loadCreatures(source["takenCreatures"], rng, variables);
 	if(!source["spellCast"].isNull() && source["spellCast"].isStruct())
 	if(!source["spellCast"].isNull() && source["spellCast"].isStruct())
 	{
 	{
 		reward.spellCast.first = randomizer.loadSpell(source["spellCast"]["spell"], rng, variables);
 		reward.spellCast.first = randomizer.loadSpell(source["spellCast"]["spell"], rng, variables);

+ 6 - 7
lib/rewardable/Interface.cpp

@@ -172,9 +172,6 @@ void Rewardable::Interface::grantRewardAfterLevelup(const Rewardable::VisitInfo
 		cb->giveHeroBonus(&gb);
 		cb->giveHeroBonus(&gb);
 	}
 	}
 
 
-	for(const ArtifactID & art : info.reward.grantedArtifacts)
-		cb->giveHeroNewArtifact(hero, art, ArtifactPosition::FIRST_AVAILABLE);
-
 	for(const ArtifactID & art : info.reward.takenArtifacts)
 	for(const ArtifactID & art : info.reward.takenArtifacts)
 	{
 	{
 		// hero does not have such artifact alone, but he might have it as part of assembled artifact
 		// hero does not have such artifact alone, but he might have it as part of assembled artifact
@@ -203,16 +200,18 @@ void Rewardable::Interface::grantRewardAfterLevelup(const Rewardable::VisitInfo
 		// TODO: handle locked slots?
 		// TODO: handle locked slots?
 	}
 	}
 
 
-	for(const SpellID & spell : info.reward.grantedScrolls)
-		cb->giveHeroNewScroll(hero, spell, ArtifactPosition::FIRST_AVAILABLE);
-
-
 	for(const SpellID & spell : info.reward.takenScrolls)
 	for(const SpellID & spell : info.reward.takenScrolls)
 	{
 	{
 		if(hero->hasScroll(spell, false))
 		if(hero->hasScroll(spell, false))
 			cb->removeArtifact(ArtifactLocation(hero->id, hero->getScrollPos(spell, false)));
 			cb->removeArtifact(ArtifactLocation(hero->id, hero->getScrollPos(spell, false)));
 	}
 	}
 
 
+	for(const ArtifactID & art : info.reward.grantedArtifacts)
+		cb->giveHeroNewArtifact(hero, art, ArtifactPosition::FIRST_AVAILABLE);
+
+	for(const SpellID & spell : info.reward.grantedScrolls)
+		cb->giveHeroNewScroll(hero, spell, ArtifactPosition::FIRST_AVAILABLE);
+
 	if(!info.reward.spells.empty())
 	if(!info.reward.spells.empty())
 	{
 	{
 		std::set<SpellID> spellsToGive;
 		std::set<SpellID> spellsToGive;

+ 12 - 7
lib/rewardable/Limiter.cpp

@@ -42,20 +42,25 @@ bool operator==(const Rewardable::Limiter & l, const Rewardable::Limiter & r)
 {
 {
 	return l.dayOfWeek == r.dayOfWeek
 	return l.dayOfWeek == r.dayOfWeek
 	&& l.daysPassed == r.daysPassed
 	&& l.daysPassed == r.daysPassed
-	&& l.heroLevel == r.heroLevel
 	&& l.heroExperience == r.heroExperience
 	&& l.heroExperience == r.heroExperience
+	&& l.heroLevel == r.heroLevel
 	&& l.manaPoints == r.manaPoints
 	&& l.manaPoints == r.manaPoints
 	&& l.manaPercentage == r.manaPercentage
 	&& l.manaPercentage == r.manaPercentage
-	&& l.secondary == r.secondary
 	&& l.canLearnSkills == r.canLearnSkills
 	&& l.canLearnSkills == r.canLearnSkills
-	&& l.creatures == r.creatures
-	&& l.spells == r.spells
+	&& l.commanderAlive == r.commanderAlive
+	&& l.hasExtraCreatures == r.hasExtraCreatures
+	&& l.resources == r.resources
+	&& l.primary == r.primary
+	&& l.secondary == r.secondary
 	&& l.artifacts == r.artifacts
 	&& l.artifacts == r.artifacts
-	&& l.players == r.players
+	&& l.availableSlots == r.availableSlots
+	&& l.scrolls == r.scrolls
+	&& l.spells == r.spells
+	&& l.canLearnSpells == r.canLearnSpells
+	&& l.creatures == r.creatures
 	&& l.heroes == r.heroes
 	&& l.heroes == r.heroes
 	&& l.heroClasses == r.heroClasses
 	&& l.heroClasses == r.heroClasses
-	&& l.resources == r.resources
-	&& l.primary == r.primary
+	&& l.players == r.players
 	&& l.noneOf == r.noneOf
 	&& l.noneOf == r.noneOf
 	&& l.allOf == r.allOf
 	&& l.allOf == r.allOf
 	&& l.anyOf == r.anyOf;
 	&& l.anyOf == r.anyOf;

+ 4 - 0
lib/rewardable/Limiter.h

@@ -135,6 +135,10 @@ struct DLL_LINKAGE Limiter final : public Serializeable
 		h & spells;
 		h & spells;
 		h & canLearnSpells;
 		h & canLearnSpells;
 		h & creatures;
 		h & creatures;
+		if (h.version >= Handler::Version::REWARDABLE_EXTENSIONS)
+		{
+			h & canReceiveCreatures;
+		}
 		h & heroes;
 		h & heroes;
 		h & heroClasses;
 		h & heroClasses;
 		h & players;
 		h & players;