示例#1
0
        public NewGameController(IEnumerable <TracableStream> staticDataSources)
        {
            foreach (var aiFactory in PlayerAssets.AIDefinitions.Values)
            {
                aiPlayers.Add(new PlayerType(PlayerControlType.LocalAI, aiFactory));
            }

            //TODO(v0.8) move to controller user
            players.Add(new NewGamePlayerInfo("Marko Kovač",
                                              colors.Take(),
                                              null,
                                              localHuman));

            players.Add(new NewGamePlayerInfo(generateAiName(),
                                              colors.Take(),
                                              null,
                                              aiPlayers.Pick()));

            this.Statics   = StaticsDB.Load(staticDataSources);
            this.evaluator = new SystemEvaluator(this.Statics);
            foreach (var populator in MapAssets.StarPopulators)
            {
                populator.SetGameData(
                    this.Statics.StarTraits,
                    this.Statics.PlanetTraits,
                    this.Statics.PlanetForumlas.ToDictionary(x => x.Key, x => x.Value.ImplicitTraits)
                    );
            }

            this.CustomStart    = LastStartingCondition ?? DefaultStartingCondition;
            this.StarPositioner = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPositionerConfig, MapAssets.StarPositioners);
            this.StarConnector  = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarConnectorConfig, MapAssets.StarConnectors);
            this.StarPopulator  = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPopulatorConfig, MapAssets.StarPopulators);
        }
示例#2
0
        public NewGameController(IEnumerable <NamedStream> staticDataSources)
        {
            foreach (var aiFactory in PlayerAssets.AIDefinitions.Values)
            {
                aiPlayers.Add(new PlayerType(PlayerControlType.LocalAI, aiFactory));
            }

            //TODO(v0.9) move to controller user
            this.players.AddRange(
                Settings.Get.LastGame.PlayersConfig != null && Settings.Get.LastGame.PlayersConfig.Length > 1 ?
                loadPlayerSetup(Settings.Get.LastGame.PlayersConfig) :
                this.defaultPlayerSetup()
                );
            this.Statics   = StaticsDB.Load(staticDataSources);
            this.evaluator = new SystemEvaluator(this.Statics);
            foreach (var populator in MapAssets.StarPopulators)
            {
                populator.SetGameData(
                    this.Statics.StarTraits,
                    this.Statics.PlanetTraits,
                    this.Statics.PlanetForumlas.ToDictionary(x => x.Key, x => x.Value.ImplicitTraits)
                    );
            }

            this.CustomStart    = LastStartingCondition ?? DefaultStartingCondition;
            this.StarPositioner = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPositionerConfig, MapAssets.StarPositioners);
            this.StarConnector  = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarConnectorConfig, MapAssets.StarConnectors);
            this.StarPopulator  = ParameterLoadingVisitor.Load(Settings.Get.LastGame.StarPopulatorConfig, MapAssets.StarPopulators);
        }
示例#3
0
        public void CalculateResearch(StaticsDB statics, StatesDB states, IList <ColonyProcessor> colonyProcessors)
        {
            var techLevels = states.DevelopmentAdvances.Of[Player].ToDictionary(x => x.Topic.IdCode, x => (double)x.Level);

            var    advanceOrder = this.ResearchOrder(states.ResearchAdvances).ToList();
            string focused      = Player.Orders.ResearchFocus;

            if (advanceOrder.Count > 0 && advanceOrder.All(x => x.Topic.IdCode != focused))
            {
                focused = advanceOrder[0].Topic.IdCode;
            }

            double focusWeight = statics.PlayerFormulas.FocusedResearchWeight;
            var    results     = new List <ResearchResult>();

            for (int i = 0; i < advanceOrder.Count; i++)
            {
                double weight = advanceOrder[i].Topic.IdCode == focused ? focusWeight : 1;
                weight /= advanceOrder.Count + focusWeight - 1;

                results.Add(advanceOrder[i].SimulateInvestment(weight));
            }

            this.ResearchPlan = results;
        }
示例#4
0
        private void advanceTechnologies(StatesDB states, StaticsDB statics)
        {
            foreach (var techProgress in this.DevelopmentPlan)
            {
                techProgress.Item.Progress(techProgress);
                if (techProgress.CompletedCount > 0)
                {
                    states.Reports.Add(new DevelopmentReport(techProgress));
                }
            }
            foreach (var techProgress in this.ResearchPlan)
            {
                techProgress.Item.Progress(techProgress);
                if (techProgress.CompletedCount > 0)
                {
                    states.Reports.Add(new ResearchReport(techProgress));
                }
            }
            this.Calculate(states.DevelopmentAdvances.Of[Player]);

            var researchLevels = states.ResearchAdvances.Of[Player].ToDictionary(x => x.Topic.IdCode, x => (double)x.Level);
            var validTechs     = new HashSet <string>(
                states.DevelopmentAdvances
                .Where(x => x.CanProgress(researchLevels, statics))
                .Select(x => x.Topic.IdCode)
                );

            Player.Orders.DevelopmentQueue = updateTechQueue(Player.Orders.DevelopmentQueue, validTechs);
        }
        private void makeDesign(StaticsDB statics, StatesDB states, string id, PredefinedDesign designData, PlayerProcessor playerProc)
        {
            var design = states.Designs.FirstOrDefault(x => x.IdCode == id);

            if (design == null)
            {
                var armor    = new Component <ArmorType>(statics.Armors[designData.Armor.IdCode], designData.Armor.Level);
                var hull     = new Component <HullType>(statics.Hulls[designData.Hull.IdCode], designData.Hull.Level);
                var reactor  = new Component <ReactorType>(statics.Reactors[designData.Reactor.IdCode], designData.Reactor.Level);
                var sensor   = new Component <SensorType>(statics.Sensors[designData.Sensors.IdCode], designData.Sensors.Level);
                var thruster = new Component <ThrusterType>(statics.Thrusters[designData.Thrusters.IdCode], designData.Thrusters.Level);

                var isDrive   = designData.IsDrive != null ? new Component <IsDriveType>(statics.IsDrives[designData.IsDrive.IdCode], designData.IsDrive.Level) : null;
                var shield    = designData.Shield != null ? new Component <ShieldType>(statics.Shields[designData.Shield.IdCode], designData.Shield.Level) : null;
                var equipment = designData.MissionEquipment.Select(
                    x => new Component <MissionEquipmentType>(statics.MissionEquipment[x.IdCode], x.Level, x.Amount)
                    ).ToList();
                var specials = designData.SpecialEquipment.Select(
                    x => new Component <SpecialEquipmentType>(statics.SpecialEquipment[x.IdCode], x.Level, x.Amount)
                    ).ToList();

                design = new Design(
                    id, playerProc.Player, false, designData.Name, designData.HullImageIndex, designData.UsesFuel,
                    armor, hull, isDrive, reactor, sensor, thruster, shield, equipment, specials
                    );

                design.CalcHash(statics);
                states.Designs.Add(design);
            }

            playerProc.Analyze(design, statics);
        }
示例#6
0
        private static TemporaryDB initDerivates(StaticsDB statics, Player[] players, Player organellePlayer, StatesDB states)
        {
            var derivates = new TemporaryDB(players, organellePlayer, statics.DevelopmentTopics);

            foreach (var colony in states.Colonies)
            {
                var colonyProc = new ColonyProcessor(colony);
                colonyProc.CalculateBaseEffects(statics, derivates.Players.Of[colony.Owner]);
                derivates.Colonies.Add(colonyProc);
            }

            foreach (var stellaris in states.Stellarises)
            {
                var stellarisProc = new StellarisProcessor(stellaris);
                stellarisProc.CalculateBaseEffects();
                derivates.Stellarises.Add(stellarisProc);
            }

            foreach (var player in players)
            {
                var playerProc = derivates.Players.Of[player];
                playerProc.Initialize(statics, states);

                foreach (var design in states.Designs.OwnedBy[player])
                {
                    playerProc.Analyze(design, statics);
                }
            }

            derivates.Natives.Initialize(states, statics, derivates);

            return(derivates);
        }
示例#7
0
        private static void initColonies(Player[] players, ColonyCollection colonies, StartingConditions startingConditions,
                                         TemporaryDB derivates, StaticsDB statics)
        {
            foreach (Colony colony in colonies)
            {
                var colonyProc = new ColonyProcessor(colony);

                colonyProc.CalculateBaseEffects(statics, derivates.Players.Of[colony.Owner]);
                derivates.Colonies.Add(colonyProc);
            }

            foreach (Player player in players)
            {
                var weights = new ChoiceWeights <Colony>();

                foreach (Colony colony in colonies.OwnedBy[player])
                {
                    weights.Add(colony, derivates.Colonies.Of[colony].Desirability);
                }

                var    maxPopulation       = colonies.OwnedBy[player].Sum(x => derivates.Colonies.Of[x].MaxPopulation);
                double totalPopulation     = Math.Min(startingConditions.Population, maxPopulation);
                double totalInfrastructure = Math.Min(startingConditions.Infrastructure, maxPopulation);

                foreach (var colony in colonies.OwnedBy[player])
                {
                    colony.Population = weights.Relative(colony) * totalPopulation;
                    derivates.Colonies.Of[colony].CalculateBaseEffects(statics, derivates.Players.Of[player]);
                }
            }
        }
示例#8
0
        public Design DesignUpgrade(Design oldDesign, StaticsDB statics, StatesDB states)
        {
            var techLevels = states.DevelopmentAdvances.Of[Player].ToDictionary(x => x.Topic.IdCode, x => (double)x.Level);

            var hull     = statics.Hulls[oldDesign.Hull.TypeInfo.IdCode].MakeHull(techLevels);
            var specials = oldDesign.SpecialEquipment.Select(
                x => statics.SpecialEquipment[x.TypeInfo.IdCode].MakeBest(techLevels, x.Quantity)
                ).ToList();

            var armor   = AComponentType.MakeBest(statics.Armors.Values, techLevels);
            var reactor = ReactorType.MakeBest(techLevels, hull, specials, statics);
            var isDrive = oldDesign.IsDrive != null?IsDriveType.MakeBest(techLevels, hull, reactor, specials, statics) : null;

            var sensor    = AComponentType.MakeBest(statics.Sensors.Values, techLevels);
            var shield    = oldDesign.Shield != null ? statics.Shields[oldDesign.Shield.TypeInfo.IdCode].MakeBest(techLevels) : null;
            var equipment = oldDesign.MissionEquipment.Select(
                x => statics.MissionEquipment[x.TypeInfo.IdCode].MakeBest(techLevels, x.Quantity)
                ).ToList();

            var thruster = AComponentType.MakeBest(statics.Thrusters.Values, techLevels);

            var design = new Design(
                states.MakeDesignId(), Player, false, oldDesign.IsVirtual, oldDesign.Name, oldDesign.ImageIndex,
                armor, hull, isDrive, reactor, sensor, shield, equipment, specials, thruster
                );

            design.CalcHash(statics);

            return(design);
        }
示例#9
0
        public static MainGame LoadGame(IkonComposite saveData, IEnumerable <TracableStream> staticDataSources)
        {
            var statics = StaticsDB.Load(staticDataSources);

            var deindexer = new ObjectDeindexer();
            int turn      = saveData[MainGame.TurnKey].To <int>();

            deindexer.AddAll(statics.Constructables, x => x.IdCode);
            deindexer.AddAll(statics.DevelopmentTopics, x => x.IdCode);
            deindexer.AddAll(statics.PredeginedDesigns);
            deindexer.AddAll(statics.ResearchTopics, x => x.IdCode);
            deindexer.AddAll(statics.Armors.Values, x => x.IdCode);
            deindexer.AddAll(statics.Hulls.Values, x => x.IdCode);
            deindexer.AddAll(statics.IsDrives.Values, x => x.IdCode);
            deindexer.AddAll(statics.MissionEquipment.Values, x => x.IdCode);
            deindexer.AddAll(statics.Reactors.Values, x => x.IdCode);
            deindexer.AddAll(statics.Sensors.Values, x => x.IdCode);
            deindexer.AddAll(statics.Shields.Values, x => x.IdCode);
            deindexer.AddAll(statics.SpecialEquipment.Values, x => x.IdCode);
            deindexer.AddAll(statics.Thrusters.Values, x => x.IdCode);
            deindexer.AddAll(statics.Traits.Values, x => x.IdCode);

            var loadedStates    = loadSaveData(saveData, deindexer, statics);
            var states          = loadedStates.Item1;
            var players         = loadedStates.Item2;
            var organellePlayer = loadedStates.Item3;
            var derivates       = initDerivates(statics, players, organellePlayer, states);

            var game = new MainGame(players.ToArray(), organellePlayer, statics, states, derivates);

            game.CalculateDerivedEffects();

            return(game);
        }
示例#10
0
        private Design makeDesign(StaticsDB statics, StatesDB states, PredefinedDesign predefDesign, Dictionary <string, double> techLevels, bool isVirtual)
        {
            var hull     = statics.Hulls[predefDesign.HullCode].MakeHull(techLevels);
            var specials = predefDesign.SpecialEquipment.OrderBy(x => x.Key).Select(
                x => statics.SpecialEquipment[x.Key].MakeBest(techLevels, x.Value)
                ).ToList();

            var armor     = AComponentType.MakeBest(statics.Armors.Values, techLevels);
            var reactor   = ReactorType.MakeBest(techLevels, hull, specials, statics);
            var isDrive   = predefDesign.HasIsDrive ? IsDriveType.MakeBest(techLevels, hull, reactor, specials, statics) : null;
            var sensor    = AComponentType.MakeBest(statics.Sensors.Values, techLevels);
            var shield    = predefDesign.ShieldCode != null ? statics.Shields[predefDesign.ShieldCode].MakeBest(techLevels) : null;
            var equipment = predefDesign.MissionEquipment.Select(
                x => statics.MissionEquipment[x.Key].MakeBest(techLevels, x.Value)
                ).ToList();

            var thruster = AComponentType.MakeBest(statics.Thrusters.Values, techLevels);

            var design = new Design(
                states.MakeDesignId(), Player, false, isVirtual, predefDesign.Name, predefDesign.HullImageIndex,
                armor, hull, isDrive, reactor, sensor, shield, equipment, specials, thruster
                );

            design.CalcHash(statics);

            if (!states.Designs.Contains(design))
            {
                states.Designs.Add(design);
                this.Analyze(design, statics);
                return(design);
            }

            return(states.Designs.First(x => x == design));
        }
示例#11
0
        public void CalculateBaseEffects(StaticsDB statics, PlayerProcessor playerProcessor)
        {
            var vars     = calcVars(statics, playerProcessor);
            var formulas = statics.ColonyFormulas;

            this.Environment     = formulas.EnvironmentFactor.Evaluate(vars);
            this.MaxPopulation   = formulas.MaxPopulation.Evaluate(vars);
            this.Organization    = formulas.Organization.Evaluate(vars);
            this.SpaceliftFactor = formulas.SpaceliftFactor.Evaluate(vars);

            this.FarmerEfficiency   = formulas.Farming.Evaluate(this.Organization, vars);
            this.GardenerEfficiency = formulas.Gardening.Evaluate(this.Organization, vars);
            this.MinerEfficiency    = formulas.Mining.Evaluate(this.Organization, vars);

            var minersPerIndustry = 1 / this.MinerEfficiency;

            this.BuilderEfficiency   = formulas.Industry.Evaluate(this.Organization, vars) / (1 + minersPerIndustry);
            this.ScientistEfficiency = formulas.Development.Evaluate(this.Organization, vars);

            this.Farmers   = this.Colony.Population / this.FarmerEfficiency;
            this.Gardeners = 0;

            var farmFields = formulas.FarmFields.Evaluate(vars);

            if (this.Farmers > farmFields)
            {
                this.Gardeners = (this.Colony.Population - this.FarmerEfficiency * farmFields) / this.GardenerEfficiency;
                this.Farmers   = farmFields + this.Gardeners;
            }

            this.WorkingPopulation = this.Colony.Population - this.Farmers;
            this.RepairPoints      = formulas.RepairPoints.Evaluate(vars);
        }
示例#12
0
        public void InitialApply(StaticsDB statics, StarData star, IEnumerable <Planet> planets)
        {
            this.pullAfflictions();
            var vars = new Var().
                       Init(statics.StarTraits.Keys, false).
                       Init(statics.PlanetTraits.Keys, false).
                       UnionWith(star.Traits.Select(x => x.Type.IdCode));

            foreach (var affliction in this.afflictions)
            {
                var trait = statics.PlanetTraits[affliction.TraitId];

                foreach (var planet in planets)
                {
                    vars.UnionWith(planet.Traits.Select(x => x.IdCode));
                    vars.Set("position", planet.Position);
                    planet.Traits.RemoveWhere(x => x.IdCode == trait.IdCode);

                    if (affliction.Condition.Evaluate(vars.Get) >= 0)
                    {
                        planet.Traits.Add(trait);
                    }
                }
            }
        }
示例#13
0
        private void makeDesign(StaticsDB statics, StatesDB states, DesignTemplate predefDesign, Dictionary <string, double> techLevels)
        {
            var hull     = statics.Hulls[predefDesign.HullCode].MakeHull(techLevels);
            var specials = predefDesign.SpecialEquipment.OrderBy(x => x.Key).Select(
                x => statics.SpecialEquipment[x.Key].MakeBest(techLevels, x.Value)
                ).ToList();
            var equipment = predefDesign.MissionEquipment.Select(
                x => statics.MissionEquipment[x.Key].MakeBest(techLevels, x.Value)
                ).ToList();

            var armor   = AComponentType.MakeBest(statics.Armors.Values, techLevels);
            var reactor = ReactorType.MakeBest(techLevels, hull, specials, equipment, statics);
            var isDrive = predefDesign.HasIsDrive ? IsDriveType.MakeBest(techLevels, hull, reactor, specials, equipment, statics) : null;
            var sensor  = AComponentType.MakeBest(statics.Sensors.Values, techLevels);
            var shield  = predefDesign.ShieldCode != null ? statics.Shields[predefDesign.ShieldCode].MakeBest(techLevels) : null;

            var thruster = AComponentType.MakeBest(statics.Thrusters.Values, techLevels);

            var design = new Design(
                this.Player, predefDesign.Name, predefDesign.HullImageIndex, true,
                armor, hull, isDrive, reactor, sensor, thruster, shield, equipment, specials
                );

            if (!states.Designs.Contains(design))
            {
                states.Designs.Add(design);
                this.Analyze(design, statics);
            }
        }
示例#14
0
        public void CalculateDevelopment(StaticsDB statics, StatesDB states, IList <ColonyProcessor> colonyProcessors)
        {
            double developmentPoints = 0;

            foreach (var colonyProc in colonyProcessors)
            {
                developmentPoints += colonyProc.Development;
            }

            var focus        = statics.DevelopmentFocusOptions[Player.Orders.DevelopmentFocusIndex];
            var techLevels   = states.DevelopmentAdvances.Of[Player].ToDictionary(x => x.Topic.IdCode, x => (double)x.Level);
            var advanceOrder = this.DevelopmentOrder(states.DevelopmentAdvances, states.ResearchAdvances, statics).ToList();

            var results = new List <DevelopmentResult>();

            for (int i = 0; i < advanceOrder.Count && i < focus.Weights.Length; i++)
            {
                results.Add(advanceOrder[i].SimulateInvestment(
                                developmentPoints * focus.Weights[i],
                                techLevels
                                ));
            }

            this.DevelopmentPlan = results;
        }
示例#15
0
        public bool CanProgress(Dictionary <string, double> researchLevels, StaticsDB statics)
        {
            var requirement = statics.DevelopmentRequirements.ContainsKey(this.Topic.IdCode) ?
                              statics.DevelopmentRequirements[this.Topic.IdCode] :
                              null;

            return(Level < Topic.MaxLevel && (requirement == null || researchLevels[requirement.Code] >= requirement.Level));
        }
示例#16
0
 public void ProcessPostcombat(StaticsDB statics, StatesDB states, TemporaryDB derivates)
 {
     this.advanceTechnologies(states, statics);
     this.checkColonizationValidity(states);
     this.doConstruction(statics, states, derivates);
     this.unlockPredefinedDesigns(statics, states);
     this.updateDesigns(statics, states, derivates);
 }
示例#17
0
        internal CombatantInfo(Combatant data, MainGame game, IEnumerable <Vector2D> validMoves)
        {
            this.Data       = data;
            this.stats      = game.Derivates[data.Owner].DesignStats[data.Ships.Design];
            this.statics    = game.Statics;
            this.validMoves = validMoves.ToList();

            this.abilities = new List <AbilityInfo>(this.stats.Abilities.Select((x, i) => new AbilityInfo(x, i, data.AbilityCharges[i])));
        }
示例#18
0
        public void PostcombatApply(StaticsDB statics, StarData star, IEnumerable <Planet> planets)
        {
            if (this.Duration <= 0)
            {
                star.Traits.PendRemove(this);
                return;
            }

            this.Duration--;
        }
示例#19
0
        internal FleetInfo(Fleet fleet, PlayerProcessor playerProc, StaticsDB statics)
        {
            this.FleetData  = fleet;
            this.playerProc = playerProc;
            this.statics    = statics;

            this.Missions = MissionInfoFactory.Create(fleet);
            this.Owner    = new PlayerInfo(fleet.Owner);
            this.Position = fleet.Position;
        }
示例#20
0
        public override Var LocalEffects(StaticsDB statics)
        {
            var vars = base.LocalEffects(statics);

            vars.And(PlanetSizeKey, Colony.Location.Planet.Size);
            vars.And(MaxPopulationKey, MaxPopulation);
            vars.And(PopulationKey, Colony.Population);

            return(vars);
        }
        public void ProcessPrecombat(StaticsDB statics, StatesDB states, TemporaryDB derivates)
        {
            var catalizers = states.Fleets.OwnedBy[this.OrganellePlayer].SelectMany(x => x.Ships).Where(x => x.Design.IdCode == CatalyzerId).Sum(x => x.Quantity);

            if (catalizers < MaxCatalyzers)
            {
                var nativeDesign = states.Designs.OwnedBy[this.OrganellePlayer].First(x => x.IdCode == CatalyzerId);
                derivates[this.OrganellePlayer].SpawnShip(states.StareaterBrain, nativeDesign, 1, 0, new AMission[0], states);
            }
        }
        public override Var LocalEffects(StaticsDB statics)
        {
            var vars = base.LocalEffects(statics);

            vars.And(PlanetSizeKey, Colony.Location.Planet.Size);
            vars.And(MaxPopulationKey, MaxPopulation);
            vars.And(PopulationKey, Colony.Population);
            vars.Init(statics.PlanetTraits.Keys, false);
            vars.UnionWith(this.Colony.Location.Planet.Traits.Select(x => x.IdCode));

            return(vars);
        }
示例#23
0
        public static Var DesignPoweredVars(
            Component <HullType> hull, Component <ReactorType> reactor,
            IEnumerable <Component <MissionEquipmentType> > missionEquipment, IEnumerable <Component <SpecialEquipmentType> > specialEquipment,
            StaticsDB statics)
        {
            var shipVars = DesignBaseVars(hull, missionEquipment, specialEquipment, statics);

            shipVars[AComponentType.LevelKey]   = reactor.Level;
            shipVars[ReactorType.SizeKey]       = statics.ShipFormulas.ReactorSize.Evaluate(shipVars.Get);
            shipVars[ReactorType.TotalPowerKey] = reactor.TypeInfo.Power.Evaluate(shipVars.Get);

            return(shipVars);
        }
示例#24
0
        private void calcRefitCosts(Design design, StaticsDB statics)
        {
            this.RefitCosts[design] = new Dictionary <Design, double>();

            var otherDesigns = this.DesignStats.Keys.Where(x => x.Hull.TypeInfo == design.Hull.TypeInfo && x != design).ToList();
            var designStats  = this.DesignStats[design];

            foreach (var otherDesign in otherDesigns)
            {
                this.RefitCosts[design][otherDesign] = refitCost(design, otherDesign, this.DesignStats[otherDesign], statics);
                this.RefitCosts[otherDesign][design] = refitCost(otherDesign, design, designStats, statics);
            }
        }
示例#25
0
        private IDictionary <string, double> calcVars(StaticsDB statics, PlayerProcessor playerProcessor)
        {
            var vars = base.LocalEffects(statics).
                       And(PlanetSizeKey, Colony.Location.Planet.Size).
                       And(PopulationKey, Colony.Population).
                       UnionWith(playerProcessor.TechLevels).
                       Init(statics.Traits.Keys, false).
                       UnionWith(Colony.Location.Planet.Traits, x => x.Type.IdCode, x => 1);

            vars.Init(statics.Constructables.Where(x => x.ConstructableAt == SiteType.Colony).Select(x => x.IdCode.ToLower() + NewBuidingPrefix), false);

            return(vars.Get);
        }
示例#26
0
        public MainGame(Player[] players, Player organellePlayer, StaticsDB statics, StatesDB states, TemporaryDB derivates)
        {
            this.Turn = 0;

            this.StareaterOrganelles = organellePlayer;
            this.MainPlayers         = players;
            this.IsReadOnly          = false;
            this.Statics             = statics;
            this.States    = states;
            this.Derivates = derivates;

            this.Processor = new GameProcessor(this);
        }
示例#27
0
        public static MainGame CreateGame(Random rng, Player[] players, Player organellePlayer, NewGameController controller, IEnumerable <TracableStream> staticDataSources)
        {
            var statics   = StaticsDB.Load(staticDataSources);
            var states    = createStates(rng, controller, players, statics);
            var derivates = createDerivates(players, organellePlayer, controller.SelectedStart, statics, states);

            var game = new MainGame(players, organellePlayer, statics, states, derivates);

            game.CalculateDerivedEffects();

            controller.SaveLastGame();
            return(game);
        }
        public void Initialize(StatesDB states, StaticsDB statics, TemporaryDB derivates)
        {
            this.OrganellePlayer.Intelligence.Initialize(states);
            foreach (var star in states.Stars)
            {
                this.OrganellePlayer.Intelligence.StarFullyVisited(star, 0);
            }

            foreach (var designData in statics.NativeDesigns)
            {
                makeDesign(statics, states, designData.Key, designData.Value, derivates[this.OrganellePlayer]);
            }
        }
        public void CalculateBaseEffects(StaticsDB statics, PlayerProcessor playerProcessor)
        {
            var vars          = calcVars(statics, playerProcessor);
            var formulas      = statics.ColonyFormulas;
            var planetEffects = statics.PlanetForumlas[this.Colony.Location.Planet.Type];

            this.Environment     = formulas.EnvironmentFactor.Evaluate(vars);
            this.MaxPopulation   = formulas.MaxPopulation.Evaluate(vars);
            this.Organization    = formulas.Organization.Evaluate(vars);
            this.SpaceliftFactor = formulas.SpaceliftFactor.Evaluate(vars);

            this.FarmerEfficiency   = formulas.Farming.Evaluate(this.Organization, vars);
            this.GardenerEfficiency = formulas.Gardening.Evaluate(this.Organization, vars);
            this.MinerEfficiency    = formulas.Mining.Evaluate(this.Organization, vars);

            var minersPerIndustry = 1 / this.MinerEfficiency;

            this.BuilderEfficiency   = formulas.Industry.Evaluate(this.Organization, vars) / (1 + minersPerIndustry);
            this.ScientistEfficiency = formulas.Development.Evaluate(this.Organization, vars);

            this.Farmers   = this.Colony.Population / this.FarmerEfficiency;
            this.Gardeners = 0;

            var farmFields = formulas.FarmFields.Evaluate(vars);

            if (this.Farmers > farmFields)
            {
                this.Gardeners = (this.Colony.Population - this.FarmerEfficiency * farmFields) / this.GardenerEfficiency;
                this.Farmers   = farmFields + this.Gardeners;
            }

            this.WorkingPopulation = this.Colony.Population - this.Farmers;
            this.RepairPoints      = formulas.RepairPoints.Evaluate(vars);

            this.MaintenancePerPop = this.Colony.Location.Planet.Traits.
                                     Concat(planetEffects.ImplicitTraits.Select(x => statics.PlanetTraits[x])).
                                     Sum(x => x.MaintenanceCost.Evaluate(vars));
            this.MaintenanceCost    = this.Colony.Population * this.MaintenancePerPop;
            this.MaintenanceLimit   = this.WorkingPopulation * this.BuilderEfficiency * this.SpaceliftFactor;
            this.MaintenancePenalty = 0;

            vars[MaintenancePenaltyKey] = this.MaintenancePenalty;
            this.PopulationGrowth       = formulas.PopulationGrowth.Evaluate(vars);

            vars[MaxPopulationKey] = this.MaxPopulation;
            this.Desirability      = formulas.Desirability.Evaluate(vars);
            this.Emigrants         = formulas.Emigrants.Evaluate(vars);
            this.FuelProduction    = formulas.FuelProduction.Evaluate(vars);
        }
示例#30
0
        public void CalculateDerivedEffects(StaticsDB statics, PlayerProcessor playerProcessor)
        {
            var vars     = calcVars(statics, playerProcessor);
            var formulas = statics.ColonyFormulas;

            foreach (var construction in SpendingPlan)
            {
                if (construction.CompletedCount > 0)
                {
                    vars[construction.Type.IdCode.ToLower() + NewBuidingPrefix] = construction.CompletedCount;
                }
            }

            this.PopulationGrowth = formulas.PopulationGrowth.Evaluate(vars);
        }