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

Fix discovered issues, remove not implemented ideas

This commit is contained in:
Ivan Savenko
2025-05-09 17:26:23 +03:00
parent 700eeb6bd4
commit 6859ab7c36
6 changed files with 33 additions and 23 deletions

View File

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

View File

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

View File

@@ -134,6 +134,8 @@ void Rewardable::Info::configureLimiter(Rewardable::Configuration & object, vstd
limiter.heroExperience = randomizer.loadValue(source["heroExperience"], rng, variables);
limiter.heroLevel = randomizer.loadValue(source["heroLevel"], rng, variables);
limiter.canLearnSkills = source["canLearnSkills"].Bool();
limiter.commanderAlive = source["commanderAlive"].Bool();
limiter.hasExtraCreatures = source["hasExtraCreatures"].Bool();
limiter.manaPercentage = randomizer.loadValue(source["manaPercentage"], 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.secondary = randomizer.loadSecondaries(source["secondary"], 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.scrolls = randomizer.loadSpells(source["scrolls"], rng, variables);
limiter.canLearnSpells = randomizer.loadSpells(source["canLearnSpells"], 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.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.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.takenScrolls = randomizer.loadSpells(source["takenScrolls"], rng, variables);
reward.spells = randomizer.loadSpells(source["spells"], 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())
{
reward.spellCast.first = randomizer.loadSpell(source["spellCast"]["spell"], rng, variables);

View File

@@ -172,9 +172,6 @@ void Rewardable::Interface::grantRewardAfterLevelup(const Rewardable::VisitInfo
cb->giveHeroBonus(&gb);
}
for(const ArtifactID & art : info.reward.grantedArtifacts)
cb->giveHeroNewArtifact(hero, art, ArtifactPosition::FIRST_AVAILABLE);
for(const ArtifactID & art : info.reward.takenArtifacts)
{
// 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?
}
for(const SpellID & spell : info.reward.grantedScrolls)
cb->giveHeroNewScroll(hero, spell, ArtifactPosition::FIRST_AVAILABLE);
for(const SpellID & spell : info.reward.takenScrolls)
{
if(hero->hasScroll(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())
{
std::set<SpellID> spellsToGive;

View File

@@ -42,20 +42,25 @@ bool operator==(const Rewardable::Limiter & l, const Rewardable::Limiter & r)
{
return l.dayOfWeek == r.dayOfWeek
&& l.daysPassed == r.daysPassed
&& l.heroLevel == r.heroLevel
&& l.heroExperience == r.heroExperience
&& l.heroLevel == r.heroLevel
&& l.manaPoints == r.manaPoints
&& l.manaPercentage == r.manaPercentage
&& l.secondary == r.secondary
&& l.canLearnSkills == r.canLearnSkills
&& l.creatures == r.creatures
&& l.spells == r.spells
&& l.artifacts == r.artifacts
&& l.players == r.players
&& l.heroes == r.heroes
&& l.heroClasses == r.heroClasses
&& 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.availableSlots == r.availableSlots
&& l.scrolls == r.scrolls
&& l.spells == r.spells
&& l.canLearnSpells == r.canLearnSpells
&& l.creatures == r.creatures
&& l.heroes == r.heroes
&& l.heroClasses == r.heroClasses
&& l.players == r.players
&& l.noneOf == r.noneOf
&& l.allOf == r.allOf
&& l.anyOf == r.anyOf;

View File

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