Fix error caused by decisions with no history

This commit is contained in:
Jaculabilis 2022-11-08 18:41:46 -08:00
parent 39c3aabe45
commit 95ed8c7682
1 changed files with 6 additions and 7 deletions

View File

@ -1,5 +1,3 @@
using System.Collections.ObjectModel;
using MultiversalDiplomacy.Adjudicate.Decision; using MultiversalDiplomacy.Adjudicate.Decision;
using MultiversalDiplomacy.Adjudicate.Logging; using MultiversalDiplomacy.Adjudicate.Logging;
using MultiversalDiplomacy.Model; using MultiversalDiplomacy.Model;
@ -511,8 +509,6 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
} }
} }
// TODO needs to also resolve true if anyone moves into this timeline
// Seasons not at the head of a timeline advance if the outcome of a battle is changed. // Seasons not at the head of a timeline advance if the outcome of a battle is changed.
// The outcome of a battle is changed if: // The outcome of a battle is changed if:
// 1. The outcome of a dislodge decision is changed, // 1. The outcome of a dislodge decision is changed,
@ -526,8 +522,9 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
// TODO these aren't timeline-specific // TODO these aren't timeline-specific
IsDislodged dislodged = decisions.IsDislodged[order.Unit]; IsDislodged dislodged = decisions.IsDislodged[order.Unit];
progress |= ResolveDecision(dislodged, world, decisions, depth + 1); progress |= ResolveDecision(dislodged, world, decisions, depth + 1);
bool previous = history.IsDislodgedOutcomes[order.Unit]; if (history.IsDislodgedOutcomes.TryGetValue(order.Unit, out bool previous)
if (dislodged.Resolved && dislodged.Outcome != previous) && dislodged.Resolved
&& dislodged.Outcome != previous)
{ {
progress |= LoggedUpdate( progress |= LoggedUpdate(
decision, decision,
@ -542,7 +539,9 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
{ {
DoesMove moves = decisions.DoesMove[moveOrder]; DoesMove moves = decisions.DoesMove[moveOrder];
progress |= ResolveDecision(moves, world, decisions, depth + 1); progress |= ResolveDecision(moves, world, decisions, depth + 1);
bool previousMove = history.DoesMoveOutcomes[moveOrder]; if (history.DoesMoveOutcomes.TryGetValue(moveOrder, out bool previousMove)
&& moves.Resolved
&& moves.Outcome != previousMove)
if (moves.Resolved && moves.Outcome != previousMove) if (moves.Resolved && moves.Outcome != previousMove)
{ {
progress |= LoggedUpdate( progress |= LoggedUpdate(