Furter rework on script hooks, simplifying required logic.

This commit is contained in:
2019-11-10 14:32:05 +01:00
parent f72fd5f905
commit 3488784409
18 changed files with 79 additions and 37 deletions

View File

@@ -14,7 +14,7 @@ const BattleLibrary *Battle::GetLibrary() const {
bool Battle::CanUse(const BaseTurnChoice *choice) {
if (choice->GetKind() == TurnChoiceKind::Attack){
//HOOK: change number of uses needed.
return static_cast<const AttackTurnChoice*>(choice)->GetAttack()->GetRemainingUses() > 1;
return dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack()->GetRemainingUses() > 1;
}
return true;
}
@@ -36,7 +36,7 @@ void Battle::CheckChoicesSetAndRun() {
auto choices = std::vector<const BaseTurnChoice*>(_numberOfSides * _creaturesPerSide);
auto i = 0;
for (auto side: _sides){
for (auto choice: side->GetChoices()){
for (const BaseTurnChoice* choice: side->GetChoices()){
if (choice->GetKind() == TurnChoiceKind::Attack){
auto attack = dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack();
uint8_t uses = 1;
@@ -92,3 +92,7 @@ void Battle::FillRecall(uint8_t side, uint8_t, Creature *c) {
TurnHandler::RunTurn(this, _currentTurnQueue);
}
}
void Battle::GetActiveScripts(ScriptAggregator &aggr) const {
aggr.Add(&_volatile);
}