Esempio n. 1
0
        public async Task SetClientStatus(int statusIntValue, TMContext context)
        {
            var info = FindClientInfo(context.Client);

            if (info != null)
            {
                info.ClientStatus = (TMClientInfoInRoom.ClientStatusForRoom)statusIntValue;
            }
            await context.ReplyOKAsync();
        }
Esempio n. 2
0
        public async Task <TMGame> StartNewGame(TMContext context)
        {
            await context.ReplyOKAsync();

            var game = new TMGame();

            game.Room = this;
            await game.SaveAsync();

            this.Status = RoomStatus.Playing;
            await this.SaveAsync();

            game.UseRpc(Lobby);

            var players = new List <TMPlayer>();

            foreach (var info in this.ClientInfos)
            {
                TMPlayer player = new TMPlayer(info)
                {
                    Game = game
                };
                players.Add(player);
            }

            await SaveAllAsync(players);

            game.Players = players;

            //List<Task> createdGameTasks = new List<Task>();

            //foreach (var p in game.Players)
            //{
            //    p.UseRpc(Lobby);
            //    createdGameTasks.Add(this.RpcClientAsync(p.Client, "OnNewGameCreated", game, p));
            //}

            this.RpcAllAsync("OnNewGameCreated", game, game.Players).ContinueWith(t =>
            {
                game.RpcAllAsync("WaitingForAllottingCharacters");
                return(game.InitAllotCharactersAsync());
            }).Unwrap();

            return(game);
        }