Reset seen opponents on ClearBattle.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
6edc9da536
commit
66b95a6e4d
|
@ -18,8 +18,9 @@ bool Battle::CanUse(const ArbUt::BorrowedPtr<BaseTurnChoice>& choice) {
|
||||||
|
|
||||||
bool Battle::TrySetChoice(BaseTurnChoice* choice) {
|
bool Battle::TrySetChoice(BaseTurnChoice* choice) {
|
||||||
EnsureNotNull(choice)
|
EnsureNotNull(choice)
|
||||||
if (!CanUse(choice))
|
if (!CanUse(choice)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
Ensure(choice->GetUser()->GetBattleSide().HasValue())
|
Ensure(choice->GetUser()->GetBattleSide().HasValue())
|
||||||
choice->GetUser()->GetBattleSide().GetValue()->SetChoice(choice);
|
choice->GetUser()->GetBattleSide().GetValue()->SetChoice(choice);
|
||||||
CheckChoicesSetAndRun();
|
CheckChoicesSetAndRun();
|
||||||
|
@ -28,12 +29,12 @@ bool Battle::TrySetChoice(BaseTurnChoice* choice) {
|
||||||
|
|
||||||
void Battle::CheckChoicesSetAndRun() {
|
void Battle::CheckChoicesSetAndRun() {
|
||||||
try {
|
try {
|
||||||
for (auto side : _sides) {
|
for (auto* side : _sides) {
|
||||||
if (!side->AllChoicesSet()) {
|
if (!side->AllChoicesSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto side : _sides) {
|
for (auto* side : _sides) {
|
||||||
if (!side->AllPossibleSlotsFilled()) {
|
if (!side->AllPossibleSlotsFilled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +49,7 @@ void Battle::CheckChoicesSetAndRun() {
|
||||||
auto choices = std::vector<std::shared_ptr<BaseTurnChoice>>(_numberOfSides * _creaturesPerSide);
|
auto choices = std::vector<std::shared_ptr<BaseTurnChoice>>(_numberOfSides * _creaturesPerSide);
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
try {
|
try {
|
||||||
for (auto side : _sides) {
|
for (auto* side : _sides) {
|
||||||
for (auto choice : side->GetChoices()) {
|
for (auto choice : side->GetChoices()) {
|
||||||
EnsureNotNull(choice)
|
EnsureNotNull(choice)
|
||||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||||
|
|
|
@ -11,8 +11,9 @@ bool BattleSide::AllPossibleSlotsFilled() const {
|
||||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||||
auto c = _creatures[i];
|
auto c = _creatures[i];
|
||||||
if (!c.HasValue() || c.GetValue()->IsFainted()) {
|
if (!c.HasValue() || c.GetValue()->IsFainted()) {
|
||||||
if (_battle->CanSlotBeFilled(_index, i))
|
if (_battle->CanSlotBeFilled(_index, i)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|
|
@ -103,6 +103,7 @@ namespace CreatureLib::Battling {
|
||||||
void Creature::ClearBattleData() noexcept {
|
void Creature::ClearBattleData() noexcept {
|
||||||
_battle = nullptr;
|
_battle = nullptr;
|
||||||
_side = nullptr;
|
_side = nullptr;
|
||||||
|
_seenOpponents = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
|
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
|
||||||
|
@ -135,10 +136,6 @@ namespace CreatureLib::Battling {
|
||||||
this->_boostedStats.SetStat(stat, s);
|
this->_boostedStats.SetStat(stat, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ArbUt::OptionalBorrowedPtr<Battle>& Creature::GetBattle() const { return _battle; }
|
|
||||||
|
|
||||||
const ArbUt::OptionalBorrowedPtr<BattleSide>& Creature::GetBattleSide() const { return _side; }
|
|
||||||
|
|
||||||
bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
||||||
|
|
||||||
void Creature::OnFaint() {
|
void Creature::OnFaint() {
|
||||||
|
|
|
@ -106,8 +106,8 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
void SetBattleData(const ArbUt::BorrowedPtr<Battle>& battle, const ArbUt::BorrowedPtr<BattleSide>& side);
|
void SetBattleData(const ArbUt::BorrowedPtr<Battle>& battle, const ArbUt::BorrowedPtr<BattleSide>& side);
|
||||||
void ClearBattleData() noexcept;
|
void ClearBattleData() noexcept;
|
||||||
const ArbUt::OptionalBorrowedPtr<Battle>& GetBattle() const;
|
inline const ArbUt::OptionalBorrowedPtr<Battle>& GetBattle() const { return _battle; }
|
||||||
const ArbUt::OptionalBorrowedPtr<BattleSide>& GetBattleSide() const;
|
inline const ArbUt::OptionalBorrowedPtr<BattleSide>& GetBattleSide() const { return _side; }
|
||||||
inline void SetOnBattleField(bool value) { _onBattleField = value; }
|
inline void SetOnBattleField(bool value) { _onBattleField = value; }
|
||||||
inline bool IsOnBattleField() const { return _onBattleField; }
|
inline bool IsOnBattleField() const { return _onBattleField; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue