mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Minor changes
This commit is contained in:
parent
e47bb3f1f9
commit
c39a9cac63
@ -212,11 +212,6 @@ ui16 Rewardable::Configuration::getResetDuration() const
|
|||||||
return resetParameters.period;
|
return resetParameters.period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
|
void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
|
||||||
{
|
{
|
||||||
auto grantRewardWithMessage = [&](int index, bool markAsVisit) -> void
|
auto grantRewardWithMessage = [&](int index, bool markAsVisit) -> void
|
||||||
@ -292,6 +287,9 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
|
|||||||
case Rewardable::SELECT_FIRST: // give first available
|
case Rewardable::SELECT_FIRST: // give first available
|
||||||
grantRewardWithMessage(rewards[0], true);
|
grantRewardWithMessage(rewards[0], true);
|
||||||
break;
|
break;
|
||||||
|
case Rewardable::SELECT_RANDOM: // give random
|
||||||
|
grantRewardWithMessage(*RandomGeneratorUtil::nextItem(rewards, cb->gameState()->getRandomGenerator()), true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -317,7 +315,7 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
|
|||||||
|
|
||||||
void CRewardableObject::heroLevelUpDone(const CGHeroInstance *hero) const
|
void CRewardableObject::heroLevelUpDone(const CGHeroInstance *hero) const
|
||||||
{
|
{
|
||||||
grantRewardAfterLevelup(configuration.info[configuration.selectedReward], hero);
|
grantRewardAfterLevelup(configuration.info[selectedReward], hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRewardableObject::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const
|
void CRewardableObject::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const
|
||||||
@ -476,7 +474,7 @@ bool CRewardableObject::wasVisitedBefore(const CGHeroInstance * contextHero) con
|
|||||||
case Rewardable::VISIT_UNLIMITED:
|
case Rewardable::VISIT_UNLIMITED:
|
||||||
return false;
|
return false;
|
||||||
case Rewardable::VISIT_ONCE:
|
case Rewardable::VISIT_ONCE:
|
||||||
return configuration.onceVisitableObjectCleared;
|
return onceVisitableObjectCleared;
|
||||||
case Rewardable::VISIT_PLAYER:
|
case Rewardable::VISIT_PLAYER:
|
||||||
return vstd::contains(cb->getPlayerState(contextHero->getOwner())->visitedObjects, ObjectInstanceID(id));
|
return vstd::contains(cb->getPlayerState(contextHero->getOwner())->visitedObjects, ObjectInstanceID(id));
|
||||||
case Rewardable::VISIT_BONUS:
|
case Rewardable::VISIT_BONUS:
|
||||||
@ -540,10 +538,10 @@ void CRewardableObject::setPropertyDer(ui8 what, ui32 val)
|
|||||||
initObj(cb->gameState()->getRandomGenerator());
|
initObj(cb->gameState()->getRandomGenerator());
|
||||||
break;
|
break;
|
||||||
case ObjProperty::REWARD_SELECT:
|
case ObjProperty::REWARD_SELECT:
|
||||||
configuration.selectedReward = val;
|
selectedReward = val;
|
||||||
break;
|
break;
|
||||||
case ObjProperty::REWARD_CLEARED:
|
case ObjProperty::REWARD_CLEARED:
|
||||||
configuration.onceVisitableObjectCleared = val;
|
onceVisitableObjectCleared = val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,9 +271,10 @@ namespace Rewardable
|
|||||||
{
|
{
|
||||||
SELECT_FIRST, // first reward that matches limiters
|
SELECT_FIRST, // first reward that matches limiters
|
||||||
SELECT_PLAYER, // player can select from all allowed rewards
|
SELECT_PLAYER, // player can select from all allowed rewards
|
||||||
|
SELECT_RANDOM, // one random reward from all mathing limiters
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::array<std::string, 3> SelectModeString{"selectFirst", "selectPlayer"};
|
const std::array<std::string, 3> SelectModeString{"selectFirst", "selectPlayer", "selectRandom"};
|
||||||
const std::array<std::string, 5> VisitModeString{"unlimited", "once", "hero", "bonus", "player"};
|
const std::array<std::string, 5> VisitModeString{"unlimited", "once", "hero", "bonus", "player"};
|
||||||
|
|
||||||
/// Base class that can handle granting rewards to visiting heroes.
|
/// Base class that can handle granting rewards to visiting heroes.
|
||||||
@ -292,9 +293,6 @@ namespace Rewardable
|
|||||||
/// contols who can visit an object, uses EVisitMode enum
|
/// contols who can visit an object, uses EVisitMode enum
|
||||||
ui8 visitMode = Rewardable::VISIT_UNLIMITED;
|
ui8 visitMode = Rewardable::VISIT_UNLIMITED;
|
||||||
|
|
||||||
/// reward selected by player
|
|
||||||
ui16 selectedReward = 0;
|
|
||||||
|
|
||||||
/// how and when should the object be reset
|
/// how and when should the object be reset
|
||||||
CRewardResetInfo resetParameters;
|
CRewardResetInfo resetParameters;
|
||||||
|
|
||||||
@ -304,8 +302,6 @@ namespace Rewardable
|
|||||||
/// if true - object info will shown in infobox (like resource pickup)
|
/// if true - object info will shown in infobox (like resource pickup)
|
||||||
EInfoWindowMode infoWindowType = EInfoWindowMode::AUTO;
|
EInfoWindowMode infoWindowType = EInfoWindowMode::AUTO;
|
||||||
|
|
||||||
bool onceVisitableObjectCleared = false;
|
|
||||||
|
|
||||||
EVisitMode getVisitMode() const;
|
EVisitMode getVisitMode() const;
|
||||||
ui16 getResetDuration() const;
|
ui16 getResetDuration() const;
|
||||||
|
|
||||||
@ -322,8 +318,6 @@ namespace Rewardable
|
|||||||
h & onSelect;
|
h & onSelect;
|
||||||
h & visitMode;
|
h & visitMode;
|
||||||
h & selectMode;
|
h & selectMode;
|
||||||
h & selectedReward;
|
|
||||||
h & onceVisitableObjectCleared;
|
|
||||||
h & infoWindowType;
|
h & infoWindowType;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -342,9 +336,14 @@ protected:
|
|||||||
/// grants reward to hero
|
/// grants reward to hero
|
||||||
void grantRewardBeforeLevelup(const CRewardVisitInfo & reward, const CGHeroInstance * hero) const;
|
void grantRewardBeforeLevelup(const CRewardVisitInfo & reward, const CGHeroInstance * hero) const;
|
||||||
|
|
||||||
/// caster to cast adveture spells
|
/// caster to cast adveture spells, no serialize
|
||||||
mutable spells::ExternalCaster caster;
|
mutable spells::ExternalCaster caster;
|
||||||
|
|
||||||
|
/// reward selected by player, no serialize
|
||||||
|
ui16 selectedReward = 0;
|
||||||
|
|
||||||
|
bool onceVisitableObjectCleared = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const Rewardable::Configuration getConfiguration() const;
|
const Rewardable::Configuration getConfiguration() const;
|
||||||
@ -382,6 +381,8 @@ public:
|
|||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & static_cast<CArmedInstance&>(*this);
|
h & static_cast<CArmedInstance&>(*this);
|
||||||
|
h & configuration;
|
||||||
|
h & onceVisitableObjectCleared;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class CRewardableConstructor;
|
friend class CRewardableConstructor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user