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)
|
||||
:_queue(std::move(queue)){}
|
||||
|
||||
const BaseTurnChoice* Dequeue(){
|
||||
BaseTurnChoice* Dequeue(){
|
||||
auto b = _queue[_current];
|
||||
_current++;
|
||||
return b;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
using namespace CreatureLib::Battling;
|
||||
|
||||
void TurnHandler::RunTurn(Battle* battle, ChoiceQueue* queue) {
|
||||
//HOOK: On Before Turn hook for all choices
|
||||
for (auto choice: queue->GetInnerQueue()){
|
||||
HOOK(OnBeforeTurn, choice, choice);
|
||||
}
|
||||
|
@ -21,7 +20,7 @@ void TurnHandler::RunTurn(Battle* battle, ChoiceQueue* queue) {
|
|||
queue->HasCompletedQueue = true;
|
||||
}
|
||||
|
||||
void TurnHandler::ExecuteChoice(const BaseTurnChoice *choice) {
|
||||
void TurnHandler::ExecuteChoice(BaseTurnChoice *choice) {
|
||||
if (choice == nullptr)
|
||||
{
|
||||
return;
|
||||
|
@ -48,7 +47,7 @@ void TurnHandler::ExecuteChoice(const BaseTurnChoice *choice) {
|
|||
switch (choiceKind){
|
||||
case TurnChoiceKind::Pass: throw NotReachableException();
|
||||
case TurnChoiceKind::Attack:
|
||||
return ExecuteAttackChoice(dynamic_cast<const AttackTurnChoice*>(choice));
|
||||
return ExecuteAttackChoice(dynamic_cast<AttackTurnChoice*>(choice));
|
||||
case TurnChoiceKind::Item:
|
||||
case TurnChoiceKind::Switch:
|
||||
case TurnChoiceKind::RunAway:
|
||||
|
@ -56,12 +55,20 @@ void TurnHandler::ExecuteChoice(const BaseTurnChoice *choice) {
|
|||
}
|
||||
}
|
||||
|
||||
void TurnHandler::ExecuteAttackChoice(const AttackTurnChoice *choice) {
|
||||
//HOOK: Change attack
|
||||
|
||||
//HOOK: Prevent attack
|
||||
void TurnHandler::ExecuteAttackChoice(AttackTurnChoice *choice) {
|
||||
auto attackName = choice->GetAttack()->GetAttack()->GetName();
|
||||
HOOK(ChangeAttack, choice, choice, attackName);
|
||||
if (attackName != choice->GetAttack()->GetAttack()->GetName()){
|
||||
//TODO: Change attack
|
||||
}
|
||||
|
||||
//TODO: Set ExecutingAttack data
|
||||
auto attack = new ExecutingAttack();
|
||||
bool prevented = false;
|
||||
HOOK(PreventAttack, attack, attack, prevented);
|
||||
if (prevented){
|
||||
return;
|
||||
}
|
||||
|
||||
//HOOK: override targets
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ namespace CreatureLib::Battling {
|
|||
class Battle;
|
||||
|
||||
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);
|
||||
public:
|
||||
static void RunTurn(Battle* battle, ChoiceQueue* queue);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
namespace CreatureLib::Battling{
|
||||
class BaseTurnChoice;
|
||||
class AttackTurnChoice;
|
||||
class ExecutingAttack;
|
||||
class Creature;
|
||||
|
||||
|
@ -25,6 +26,10 @@ namespace CreatureLib::Battling{
|
|||
}
|
||||
|
||||
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 IsInvulnerable(ExecutingAttack* attack, Creature* target , bool& result){};
|
||||
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
||||
|
|
Loading…
Reference in New Issue