示例#1
0
        private static void UserJoined(Game game, GameAction action)
        {
            User user = ctx.GetUserByID(action.UserID.Value);

            Console.WriteLine(String.Format("{0} joined the game.", user.Name));

            // place user, commit action
            ctx.PlaceUserOnFreeSeat(game, user, action.GameActionID);

            // how many users are in the game?
            List <int> usersInGame = ctx.GetUsersInGame(game);

            if (usersInGame.Count == 1)
            {
                // your are the first user, wait for other players
                ctx.WaitForPlayers(game, action.UserID.Value);
            }
            if (usersInGame.Count == 2)
            {
                // you are the second user, start the game
                ctx.PayBlinds(game);

                // deal first cards
                ctx.DealPocketCards(game);
            }
            else if (usersInGame.Count > 2)
            {
                // wait for round to end
            }
        }