public static RoomDB CreateRoomDB(Room room) { if (room == null) { return(null); } RoomDB r; if (db.RoomDBs.Count() != 0) { r = db.RoomDBs.Find(room.Id); if (r != null) { return(r); } } r = new RoomDB { allowSpectating = room.Game.IsAllowSpectating(), bigBlind = ((TexasGame)room.Game).GamePreferences.BigBlind, gamePolicy = ((TexasGame)room.Game).GamePreferences.GetGameType().ToString(), id = room.Id, maxBuyIn = ((TexasGame)room.Game).GamePreferences.MaxBuyIn, maxPlayers = ((TexasGame)room.Game).GamePreferences.MaxPlayers, minBuyIn = ((TexasGame)room.Game).GamePreferences.MinBuyIn, minPlayers = ((TexasGame)room.Game).GamePreferences.MinPlayers }; return(r); }
public static Room CreateRoomFromDB(RoomDB rd) { if (rd == null) { return(null); } GameTypePolicy policy = (GameTypePolicy)Enum.Parse(typeof(GameTypePolicy), rd.gamePolicy); return(new Room(rd.id, new TexasGame(new GamePreferences(policy, rd.maxPlayers, rd.minPlayers, rd.minBuyIn, rd.maxBuyIn, rd.allowSpectating, rd.bigBlind)))); }
public void AddRoomToLeague(League league, Room room) { LeagueDB ldb = CreateLeagueDB(league); if (ldb.Rooms.Count != 0 && ldb.Rooms.Any(l => l.id == room.Id)) { return; } RoomDB rdb = RoomsByDB.CreateRoomDB(room); ldb.Rooms.Add(rdb); league.Rooms.Add(room); db.SaveChanges(); Log.InfoLog("DB:Add Room " + room.Id + " to a League " + league.Id); }