Example #1
0
        public static void ProcessTurn(int count)
        {
            for (var i = 0; i < count; i++)
            {
                using (var t = new TransactionScope()) {
                    var db = new DbDataContext();

                    var config = db.GetConfig();
                    config.CombatTurn++;

                    FleetLogic.ProcessTransitTurn(db);

                    foreach (var o in db.CelestialObjects)
                    {
                        o.UpdateIncomeInfo();
                    }

                    foreach (var player in db.Players.Where(x => x.IsActive))
                    {
                        if (config.CombatTurn % config.PopulationTick == 0)
                        {
                            player.ApplyPopulationTick(config.CombatTurn);
                        }
                        player.ApplyResourceTurn(config.CombatTurn);
                    }

                    db.MarkDirty();

                    config.TurnStarted = DateTime.UtcNow;                     // todo synchronize properly when not faking
                    db.SubmitChanges();
                    t.Complete();
                }
            }
        }
Example #2
0
        public static StarMap GetMapData(string playerName, string password)
        {
            var db = new DbDataContext();

            var ret = new StarMap();

            var lo = new DataLoadOptions();

            lo.LoadWith <CelestialObject>(x => x.CelestialObjectShips);            // todo stealth also in all fleet structures
            lo.LoadWith <CelestialObject>(x => x.CelestialObjectStructures);
            db.LoadOptions       = lo;
            ret.CelestialObjects = db.CelestialObjects.ToList();

            ret.Players = db.Players.Where(x => x.IsActive).ToList();

            ret.StarSystems = db.StarSystems.ToList();

            ret.Transits = FleetLogic.GetTransits(playerName, password);

            ret.Config = db.GetConfig();

            ret.ObjectLinks = db.CelestialObjectLinks.ToList();

            return(ret);
        }