More work on basic turn layout.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-11-02 13:57:43 +01:00
parent d7fee13002
commit fc675efdf5
11 changed files with 122 additions and 17 deletions

View File

@@ -2,6 +2,7 @@
#include "../Flow/TurnHandler.hpp"
#include "../TurnChoices/AttackTurnChoice.hpp"
#include "../Flow/TurnOrdering.hpp"
#include "../../Core/Exceptions/NotImplementedException.hpp"
using namespace CreatureLib;
using namespace CreatureLib::Battling;
@@ -10,10 +11,10 @@ const BattleLibrary *Battle::GetLibrary() const {
return _library;
}
bool Battle::CanUse(BaseTurnChoice *choice) {
bool Battle::CanUse(const BaseTurnChoice *choice) {
if (choice->GetKind() == TurnChoiceKind::Attack){
//HOOK: change number of uses needed.
return static_cast<AttackTurnChoice*>(choice)->GetAttack()->GetRemainingUses() > 1;
return static_cast<const AttackTurnChoice*>(choice)->GetAttack()->GetRemainingUses() > 1;
}
return true;
}
@@ -36,6 +37,16 @@ void Battle::CheckChoicesSetAndRun() {
auto i = 0;
for (auto side: _sides){
for (auto choice: side->GetChoices()){
if (choice->GetKind() == TurnChoiceKind::Attack){
auto attack = static_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++;
}
@@ -54,3 +65,11 @@ ChoiceQueue* Battle::GetCurrentTurnQueue() const {
Core::Random &Battle::GetRandom(){
return _random;
}
bool Battle::CreatureInField(const Creature *creature) const {
for (auto s: _sides){
if (s->CreatureOnSide(creature))
return true;
}
return false;
}