Example #1
0
        protected override void endGameHandler(UserThread client, CSMessage msg)
        {
            try
            {
                CSUser    challenger = (CSUser)msg.get(MessageType.USER);
                bool      play       = (bool)msg.get(MessageType.PLAY_GAME);
                Object    gameStuff  = (Object)msg.get(MessageType.GAME_STUFF);
                GameState state      = GameState.LOST;

                if (msg.get(MessageType.WIN_GAME) != null)
                {
                    client.ClientUser.win();
                    state = GameState.WON;
                }
                else if (msg.get(MessageType.DRAW_GAME) != null)
                {
                    client.ClientUser.draw();
                    state = GameState.DRAW;
                }

                client.ClientUser.incrementParties();
                if (view.isOpened())
                {
                    view.endGameHandler(client.ClientUser, challenger, state, play, gameStuff);
                }
            }
            catch (Exception e)
            {
                log(Severiry.ERROR, "Controller[EndGame] - " + e.Message);
            }
        }