Beispiel #1
0
        public void QueryBattlegroup()
        {
            if (CivilizationInfo.battlegroup_id == null)
            {
                return;
            }

            Debug.WriteLine(string.Format("Civilization Ship: {0}, Getting Battlegroups", CivilizationInfo.id));
            BattlegroupInfo = Database.Session.Query <DB_civilization_battlegroups>().Where(x => x.id == CivilizationInfo.battlegroup_id).First();
        }
Beispiel #2
0
        public ActionResult New(BattlegroupForm form)
        {
            Debug.WriteLine($"POST: Battlegroup Ship Controller: New");
            DB_users user = Auth.User;
            var      game = GameState.Game;

            var civilization = game.GetCivilization(form.CivilizationID.Value);

            if (!civilization.PlayerOwnsCivilization(user.id) && !RequireGMAdminAttribute.IsGMOrAdmin())
            {
                return(RedirectToRoute("game", new { gameID = game.Info.id }));
            }

            var system = game.Sector.StarsystemFromHex(form.HexX, form.HexY);

            if (system != null && system.Info.game_id != game.Info.id)
            {
                return(RedirectToRoute("game", new { gameID = game.Info.id }));
            }

            // Create the Battlegroup and save it to the DB
            DB_civilization_battlegroups battlegroup = new DB_civilization_battlegroups();

            battlegroup.game_id         = game.ID;
            battlegroup.civilization_id = civilization.ID;
            battlegroup.starsystem_id   = system.ID;
            battlegroup.name            = form.Name;
            battlegroup.gmnotes         = form.GMNotes;
            Database.Session.Save(battlegroup);

            // Add in all the checked Ships
            foreach (var unitCheckbox in form.UnassignedUnits)
            {
                if (unitCheckbox.IsChecked)
                {
                    var ship = FindCivilizationUnit(unitCheckbox.ID);
                    ship.CivilizationInfo.battlegroup_id = battlegroup.id;
                    Database.Session.Update(ship.CivilizationInfo);
                }
            }

            Database.Session.Flush();
            return(RedirectToRoute("ViewCivilization", new { civilizationID = form.CivilizationID.Value }));
        }
 public Battlegroup(DB_civilization_battlegroups info, Civilization owner)
 {
     Info  = info;
     Owner = owner;
     Units = new List <CivilizationUnit>();
 }