Esempio n. 1
0
        private void StartNextTurn()
        {
            TurnNumber++;

            if (TurnNumber % 2 == 0)
            {
                Power.CalculatePowerRatings(this);
            }

            ProcessBarbarians();

            ChoseNextCiv();
        }
Esempio n. 2
0
        private Game(Map[] maps, Rules configRules, IList <Civilization> civilizations, Options options,
                     string[] gamePaths, DifficultyType difficulty, IPlayer localPlayer)
        {
            Script           = new ScriptEngine(localPlayer.UI, this, gamePaths);
            _options         = options;
            _maps            = maps;
            _rules           = configRules;
            TurnNumber       = 0;
            _difficultyLevel = difficulty;

            AllCivilizations.AddRange(civilizations);

            CityNames = NameLoader.LoadCityNames(gamePaths);

            Players = civilizations.Select(c =>
            {
                var player = c.PlayerType switch
                {
                    PlayerType.AI => new AIPlayer(_difficultyLevel),
                    PlayerType.Local => localPlayer,
                    PlayerType.Remote => throw new NotSupportedException("Network play not implemented"),
                    PlayerType.Barbarians =>
                    //TODO: create seperate barbarian player
                    new AIPlayer(_difficultyLevel),
                    _ => throw new ArgumentOutOfRangeException(nameof(c.PlayerType), c.PlayerType, null)
                };
                return(player.SetCiv(c));
            }).ToArray();

            TerrainImprovements = TerrainImprovementFunctions.GetStandardImprovements(Rules);

            Script.RunScript("tile_improvements.lua");



            Script.RunScript("improvements.lua");
            Script.RunScript("advances.lua");

            AllCivilizations.ForEach((civ) =>
            {
                OnCivEvent?.Invoke(this, new CivEventArgs(CivEventType.Created, civ));
            });


            this.SetupTech();

            Power.CalculatePowerRatings(this);
        }