public IGame CreateGame(NetUser creator, string name, string type) { System.Diagnostics.Debug.Assert(bot.Master != null); System.Diagnostics.Debug.Assert(bot.Config != null); if(games.Any(g => g.Name.ToLower() == name.ToLower())) { throw new DuplicateNameException("A game with the name " + name + " already exists."); } IGame game = null; switch(type) { case "mafia": game = new MafiaGame.MafiaGame(bot, creator, name); break; case "barebones": game = new Barebones.BarebonesGame(bot, creator, name); break; default: throw new InvalidGameTypeException("Gametype " + type + " not found."); } game.Creator = creator; if(game == null) { throw new InvalidGameTypeException("Unknown game type " + type); } games.Add(game); creator.Commands.Add(new Commands.DestroyCommand(this, game)); return game; }
public MafiaUser(MafiaGame game, NetUser user, VillageMember member) { this.user = user; this.game = game; this.member = member; AddMafiaCommands(); member.PowerGained += new EventHandler<PowerEventArgs>(OnPowerGained); member.PowerLost += new EventHandler<PowerEventArgs>(OnPowerLost); member.Faction.PowerGained += new EventHandler<PowerEventArgs>(OnFactionPowerGained); member.Faction.PowerLost += new EventHandler<PowerEventArgs>(OnFactionPowerLost); }
public VillageConnector(MafiaGame game) { this.game = game; }