Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how AI handles an unexpected EndBattle event #341

merged 1 commit into from Sep 13, 2018
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+7 −5
Diff settings


Just for now

Copy path View file
@@ -320,6 +320,10 @@ impl Ai {

pub fn command(&mut self, state: &State) -> Option<Command> {
if state.battle_result().is_some() {
info!("AI: The battle has ended, can't create new commands.");
return None;
let mut ids = state::players_agent_ids(state,;
state::sort_agent_ids_by_distance_to_enemies(state, &mut ids);
for agent_id in ids {
@@ -7,6 +7,7 @@ use core::tactical_map::{

pub fn check(state: &State, command: &Command) -> Result<(), Error> {
trace!("check: {:?}", command);
if state.battle_result().is_some() {
return Err(Error::BattleEnded);
Copy path View file
@@ -247,17 +247,14 @@ impl Battle {
fn do_ai(&mut self, context: &mut Context) -> Box<dyn Action> {
debug!("AI: <");
let mut actions = Vec::new();
loop {
let command =;
while let Some(command) = {
debug!("AI: command = {:?}", command);
actions.push(self.do_command_inner(context, &command));
if let command::Command::EndTurn(_) = command {
if self.state.battle_result().is_some() {
debug!("AI: >");
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.