Added more script hooks
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
49bd4813f6
commit
f6415fba27
|
@ -15,7 +15,7 @@ namespace CreatureLib::Battling{
|
||||||
explicit ChoiceQueue(std::vector<BaseTurnChoice*> queue)
|
explicit ChoiceQueue(std::vector<BaseTurnChoice*> queue)
|
||||||
:_queue(std::move(queue)){}
|
:_queue(std::move(queue)){}
|
||||||
|
|
||||||
const BaseTurnChoice* Dequeue(){
|
BaseTurnChoice* Dequeue(){
|
||||||
auto b = _queue[_current];
|
auto b = _queue[_current];
|
||||||
_current++;
|
_current++;
|
||||||
return b;
|
return b;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
using namespace CreatureLib::Battling;
|
using namespace CreatureLib::Battling;
|
||||||
|
|
||||||
void TurnHandler::RunTurn(Battle* battle, ChoiceQueue* queue) {
|
void TurnHandler::RunTurn(Battle* battle, ChoiceQueue* queue) {
|
||||||
//HOOK: On Before Turn hook for all choices
|
|
||||||
for (auto choice: queue->GetInnerQueue()){
|
for (auto choice: queue->GetInnerQueue()){
|
||||||
HOOK(OnBeforeTurn, choice, choice);
|
HOOK(OnBeforeTurn, choice, choice);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +20,7 @@ void TurnHandler::RunTurn(Battle* battle, ChoiceQueue* queue) {
|
||||||
queue->HasCompletedQueue = true;
|
queue->HasCompletedQueue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnHandler::ExecuteChoice(const BaseTurnChoice *choice) {
|
void TurnHandler::ExecuteChoice(BaseTurnChoice *choice) {
|
||||||
if (choice == nullptr)
|
if (choice == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -48,7 +47,7 @@ void TurnHandler::ExecuteChoice(const BaseTurnChoice *choice) {
|
||||||
switch (choiceKind){
|
switch (choiceKind){
|
||||||
case TurnChoiceKind::Pass: throw NotReachableException();
|
case TurnChoiceKind::Pass: throw NotReachableException();
|
||||||
case TurnChoiceKind::Attack:
|
case TurnChoiceKind::Attack:
|
||||||
return ExecuteAttackChoice(dynamic_cast<const AttackTurnChoice*>(choice));
|
return ExecuteAttackChoice(dynamic_cast<AttackTurnChoice*>(choice));
|
||||||
case TurnChoiceKind::Item:
|
case TurnChoiceKind::Item:
|
||||||
case TurnChoiceKind::Switch:
|
case TurnChoiceKind::Switch:
|
||||||
case TurnChoiceKind::RunAway:
|
case TurnChoiceKind::RunAway:
|
||||||
|
@ -56,12 +55,20 @@ void TurnHandler::ExecuteChoice(const BaseTurnChoice *choice) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnHandler::ExecuteAttackChoice(const AttackTurnChoice *choice) {
|
void TurnHandler::ExecuteAttackChoice(AttackTurnChoice *choice) {
|
||||||
//HOOK: Change attack
|
auto attackName = choice->GetAttack()->GetAttack()->GetName();
|
||||||
|
HOOK(ChangeAttack, choice, choice, attackName);
|
||||||
//HOOK: Prevent attack
|
if (attackName != choice->GetAttack()->GetAttack()->GetName()){
|
||||||
|
//TODO: Change attack
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Set ExecutingAttack data
|
||||||
auto attack = new ExecutingAttack();
|
auto attack = new ExecutingAttack();
|
||||||
|
bool prevented = false;
|
||||||
|
HOOK(PreventAttack, attack, attack, prevented);
|
||||||
|
if (prevented){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//HOOK: override targets
|
//HOOK: override targets
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ namespace CreatureLib::Battling {
|
||||||
class Battle;
|
class Battle;
|
||||||
|
|
||||||
class TurnHandler {
|
class TurnHandler {
|
||||||
static void ExecuteChoice(const BaseTurnChoice* choice);
|
static void ExecuteChoice(BaseTurnChoice* choice);
|
||||||
|
|
||||||
static void ExecuteAttackChoice(const AttackTurnChoice* choice);
|
static void ExecuteAttackChoice(AttackTurnChoice* choice);
|
||||||
static void HandleAttackForTarget(ExecutingAttack* attack, Creature* target, const ExecutingAttack::TargetData& targetData);
|
static void HandleAttackForTarget(ExecutingAttack* attack, Creature* target, const ExecutingAttack::TargetData& targetData);
|
||||||
public:
|
public:
|
||||||
static void RunTurn(Battle* battle, ChoiceQueue* queue);
|
static void RunTurn(Battle* battle, ChoiceQueue* queue);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
namespace CreatureLib::Battling{
|
namespace CreatureLib::Battling{
|
||||||
class BaseTurnChoice;
|
class BaseTurnChoice;
|
||||||
|
class AttackTurnChoice;
|
||||||
class ExecutingAttack;
|
class ExecutingAttack;
|
||||||
class Creature;
|
class Creature;
|
||||||
|
|
||||||
|
@ -25,6 +26,10 @@ namespace CreatureLib::Battling{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnBeforeTurn(const BaseTurnChoice* choice){};
|
virtual void OnBeforeTurn(const BaseTurnChoice* choice){};
|
||||||
|
|
||||||
|
virtual void ChangeAttack(AttackTurnChoice* choice, std::string& attack){};
|
||||||
|
virtual void PreventAttack(ExecutingAttack* attack,bool& result){};
|
||||||
|
|
||||||
virtual void FailIncomingAttack(ExecutingAttack* attack, Creature* target, bool& result){};
|
virtual void FailIncomingAttack(ExecutingAttack* attack, Creature* target, bool& result){};
|
||||||
virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target , bool& result){};
|
virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target , bool& result){};
|
||||||
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
||||||
|
|
Loading…
Reference in New Issue