| 527 | } |
| 528 | |
| 529 | void Scene_Battle::PrepareBattleAction(Game_Battler* battler) { |
| 530 | if (battler->GetBattleAlgorithm() == nullptr) { |
| 531 | return; |
| 532 | } |
| 533 | |
| 534 | if (!battler->CanAct()) { |
| 535 | if (battler->GetBattleAlgorithm()->GetType() != Game_BattleAlgorithm::Type::None) { |
| 536 | battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::None>(battler)); |
| 537 | } |
| 538 | return; |
| 539 | } |
| 540 | |
| 541 | if (battler->GetSignificantRestriction() == lcf::rpg::State::Restriction_attack_ally) { |
| 542 | Game_Battler *target = battler->GetType() == Game_Battler::Type_Enemy ? |
| 543 | Main_Data::game_enemyparty->GetRandomActiveBattler() : |
| 544 | Main_Data::game_party->GetRandomActiveBattler(); |
| 545 | |
| 546 | battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(battler, target)); |
| 547 | return; |
| 548 | } |
| 549 | |
| 550 | if (battler->GetSignificantRestriction() == lcf::rpg::State::Restriction_attack_enemy) { |
| 551 | Game_Battler *target = battler->GetType() == Game_Battler::Type_Ally ? |
| 552 | Main_Data::game_enemyparty->GetRandomActiveBattler() : |
| 553 | Main_Data::game_party->GetRandomActiveBattler(); |
| 554 | |
| 555 | battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(battler, target)); |
| 556 | return; |
| 557 | } |
| 558 | |
| 559 | // If we can no longer perform the action (no more items, ran out of SP, etc..) |
| 560 | if (!battler->GetBattleAlgorithm()->ActionIsPossible()) { |
| 561 | battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::None>(battler)); |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | void Scene_Battle::RemoveCurrentAction() { |
| 566 | battle_actions.front()->SetBattleAlgorithm(nullptr); |
nothing calls this directly
no test coverage detected