//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); } }
//Removes Player from jail public void RemovePlayerFromJail(Player player) { JailedPlayer jPlayer = playersInJail[GetJailedPlayerIndex(player)]; RemovePlayerFromJail(jPlayer); }
//Removes JailPlayer from jail public void RemovePlayerFromJail(JailedPlayer jPlayer) { jPlayer.GetPlayer().FreePlayer(); playersInJail.Remove(jPlayer); }