Added layout for CreatureParty

This commit is contained in:
Deukhoofd 2019-11-28 12:16:03 +01:00
parent aa356d74d7
commit 3b685ae782
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 39 additions and 1 deletions

View File

@ -66,7 +66,6 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice *choice) {
auto target = choice->GetUser()->GetBattle()->GetTarget(choice->GetTarget());
std::vector<Creature*> targets = {target};
//TODO: Set ExecutingAttack data
auto attack = new ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript());
bool prevented = false;
HOOK(PreventAttack, attack, attack, prevented);

View File

@ -0,0 +1 @@
#include "CreatureParty.hpp"

View File

@ -0,0 +1,38 @@
#ifndef CREATURELIB_CREATUREPARTY_HPP
#define CREATURELIB_CREATUREPARTY_HPP
#include <array>
#include "Creature.hpp"
namespace CreatureLib::Battling{
template <int max>
class CreatureParty {
std::array<Creature*, max> _party;
public:
CreatureParty(std::array<Creature*, max> party) : _party(party){
}
Creature* GetAtIndex(int index) const{
return _party[index];
}
void Switch(int a, int b){
auto ca = _party[a];
_party[a] = _party[b];
_party[b] = ca;
}
bool HasAvailableCreatures() const{
for (Creature* c: _party){
if (c == nullptr) continue;
if (c->IsFainted()) continue;
return true;
}
return false;
}
};
}
#endif //CREATURELIB_CREATUREPARTY_HPP