private static void AddUnit(GameSpec spec, UnitSpec unitSpec) { var id = (ushort)spec.Units.Count; unitSpec.UnitSpecID = id; spec.Units[id] = unitSpec; }
public static void Main(string [] args) { Console.WriteLine("Starting Mini Quest Server"); Log.Info("Loading Game Data"); GameData = new GameSpec(); //GameData.LoadGameData(); var qtdPlayers = 4; var map = new WorldMap(qtdPlayers); Log.Info("Generating World"); var worldGen = new Worldgen(map); worldGen.Populators.Add(new NewbieChunkPopulator()); worldGen.Generate(); //map.PrintAscii(); Log.Info("Registering Listeners"); new PacketHandler(); new MapListener(map); var server = new SocketServer(); server.Start(); Console.WriteLine("Registering Listeners"); Console.WriteLine("Server running"); var tick = new ServerTicks(); tick.StartTicks(); }
public CommandRunner(ESDOptions options, ESDOptions.Option opt) { this.options = options; this.opt = opt; this.spec = options.Spec; this.editor = new GameEditor(spec); this.scraper = new Scraper(spec); this.u = new Universe(); }
public static void CombineDragonTpfs() { // Utility for creating Divine Dragon texbnd. Requires using Yabber to unpack these bnds, and repack after done. string gamePath = GameSpec.ForGame(GameSpec.FromGame.SDT).GameDir; string mainPath = $@"{gamePath}\chr\c5200-texbnd-dcx\chr\c5200\c5200.tpf"; SFUtil.Backup(mainPath); TPF dragon = TPF.Read(mainPath); foreach (string p in Directory.GetFiles($@"{gamePath}\map\m25\m25_0000-tpfbhd", "m25_Dragon*.tpf.dcx")) { TPF t = TPF.Read(p); dragon.Textures.AddRange(t.Textures); } dragon.Write(mainPath); }
private GameSpec MakeGameSpec(Population competitors, Population playersInCurrentGame) { var spec = new GameSpec().BasicGame().WithSet <FirstGame>(); _gameSize.Times(() => { if (competitors.Any()) { var competitor = competitors.First(); competitors.Remove(competitor); playersInCurrentGame.Add(competitor); var controller = new AiPlayerController(competitor); var playerSpec = new PlayerSpec().WithController(controller).WithId(competitor.Id); spec.WithPlayer(playerSpec); } }); return(spec); }
public Game CreateGame() { lock (locker) { var container = new Bootstrapper().BootstrapApplication(); container.SetDefaultsToProfile("FunctionalTests"); container.GetInstance <ConsoleEventLogger>(); var aiPlayerBuilder = container.GetInstance <AiPlayerBuilder>(); _gameSpec = new GameSpec() .WithPlayer(aiPlayerBuilder.BuildAiPlayer("AI - 1", new Guid())) .WithPlayer(aiPlayerBuilder.BuildAiPlayer("AI - 2", new Guid())) .BasicGame() .WithSet <FirstGame>(); var gameBuilder = new GameBuilder(); var game = gameBuilder.Initialize(_gameSpec, container.GetInstance <GameScope>()); return(game); } }
public void NewGame(int players, int victoryCards, int curseCards) { IEventAggregator eventAggregator = new MockEventAggregator(); var deckBuilder = new DeckBuilder(); var supplyBuilder = new SupplyBuilder(eventAggregator); var playerBuilder = new PlayerBuilder(eventAggregator, deckBuilder); var scope = new GameScope(eventAggregator, supplyBuilder, playerBuilder, new List <EndGameCondition>(), new MockBus(), new Container()); GameSpec gameSpec = new GameSpec() .BasicGame() .WithSet <FirstGame>() .WithPlayer(players.Times(() => new PlayerSpec())); Game game = new GameBuilder().Initialize(gameSpec, scope); game.Supply[Victory.Estate].Count.ShouldEqual(victoryCards, "Wrong number of estates"); game.Supply[Victory.Duchy].Count.ShouldEqual(victoryCards, "Wrong number of duchies"); game.Supply[Victory.Province].Count.ShouldEqual(victoryCards, "Wrong number of provinces"); game.Supply[BasicCards.Curse].Count.ShouldEqual(curseCards, "Wrong number of curse cards"); game.Players.Count().ShouldEqual(players, "Wrong number of players"); }
private static void Main(string[] args) { try { int aiPlayerCount = AskForAiPlayerCount(); _container = new Bootstrapper().BootstrapApplication(); var aiPlayerBuilder = _container.GetInstance <AiPlayerBuilder>(); var gameSpec = new GameSpec() .BasicGame() //.WithSet<FirstGame>() //.WithSet<BigMoney>() //.WithSet<Interaction>() //.WithSet<SizeDistortion>() .WithSet <Deconstruction>() .WithPlayer(_container.GetInstance <PlayerSpec <ConsolePlayerController> >().WithPlayerName("You")) ; var i = 0; aiPlayerCount.Times(() => { gameSpec.WithPlayer(aiPlayerBuilder.WithTreeSpec(new TreeSpec { MaxDepth = 100 }).BuildAiPlayer("AI - " + ++i)); }); var gameBuilder = new GameBuilder(); var scope = _container.GetInstance <GameScope>(); new ConsoleEventLogger(scope.EventAggregator); Game game = gameBuilder.Initialize(gameSpec, scope); game.Start(); } catch (Exception) { throw; } }
public static GameSpec Generate() { GameSpec spec = new GameSpec(); // BUILDINGS // CASTLE spec.Buildings[1] = new BuildingSpec() { Id = 1, ModelID = 1, }; // FARM spec.Buildings[2] = new BuildingSpec() { Id = 2, ModelID = 2, }; spec.InitialBuilding = spec.Buildings[1].Id; TestTiles.Generate(spec); TestUnits.Generate(spec); TestItems.Generate(spec); return(spec); }
public Option NextAction() { while (opts.Count > 0) { Option opt = opts.Dequeue(); if (opt is SetGame game) { Spec = ForGame(game.Game); EsdInputs.Clear(); ClearFilters(); } else if (opt is SetGameOpt gameOpt) { string val = gameOpt.Value; switch (gameOpt.Name) { case "basedir": Spec.GameDir = WindowsifyPath(val); break; case "esddir": Spec.EsdDir = WindowsifyPath(val); EsdInputs.Clear(); ClearFilters(); break; case "maps": Spec.MsbDir = val; break; case "names": Spec.NameDir = val; break; case "msgs": Spec.MsgDir = val; break; case "layouts": Spec.LayoutDir = WindowsifyPath(val); break; case "params": Spec.ParamFile = WindowsifyPath(val); break; case "outdcx": Spec.Dcx = gameOpt.Dcx; break; default: break; } if (Spec.GameDir == null) { throw new Exception($"Can't set {gameOpt.Name} without setting basedir first"); } } else if (opt is SetFlag flag) { Flags[flag.Name] = flag.Value; } else if (opt is AddFilter filter) { ClearFilters(); foreach (string val in filter.Name) { if (ESDName.IsKnownPrefix(val)) { Esds.Add(val); } else if (val.StartsWith("m")) { Maps.Add(val); } else if (val.StartsWith("c") || val.StartsWith("h")) { Chrs.Add(val); } else { throw new Exception($"Internal error: unknown filter {val}"); } } } else if (opt is AddInput input) { if (input.Name.Any(n => n.EndsWith(".py"))) { if (!input.Name.All(n => n.EndsWith(".py"))) { throw new Exception($"Some but not all input files ended in .py"); } PyInputs.Clear(); PyInputs.AddRange(input.Name); } else { foreach (string val in input.Name) { if (!(val.EndsWith(".esd") || val.EndsWith("esdbnd.dcx") || val.EndsWith(".esd.dcx"))) { throw new Exception($"ESD input files must end in .esd, .esdbnd.dcx, or .esd.dcx"); } } EsdInputs.Clear(); EsdInputs.AddRange(input.Name); } } else if (opt is SetCmdType cmd) { Type = cmd.Type; } else if (opt is SetEddFormat eddFormat) { EddFormat = eddFormat.Type; } else if (opt is SetEddDir eddDir) { EddDir = eddDir.DirName; } else { // All others are actions LastAction = opt; return(LastAction); } } if (LastAction == null) { LastAction = new Info(); return(LastAction); } return(null); }
public ClientStrategyGame(GameSpec specs, GameWorld world) : base(specs, world) { }
public GameSpecResponse(StrategyGame game) { this.Spec = game.GameSpec; this.WorldX = game.World.SizeX; this.WorldY = game.World.SizeY; }
public static void Generate(GameSpec spec) { spec.Items[0] = GOLD; }