Implements running from battle.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -44,9 +44,9 @@ void TurnHandler::ExecuteChoice(BaseTurnChoice* choice) {
|
||||
case TurnChoiceKind::Pass: throw NotReachableException();
|
||||
case TurnChoiceKind::Attack: return ExecuteAttackChoice(dynamic_cast<AttackTurnChoice*>(choice));
|
||||
case TurnChoiceKind::Switch: return ExecuteSwitchChoice(dynamic_cast<SwitchTurnChoice*>(choice));
|
||||
case TurnChoiceKind::Flee: return ExecuteFleeChoice(dynamic_cast<FleeTurnChoice*>(choice));
|
||||
|
||||
case TurnChoiceKind::Item:
|
||||
case TurnChoiceKind::RunAway: throw NotImplementedException();
|
||||
case TurnChoiceKind::Item: throw NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
||||
auto hitType = hit->GetType();
|
||||
HOOK(ChangeAttackType, targetSource, attack, target, hitIndex, hitType);
|
||||
hit->SetEffectiveness(library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes()));
|
||||
hit->SetCritical(library->GetCriticalLibrary()->IsCritical(attack, target, hitIndex));
|
||||
hit->SetCritical(library->GetMiscLibrary()->IsCritical(attack, target, hitIndex));
|
||||
hit->SetBasePower(dmgLibrary->GetBasePower(attack, target, hitIndex));
|
||||
hit->SetDamage(dmgLibrary->GetDamage(attack, target, hitIndex));
|
||||
|
||||
@@ -180,4 +180,18 @@ void TurnHandler::ExecuteSwitchChoice(CreatureLib::Battling::SwitchTurnChoice* c
|
||||
auto userSide = user->GetBattleSide();
|
||||
auto userIndex = userSide->GetCreatureIndex(user);
|
||||
userSide->SetCreature(choice->GetNewCreature(), userIndex);
|
||||
}
|
||||
}
|
||||
void TurnHandler::ExecuteFleeChoice(FleeTurnChoice* choice) {
|
||||
auto user = choice->GetUser();
|
||||
auto battle = user->GetBattle();
|
||||
if (!battle->CanFlee()) {
|
||||
return;
|
||||
}
|
||||
// TODO: If any of the creatures on the users side has a script that prevents it from running, block.
|
||||
// TODO: If any of the creatures on any other side has a script that prevents this side from running, block.
|
||||
|
||||
if (battle->GetLibrary()->GetMiscLibrary()->CanFlee(choice)) {
|
||||
user->GetBattleSide()->MarkAsFled();
|
||||
battle->ValidateBattleState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../Models/ExecutingAttack.hpp"
|
||||
#include "../TurnChoices/AttackTurnChoice.hpp"
|
||||
#include "../TurnChoices/FleeTurnChoice.hpp"
|
||||
#include "../TurnChoices/SwitchTurnChoice.hpp"
|
||||
#include "ChoiceQueue.hpp"
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace CreatureLib::Battling {
|
||||
ExecutingAttack::TargetData* targetData);
|
||||
|
||||
static void ExecuteSwitchChoice(SwitchTurnChoice* choice);
|
||||
static void ExecuteFleeChoice(FleeTurnChoice* choice);
|
||||
|
||||
public:
|
||||
static void RunTurn(Battle* battle, ChoiceQueue* queue);
|
||||
|
||||
Reference in New Issue
Block a user