Ejemplo n.º 1
0
        public ActionResult Index(TestVM model)
        {
            if (!string.IsNullOrEmpty(Request.Params["init"]))
                CreateGame(model);

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            TestVM model = new TestVM();
            model.Players = new List<TestPlayer>();
            model.Players.Add(new TestPlayer { p0m = "15000", p0p = "0", p0h = true });
            model.Players.Add(new TestPlayer { p0m = "15000", p0p = "0", p0h = false });
            CreateGame(model);

            return View(model);
        }
Ejemplo n.º 3
0
        private void CreateGame(TestVM model)
        {
            var g = GameHelper.CreateNew(2, 30, "en-US", 1, model.isDebug);
            //Session["test_game"] = g;
            Session["gid"] = g.Id.ToString();
            GameContext.Clear();
            GameContext.Add(g);

            Simulator.AddPlayers(g, 2, new[] { CurrUser, "bot1" });
            Simulator.InitWithData(g, Server.MapPath("~/res"));
            g.StartGame();

            int i = 0;
            foreach (var pl in model.Players)
            {
                g.Players[i].Money = ToInt(pl.p0m) * 1000;
                g.Players[i].IsBot = !pl.p0h;
                g.Players[i].Pos = ToInt(pl.p0p);
                if (!string.IsNullOrEmpty(pl.p0c))
                {
                    var cells = pl.p0c.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
                    cells.ForEach(x => g.Cells[Int32.Parse(x)].Owner = 0);
                }
                i++;
            }

            g.Map.UpdateMap();
        }