Used ClangFormat style guide I'm happy with.
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:
@@ -1,25 +1,22 @@
|
||||
#include "Battle.hpp"
|
||||
#include "../Flow/TurnHandler.hpp"
|
||||
#include "../TurnChoices/AttackTurnChoice.hpp"
|
||||
#include "../Flow/TurnOrdering.hpp"
|
||||
#include "../../Core/Exceptions/NotImplementedException.hpp"
|
||||
#include "../Flow/TurnHandler.hpp"
|
||||
#include "../Flow/TurnOrdering.hpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
const BattleLibrary *Battle::GetLibrary() const {
|
||||
return _library;
|
||||
}
|
||||
const BattleLibrary* Battle::GetLibrary() const { return _library; }
|
||||
|
||||
bool Battle::CanUse(const BaseTurnChoice *choice) {
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack){
|
||||
//HOOK: change number of uses needed.
|
||||
bool Battle::CanUse(const BaseTurnChoice* choice) {
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
// HOOK: change number of uses needed.
|
||||
return dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack()->GetRemainingUses() > 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Battle::TrySetChoice(BaseTurnChoice *choice) {
|
||||
bool Battle::TrySetChoice(BaseTurnChoice* choice) {
|
||||
if (!CanUse(choice))
|
||||
return false;
|
||||
choice->GetUser()->GetBattleSide()->SetChoice(choice);
|
||||
@@ -28,29 +25,29 @@ bool Battle::TrySetChoice(BaseTurnChoice *choice) {
|
||||
}
|
||||
|
||||
void Battle::CheckChoicesSetAndRun() {
|
||||
for (auto side: _sides){
|
||||
if (!side->AllChoicesSet()){
|
||||
for (auto side : _sides) {
|
||||
if (!side->AllChoicesSet()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto choices = std::vector<BaseTurnChoice*>(_numberOfSides * _creaturesPerSide);
|
||||
auto i = 0;
|
||||
for (auto side: _sides){
|
||||
for (BaseTurnChoice* choice: side->GetChoices()){
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack){
|
||||
auto attack = dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack();
|
||||
uint8_t uses = 1;
|
||||
//HOOK: change number of uses needed.
|
||||
if (attack->GetRemainingUses() < uses){
|
||||
//TODO: Implement default move
|
||||
throw NotImplementedException("Not enough remaining uses, change to default move.");
|
||||
}
|
||||
//HOOK: Check if we need to change the move
|
||||
}
|
||||
choices[i] = choice;
|
||||
i++;
|
||||
}
|
||||
side->ResetChoices();
|
||||
for (auto side : _sides) {
|
||||
for (BaseTurnChoice* choice : side->GetChoices()) {
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
auto attack = dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack();
|
||||
uint8_t uses = 1;
|
||||
// HOOK: change number of uses needed.
|
||||
if (attack->GetRemainingUses() < uses) {
|
||||
// TODO: Implement default move
|
||||
throw NotImplementedException("Not enough remaining uses, change to default move.");
|
||||
}
|
||||
// HOOK: Check if we need to change the move
|
||||
}
|
||||
choices[i] = choice;
|
||||
i++;
|
||||
}
|
||||
side->ResetChoices();
|
||||
}
|
||||
TurnOrdering::OrderChoices(choices, _random);
|
||||
auto choiceQueue = new ChoiceQueue(choices);
|
||||
@@ -60,39 +57,31 @@ void Battle::CheckChoicesSetAndRun() {
|
||||
_currentTurnQueue = nullptr;
|
||||
}
|
||||
|
||||
ChoiceQueue* Battle::GetCurrentTurnQueue() const {
|
||||
return _currentTurnQueue;
|
||||
}
|
||||
ChoiceQueue* Battle::GetCurrentTurnQueue() const { return _currentTurnQueue; }
|
||||
|
||||
Core::Random &Battle::GetRandom(){
|
||||
return _random;
|
||||
}
|
||||
Core::Random& Battle::GetRandom() { return _random; }
|
||||
|
||||
bool Battle::CreatureInField(const Creature *creature) const {
|
||||
for (auto s: _sides){
|
||||
bool Battle::CreatureInField(const Creature* creature) const {
|
||||
for (auto s : _sides) {
|
||||
if (s->CreatureOnSide(creature))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Battle::HasRecalledSlots() const {
|
||||
return _numberOfRecalledSlots > 0;
|
||||
}
|
||||
bool Battle::HasRecalledSlots() const { return _numberOfRecalledSlots > 0; }
|
||||
|
||||
void Battle::ForceRecall(uint8_t side, uint8_t index) {
|
||||
_numberOfRecalledSlots++;
|
||||
//TODO: Switch out.
|
||||
// TODO: Switch out.
|
||||
}
|
||||
|
||||
void Battle::FillRecall(uint8_t side, uint8_t, Creature *c) {
|
||||
void Battle::FillRecall(uint8_t side, uint8_t, Creature* c) {
|
||||
_numberOfRecalledSlots--;
|
||||
//TODO: switch in.
|
||||
if (_numberOfRecalledSlots == 0 && _currentTurnQueue != nullptr){
|
||||
// TODO: switch in.
|
||||
if (_numberOfRecalledSlots == 0 && _currentTurnQueue != nullptr) {
|
||||
TurnHandler::RunTurn(this, _currentTurnQueue);
|
||||
}
|
||||
}
|
||||
|
||||
void Battle::GetActiveScripts(std::vector<ScriptWrapper> &scripts) {
|
||||
scripts.emplace_back(&_volatile);
|
||||
}
|
||||
void Battle::GetActiveScripts(std::vector<ScriptWrapper>& scripts) { scripts.emplace_back(&_volatile); }
|
||||
|
||||
Reference in New Issue
Block a user