/// <summary>
 /// concatenate two phaseList together
 /// </summary>
 /// <param name="added"></param>
 public void pushList(PhaseList added)
 {
     if (isEmpty())
     {
         head = added.head;
         tail = added.tail;
     }
     else if (added.isEmpty())
     {
     }
     else
     {
         added.tail.next = head;
         head            = added.head;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Advance the next stage and skip the following stages that do not need user response
 /// </summary>
 public bool nextStage(UserAction userAction)
 {
     while (true)
     {
         PhaseList followingPhases;
         if (curPhase is PlayerTurn)
         { // when turn switches
             curRoundPlayer = curPhase.player;
             log(Legends_of_the_Three_Kingdoms.Properties.Resources.The_round_of + curRoundPlayer.ToString() + Legends_of_the_Three_Kingdoms.Properties.Resources._start);
         }
         followingPhases = curPhase.advance(userAction, this);
         if (followingPhases == null)
         { // the next state need a user action for future decison
             if (curPhase is HiddenPhase)
             {
                 throw new InvalidOperationException(Legends_of_the_Three_Kingdoms.Properties.Resources.Invisible_Phase_should_not_giv + curPhase);
             }
             else
             {
                 return(false);
             }
         }
         stages.pop();
         stages.pushList(followingPhases);
         if (stages.isEmpty())
         {
             throw new EmptyException(Legends_of_the_Three_Kingdoms.Properties.Resources.The_stages_stack_is_empty);
         }
         if (curPhase.needResponse())
         { // the next state need a user action for future decison
           // but since it is supposed to be a responsive phase, pause a while before autoadvance
             log(curPhase.ToString());
             return(true);
         }
     }
 }