Implements marking opponents as seen.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -64,6 +64,8 @@ namespace CreatureLib::Battling {
|
||||
void ValidateBattleState();
|
||||
inline bool HasEnded() const { return _hasEnded; }
|
||||
inline uint8_t GetResult() const { return _battleResult; }
|
||||
|
||||
const std::vector<BattleSide*>& GetSides() const { return _sides; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,24 @@ void BattleSide::SetChoice(BaseTurnChoice* choice) {
|
||||
|
||||
void BattleSide::SetCreature(Creature* creature, uint8_t index) {
|
||||
auto old = _creatures[index];
|
||||
if (old != nullptr){
|
||||
if (old != nullptr) {
|
||||
old->SetOnBattleField(false);
|
||||
}
|
||||
_creatures[index] = creature;
|
||||
creature->SetBattleData(_battle, this);
|
||||
creature->SetOnBattleField(true);
|
||||
if (_battle == nullptr)
|
||||
return;
|
||||
for (auto side : _battle->GetSides()) {
|
||||
if (side == this)
|
||||
continue;
|
||||
for (auto c : side->GetCreatures()) {
|
||||
if (c != nullptr) {
|
||||
c->MarkOpponentAsSeen(creature);
|
||||
creature->MarkOpponentAsSeen(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BattleSide::CreatureOnSide(const Creature* creature) const {
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace CreatureLib::Battling {
|
||||
|
||||
void GetActiveScripts(std::vector<ScriptWrapper>& scripts) final;
|
||||
|
||||
const std::vector<Creature*>& GetCreatures() { return _creatures; }
|
||||
|
||||
uint8_t GetSideIndex() { return _index; }
|
||||
uint8_t GetCreatureIndex(Creature* c) {
|
||||
for (size_t i = 0; i < _creatures.size(); i++) {
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace CreatureLib::Battling {
|
||||
|
||||
bool _hasOverridenTalent;
|
||||
std::string _overridenTalentName = "";
|
||||
std::unordered_set<Creature*> _seenOpponents = {};
|
||||
|
||||
std::vector<LearnedAttack*> _attacks;
|
||||
|
||||
@@ -69,7 +70,7 @@ namespace CreatureLib::Battling {
|
||||
void SetBattleData(Battle* battle, BattleSide* side);
|
||||
Battle* GetBattle() const;
|
||||
BattleSide* GetBattleSide() const;
|
||||
void SetOnBattleField(bool value) {_onBattleField = value;}
|
||||
void SetOnBattleField(bool value) { _onBattleField = value; }
|
||||
bool IsOnBattleField() const { return _onBattleField; }
|
||||
|
||||
const std::string& GetNickname() const;
|
||||
@@ -83,6 +84,9 @@ namespace CreatureLib::Battling {
|
||||
void Damage(uint32_t damage, DamageSource source);
|
||||
void OverrideActiveTalent(const std::string& talent);
|
||||
|
||||
void MarkOpponentAsSeen(Creature* creature) { _seenOpponents.insert(creature); }
|
||||
const std::unordered_set<Creature*>& GetSeenOpponents() const { return _seenOpponents; }
|
||||
|
||||
void GetActiveScripts(std::vector<ScriptWrapper>& scripts) override;
|
||||
void ClearVolatileScripts();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user