Add new Creature::IsUsable function, which replaces IsFainted functionality in several places.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -34,7 +34,7 @@ namespace CreatureLib::Battling {
|
||||
for (const auto& creature : p) {
|
||||
if (creature == nullptr)
|
||||
continue;
|
||||
if (creature->IsFainted())
|
||||
if (!creature->IsUsable())
|
||||
continue;
|
||||
if (creature->IsOnBattleField())
|
||||
continue;
|
||||
|
||||
@@ -10,7 +10,7 @@ bool BattleSide::AllPossibleSlotsFilled() const {
|
||||
try {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
auto c = _creatures[i];
|
||||
if (!c.HasValue() || c.GetValue()->IsFainted()) {
|
||||
if (!c.HasValue() || !c.GetValue()->IsUsable()) {
|
||||
if (_battle->CanSlotBeFilled(_index, i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -143,6 +143,8 @@ namespace CreatureLib::Battling {
|
||||
this->_boostedStats.SetStat(stat, s);
|
||||
}
|
||||
|
||||
bool Creature::IsUsable() const noexcept { return !this->IsFainted(); }
|
||||
|
||||
bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
||||
|
||||
void Creature::OnFaint() {
|
||||
|
||||
@@ -122,6 +122,8 @@ namespace CreatureLib::Battling {
|
||||
const CreatureLib::Library::TalentIndex& GetRealTalent() const noexcept { return _talentIndex; }
|
||||
const ArbUt::StringView& GetActiveTalent() const;
|
||||
|
||||
/// Are we allowed to use this creature in a battle?
|
||||
[[nodiscard]] virtual bool IsUsable() const noexcept;
|
||||
[[nodiscard]] bool IsFainted() const noexcept;
|
||||
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const noexcept;
|
||||
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace CreatureLib::Battling {
|
||||
for (Creature* c : _party) {
|
||||
if (c == nullptr)
|
||||
continue;
|
||||
if (c->IsFainted())
|
||||
if (!c->IsUsable())
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user