Refactoring MustFightBattle
-
I've been working on the offensive subs submerge/withdraw step and discovered that my idea of having a unified
valid()
check that works for bothgetNames
andexecute
won't work.In the offensive subs submerge/withdraw step,
execute
shouldn't run if there is a destroyer present. ButgetNames
is called at the beginning of the round and there might be a destroyer present that will die beforeexecute
is called. IfgetNames
doesn't return the submerge/withdraw step, then an error will occur.I was actually able to trigger this error from the master branch when
Submersible Subs
is false,Sub Retreat Before Battle
is false, and a destroyer is present at the beginning of the round but then is destroyed during the round. IfSubmersible Subs
is true andSub Retreat Before Battle
is false, then this error doesn't occur because it doesn't check for destroyers.I'm going to be removing
valid()
as a public method from theBattleStep
interface. Instead,getNames
andexecute
will do their own internal valid check. This check might be the same or different, depending on the step.