using System; using System.Collections.Generic; using System.Linq; using System.Text; using Chop.Game.User; namespace Chop.Game.Rooms.Games { public class Lobby { public Dictionary mGames; public Room mRoom; public Lobby(Room room) { mRoom = room; mGames = new Dictionary(); } public List GetGames(VirtualGameState s) { List games = new List(); foreach (VirtualGame g in mGames.Values) if (g.mState == s) games.Add(g); return games; } public VirtualGame GetGame(int id) { try { return mGames[id]; } catch { return null; } } public void CreateGame(VirtualGame game) { game.mID = GetNewGameID(); game.AddPlayer(game.mOwner, 0); mGames.Add(game.mID, game); } public void RemoveGame(int id) { if (mGames.ContainsKey(id)) mGames.Remove(id); } public int GetNewGameID() { int i = 0; while (mGames.ContainsKey(i)) i++; return i; } } }