Exemple #1
0
        /// <summary>
        /// Calls play game of model. draw player in opponent board,
        /// and check if player reached the end.
        /// </summary>
        /// <param name="direction"></param>
        public void Play(string direction)
        {
            ServerModel model      = ServerModel.GetInstance();
            string      playerId   = Context.ConnectionId;
            string      gameName   = model.Play(ToDirectionStr(direction), playerId);
            string      opponentId = model.GetCompetitorOf(playerId);

            // draw new player location in opponent board.
            Clients.Client(opponentId).moveOtherPlayer(direction);
            // check if player reached goal position.
            if (model.IsPlayerReachedExit(playerId))
            {
                Close(gameName, playerId);
            }
        }