2005-03-19

In the CBT rules, there are a few actions that player can take to interrupt
another player's movement.  These include attacks by hidden units and avoiding
a skidding unit.  Both actions have common features, but each has unique
requirements.

Unique requirements of hidden movement:
 - avoid giving hints about location of hidden unit to moving player
 - avoid giving hints about moving unit's remaining move to hidden unit's player
 - hidden unit's action automatically succeeds
 - hidden unit's player can only perform a pointblank attack

Unique requirements of avoiding a skid:
 - both skidding unit's remaing skid can be shown to stepping player
 - avoiding unit needs to pass a PSR to take action
 - avoiding unit takes entire move (possibly causing more skids or pointblank attacks)

The common elements are:
 - interrupting a unit's movement resolution
 - resuming interrupted unit's movement after completion of interrupt
 - need to track a stack of interrupted moves (even in SAV files)
 - adding non-standard GameTurn objects to the turn sequence
 - sending an update of the interrupted unit's status to only one player


I recommend that a HiddenUnitTurn be added after *every* GameTurn of the
opposing force.  If the hidden unit's player takes a turn after *every* move,
then the moving player is less likely to figure out **which** unit moved next
to a hidden unit.  If there are no valid pointblank attack targets (i.e. no
unit move next to a hidden unit), then the hidden unit's player gets a simple
AlertDialog, and the doubleblind rules will still be in effect.  At the first
step in a unit's move that takes it adjacent to a hidden unit, the move is
interrupted and the hidden unit's player can take a turn.  If the hidden unit's
player chooses not to shoot, then resume the rest of the interrupted move.
Please note, the HiddenUnitTurn is not removed until the unit's entire
move is complete, as it may take several steps adjacent to hidden units, and
the hidden units' player may choose to wait until a later step to take action.

Please note that the hidden units rules aren't 100% clear whether a pointblank
attack allows the moving player to choose to change the remaining steps in
the moving unit's turn.  The phrasing is "Any damage takes effect immediately
during the Movement Phase, and the results may affect the actions of the target
unit for the rest of the phase."  I believe that the rule intends for PSRs to
be resolved immediately, and the the moving player can use any remaining MPs
to react to the revealed unit.  Therefore, insert a new SpecificEntityTurn
into the game following the HiddenUnitTurn (and add a HiddenUnitTurn after the
SpecificUnitTurn:) to allow the moving player to finish his move after the
hidden unit revealed itself.


The AvoidSkidTurn should only be added when possible, and it should be
inserted right after the moving unit's turn (which is considered complete when
the skid starts).  After the interrupting unit's move (which itself may add
HiddenUnitTurns, or cause additional AvoidSkidTurns), the remaining
skid is resolved (which may result in yet *more* AvoidSkidTurns).  Thus
parts the skid resolution may occur in several different GameTurns.  Finally,
don't forget to remove the first "normal" GameTurn that the avoiding unit
could have taken (i.e. it took its move early).

Creating and inserting new GameTurn objects should be quite easy.  Reworking
the Server#processMovement() method to allow it to be interrupted, saving any
remaining movement, and resuming saved movement as appropriate will be the hard
parts of this task.