private void challenge_player(Player player, Message message) { try { if (player.IsPlaying) { player.Send("Denied", "You are already playing."); } Player target = FindPlayerByName(message.GetString(0)); if (target.IsPlaying) { player.Send("Denied", "Target is already playing."); } player.ChallengePlayer(target); } catch (Exception e) { Log("Challenge player message processing failed.", e); player.Send("Denied", "Incorrect message format."); } }
private void delete_figure(Player player, Message message) { try { string position = message.GetString(0); player.GameModel.DeleteFigure(position); Broadcast("Delete figure", player.ConnectUserId, position); } catch (Exception e) { Log("Delete figure message processing failed.", e); player.Send("Denied", "Incorrect message format."); } }
/// <summary> /// Вызывает другого игрока на игру. /// </summary> /// <param name="other">Вызванный игрок.</param> public void ChallengePlayer(Player other) { game.Log("Player " + this.ConnectUserId + " challenged player " + other.ConnectUserId + "."); if (other == this) { this.Send("Denied", "You can't challenge yourself."); return; } if (challenged != null) { challenged.Send("Challenge revoked", this.ConnectUserId); } challenged = other; other.Send("Challenged", this.ConnectUserId); if (other.Challenged == this) { GameModel model = new GameModel(this, other); this.GameCreated(model); other.GameCreated(model); } }
private void stop_game(Player player, Message message) { if (player.GameModel == null) { Log("Player tried to stop game, but they are not playing."); player.Send("Denied", "You are not playing."); } }
private void say(Player player, Message message) { try { Broadcast("Say", player.ConnectUserId, message.GetString(0)); } catch (Exception e){ Log("Say message processing failed.", e); player.Send("Denied", "Incorrect message format."); } }