public GameResult?RemovePlayer(String playerID) { if (PlayerIDs.Contains(playerID)) { var players = PlayerIDs.Split(",").ToList(); players.Remove(playerID); if (players[0] != null && players[0] != "") { PlayerIDs = players[0] + ","; } else { return(GameResult.END); } } return(null); }
public bool Turn(String id, String chosenFieldCell) { if (id == CurrentPlayerMove) { var chosen = int.Parse(chosenFieldCell); var players = PlayerIDs.Split(",").ToList(); var currentField = new JavaScriptSerializer().Deserialize <String[]>(GameFieldJSON); if (currentField[chosen] != "") { return(false); } currentField[chosen] = id; Result = DetermineWinner(currentField); GameFieldJSON = new JavaScriptSerializer().Serialize(currentField); if (Result == GameResult.NONE) { CurrentPlayerMove = (players[0] == id) ? players[1] : players[0]; } return(true); } return(false); }