Added layout for CreatureParty

This commit is contained in:
Deukhoofd committed 2019-11-28 12:16:03 +01:00
1 parent aa356d74d7
commit 3b685ae782
3 files changed
+39 -1

No files matched your search

-1
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);
+1
View File
@@ -0,0 +1 @@
#include "CreatureParty.hpp"
+38
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