示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        internal void OnMoveResponse(MoveResponse response)
        {
            if (response.MoveStatus == MoveStatus.Accepted)
            {
                var mv = new GameMove()
                {
                    Index  = ++this.index,
                    Row    = response.Row,
                    Column = response.Column,
                    Color  = CurrentPlayer.Color
                };

                // stores the move
                this.Move(mv);

                //
                this.Status = response.GameStatus;
                this.Winner = response.Player;

                if (response.GameStatus != GameStatus.Continue)
                {
                    this.GameOver?.Invoke(this,
                                          new GameOverEventArgs()
                    {
                        Status            = this.Status,
                        Winner            = this.Winner,
                        WinningLine       = response.WinningLine,
                        WinningLineCoords = response.WinningLineCoords,
                        Row    = response.Row,
                        Column = response.Column
                    });
                }
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gm"></param>
        internal void OnMove(GameMove move)
        {
            var mv = new GameMove()
            {
                Index  = ++this.index,
                Row    = move.Row,
                Column = move.Column,
                Color  = CurrentPlayer.Color
            };

            this.Move(mv);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gm"></param>
        internal void Move(GameMove move)
        {
            this.log.Debug("Move accepted: index={0}, color={1}, row={2}, column={3}",
                           move.Index, move.Color, move.Row, move.Column);

            // add the move to our moves list
            this.Moves.Add(move);

            // notify the subscribers
            this.MoveMade?.Invoke(this, new MoveEventArgs(move));

            // change the current player
            this.CurrentPlayer =
                (this.CurrentPlayer == this.WhitePlayer) ? this.BlackPlayer : this.WhitePlayer;

            // notify the listeners
            this.PlayerChanged?.Invoke(this,
                                       new PlayerChangedEventArgs(
                                           new Player(
                                               this.CurrentPlayer.Name, this.CurrentPlayer.Type, this.CurrentPlayer.Color)));
        }
示例#4
0
 public MoveEventArgs(GameMove gm)
 {
     this.GameMove = gm;
 }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="gm"></param>
 internal void PlayerMove(GameMove gm)
 {
     this.GameServiceActor.Tell(
         new Gomoku.Actors.Client.Move(this.CurrentPlayer, gm.Row, gm.Column));
 }