Update to latest Arbutils.
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:
@@ -9,7 +9,6 @@ using namespace CreatureLib::Battling;
|
||||
const ArbUt::BorrowedPtr<const BattleLibrary>& Battle::GetLibrary() const noexcept { return _library; }
|
||||
|
||||
bool Battle::CanUse(const ArbUt::BorrowedPtr<BaseTurnChoice>& choice) {
|
||||
AssertNotNull(choice)
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
// HOOK: change number of uses needed.
|
||||
return choice.ForceAs<AttackTurnChoice>()->GetAttack()->GetRemainingUses() >= 1;
|
||||
@@ -18,10 +17,10 @@ bool Battle::CanUse(const ArbUt::BorrowedPtr<BaseTurnChoice>& choice) {
|
||||
}
|
||||
|
||||
bool Battle::TrySetChoice(BaseTurnChoice* choice) {
|
||||
AssertNotNull(choice)
|
||||
EnsureNotNull(choice)
|
||||
if (!CanUse(choice))
|
||||
return false;
|
||||
Assert(choice->GetUser()->GetBattleSide().HasValue())
|
||||
Ensure(choice->GetUser()->GetBattleSide().HasValue())
|
||||
choice->GetUser()->GetBattleSide().GetValue()->SetChoice(choice);
|
||||
CheckChoicesSetAndRun();
|
||||
return true;
|
||||
@@ -51,7 +50,7 @@ void Battle::CheckChoicesSetAndRun() {
|
||||
try {
|
||||
for (auto side : _sides) {
|
||||
for (auto choice : side->GetChoices()) {
|
||||
AssertNotNull(choice)
|
||||
EnsureNotNull(choice)
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
auto attack = std::static_pointer_cast<AttackTurnChoice>(choice);
|
||||
uint8_t uses = 1;
|
||||
@@ -99,7 +98,6 @@ ArbUt::BorrowedPtr<ChoiceQueue> Battle::GetCurrentTurnQueue() const noexcept { r
|
||||
BattleRandom* Battle::GetRandom() noexcept { return &_random; }
|
||||
|
||||
bool Battle::CreatureInField(ArbUt::BorrowedPtr<Creature> creature) const {
|
||||
AssertNotNull(creature)
|
||||
return std::any_of(_sides.begin(), _sides.end(), [creature](auto c) { return c->CreatureOnSide(creature); });
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace CreatureLib::Battling {
|
||||
.count())
|
||||
: _library(library), _parties(parties.GetStdList()), _canFlee(canFlee), _numberOfSides(numberOfSides),
|
||||
_creaturesPerSide(creaturesPerSide), _sides(numberOfSides), _random(randomSeed) {
|
||||
AssertAllNotNull(parties);
|
||||
EnsureAllNotNull(parties);
|
||||
|
||||
for (size_t i = 0; i < numberOfSides; i++) {
|
||||
_sides.Append(new BattleSide(i, this, creaturesPerSide));
|
||||
|
||||
@@ -11,9 +11,7 @@ namespace CreatureLib::Battling {
|
||||
|
||||
public:
|
||||
BattleParty(CreatureParty* party, const ArbUt::List<CreatureIndex>& responsibleIndices)
|
||||
: _party(party), _responsibleIndices(responsibleIndices) {
|
||||
AssertNotNull(_party)
|
||||
}
|
||||
: _party(party), _responsibleIndices(responsibleIndices) {}
|
||||
|
||||
inline const ArbUt::BorrowedPtr<CreatureParty>& GetParty() const { return _party; }
|
||||
inline const ArbUt::List<CreatureIndex>& GetResponsibleIndices() const { return _responsibleIndices; }
|
||||
|
||||
@@ -7,7 +7,6 @@ using namespace CreatureLib::Battling;
|
||||
bool BattleSide::AllChoicesSet() const noexcept { return _choicesSet == _creaturesPerSide; }
|
||||
|
||||
bool BattleSide::AllPossibleSlotsFilled() const {
|
||||
AssertNotNull(_battle)
|
||||
try {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
auto c = _creatures[i];
|
||||
@@ -30,7 +29,7 @@ void BattleSide::ResetChoices() noexcept {
|
||||
}
|
||||
|
||||
void BattleSide::SetChoice(BaseTurnChoice* choice) {
|
||||
AssertNotNull(choice)
|
||||
EnsureNotNull(choice)
|
||||
try {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
auto& c = _creatures[i];
|
||||
@@ -60,9 +59,6 @@ void BattleSide::SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, uint
|
||||
}
|
||||
creature.GetValue()->SetBattleData(_battle, this);
|
||||
creature.GetValue()->SetOnBattleField(true);
|
||||
if (_battle == nullptr) {
|
||||
return;
|
||||
}
|
||||
for (auto* side : _battle->GetSides()) {
|
||||
if (side == this) {
|
||||
continue;
|
||||
@@ -91,6 +87,5 @@ size_t BattleSide::ScriptCount() const { return _battle->ScriptCount() + 1; }
|
||||
|
||||
uint8_t BattleSide::GetRandomCreatureIndex() {
|
||||
// TODO: Consider adding parameter to only get index for available creatures.
|
||||
AssertNotNull(_battle)
|
||||
return _battle->GetRandom()->Get(_creaturesPerSide);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace CreatureLib::Battling {
|
||||
|
||||
void Creature::ChangeSpecies(const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
||||
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant) {
|
||||
AssertNotNull(species);
|
||||
AssertNotNull(variant);
|
||||
_species = species;
|
||||
|
||||
// If the creature is genderless, but it's new species is not, we want to set its gender
|
||||
@@ -51,7 +49,6 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
|
||||
void Creature::ChangeVariant(const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant) {
|
||||
AssertNotNull(variant)
|
||||
_variant = variant;
|
||||
|
||||
// Set the types to the new variant.
|
||||
@@ -145,8 +142,8 @@ namespace CreatureLib::Battling {
|
||||
bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
||||
|
||||
void Creature::OnFaint() {
|
||||
AssertNotNull(_battle)
|
||||
AssertNotNull(_side)
|
||||
EnsureNotNull(_battle)
|
||||
EnsureNotNull(_side)
|
||||
// HOOK: On Faint
|
||||
if (_battle.HasValue()) {
|
||||
_battle.GetValue()->TriggerEventListener<FaintEvent>(this);
|
||||
|
||||
@@ -43,8 +43,6 @@ namespace CreatureLib::Battling {
|
||||
const std::unique_ptr<Script>& script)
|
||||
: _numberHits(numberHits), _hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user),
|
||||
_attack(attack), _targets(targets) {
|
||||
AssertNotNull(user)
|
||||
AssertNotNull(attack)
|
||||
// Take ownership of the script of the attack choice, and give attack choice our initial nullptr.
|
||||
_script.swap(const_cast<std::unique_ptr<Script>&>(script));
|
||||
}
|
||||
|
||||
@@ -4,13 +4,11 @@ CreatureLib::Battling::LearnedAttack::LearnedAttack(
|
||||
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, uint8_t maxUses,
|
||||
AttackLearnMethod learnMethod)
|
||||
: _attack(attack), _maxUses(maxUses), _remainingUses(maxUses), _learnMethod(learnMethod) {
|
||||
AssertNotNull(_attack)
|
||||
}
|
||||
|
||||
CreatureLib::Battling::LearnedAttack::LearnedAttack(
|
||||
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, AttackLearnMethod learnMethod)
|
||||
: _attack(attack), _maxUses(attack->GetBaseUsages()), _remainingUses(_maxUses), _learnMethod(learnMethod) {
|
||||
AssertNotNull(_attack)
|
||||
}
|
||||
|
||||
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>&
|
||||
|
||||
Reference in New Issue
Block a user