Esempio n. 1
0
        // POST: api/Room   create room
        public RoomState Post([FromBody] Room value, string token)
        {
            if (Server.ChangeLeagues.AddDays(7) <= DateTime.Now)
            {
                Server.GameFacade.SetLeagues();
                Server.ChangeLeagues = DateTime.Now;
            }
            var ans = new RoomState();

            try
            {
                Server.CheckToken(token);
                IRoom r = Server.GameFacade.CreateGameWithPreferences(value.RoomName,
                                                                      Crypto.Decrypt(value.CreatorUserName), value.CreatorPlayerName, value.GameType, value.BuyInPolicy,
                                                                      value.ChipPolicy, value.MinBet, value.MinPlayers, value.MaxPlayers, value.SpectatingAllowed);
                if (r != null)
                {
                    var roomDic  = new Dictionary <string, List <RoomState> >();
                    var userList = new List <RoomState>();
                    if (Replays.ContainsKey(r.Name))
                    {
                        Replays.Remove(r.Name);
                    }
                    roomDic.Add(value.CreatorPlayerName, userList);
                    Replays.Add(r.Name, roomDic);
                    CreateRoomState(value.CreatorPlayerName, r, ans);
                }
                return(ans);
            }

            catch (Exception e)
            {
                ans.Messege = e.Message;
                return(ans);
            }
        }