コード例 #1
0
 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.");
     }
 }
コード例 #2
0
 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.");
     }
 }
コード例 #3
0
        /// <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);
            }
        }
コード例 #4
0
 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.");
     }
 }
コード例 #5
0
 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.");
     }
 }