コード例 #1
0
        //Rolls the dice and checks if the player rolls doubles.
        //If player rolls doubles or have being in jail for 3 turns, they are released from jail
        //Else they stay in jail and time spent is increased by one.
        public bool EscapeJail(Player player)
        {
            int          rollOne = die.GetDiceRoll();
            int          rollTwo = die.GetDiceRoll();
            JailedPlayer jPlayer = playersInJail[GetJailedPlayerIndex(player)];


            if (rollOne == rollTwo || jPlayer.CanPlayerLeaveJail())
            {
                MessageBox.Show("Rolled: " + rollOne + " " + rollTwo + "\n Can leave jail.");
                RemovePlayerFromJail(jPlayer);
                return(true);
            }
            else
            {
                MessageBox.Show("Rolled: " + rollOne + " " + rollTwo + "\n Cannot leave jail.");
                jPlayer.SpendTurnInJail();
                return(false);
            }
        }
コード例 #2
0
        //Removes Player from jail
        public void RemovePlayerFromJail(Player player)
        {
            JailedPlayer jPlayer = playersInJail[GetJailedPlayerIndex(player)];

            RemovePlayerFromJail(jPlayer);
        }
コード例 #3
0
 //Removes JailPlayer from jail
 public void RemovePlayerFromJail(JailedPlayer jPlayer)
 {
     jPlayer.GetPlayer().FreePlayer();
     playersInJail.Remove(jPlayer);
 }