Set data for executing attacks.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-11-24 11:06:51 +01:00
parent 583bde3768
commit aa356d74d7
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 19 additions and 1 deletions

View File

@ -62,8 +62,12 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice *choice) {
//TODO: Change attack //TODO: Change attack
} }
// FIXME: Resolve all targets
auto target = choice->GetUser()->GetBattle()->GetTarget(choice->GetTarget());
std::vector<Creature*> targets = {target};
//TODO: Set ExecutingAttack data //TODO: Set ExecutingAttack data
auto attack = new ExecutingAttack(); auto attack = new ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript());
bool prevented = false; bool prevented = false;
HOOK(PreventAttack, attack, attack, prevented); HOOK(PreventAttack, attack, attack, prevented);
if (prevented){ if (prevented){

View File

@ -67,6 +67,16 @@ namespace CreatureLib::Battling {
LearnedAttack* _attack; LearnedAttack* _attack;
Script* _script; Script* _script;
public: public:
ExecutingAttack(const std::vector<Creature*>& targets, uint8_t numberHits, Creature* user, LearnedAttack* attack,
Script* script)
: _user(user), _attack(attack), _script(script)
{
_targets.reserve(targets.size());
for (auto target: targets){
_targets.insert({target, TargetData(numberHits)});
}
}
virtual ~ExecutingAttack() = default; virtual ~ExecutingAttack() = default;
TargetData& GetAttackDataForTarget(Creature* creature){ TargetData& GetAttackDataForTarget(Creature* creature){

View File

@ -31,6 +31,10 @@ namespace CreatureLib::Battling{
return _target; return _target;
} }
Script* GetAttackScript(){
return _attackScript;
}
protected: protected:
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override { void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override {
scripts.emplace_back(&_attackScript); scripts.emplace_back(&_attackScript);