예제 #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="defensePoints">The <see cref="UnitPivot.DefensePoints"/> value.</param>
 /// <param name="offensePoints">The <see cref="UnitPivot.OffensePoints"/> value.</param>
 /// <param name="speed">The <see cref="UnitPivot.Speed"/> value.</param>
 /// <param name="productivityCost">The <see cref="BuildablePivot.ProductivityCost"/> value.</param>
 /// <param name="advancePrerequisite">The <see cref="BuildablePivot.AdvancePrerequisite"/> value.</param>
 /// <param name="advanceObsolescence">The <see cref="BuildablePivot.AdvanceObsolescence"/> value.</param>
 /// <param name="purchasePrice">The <see cref="BuildablePivot.PurchasePrice"/> value.</param>
 /// <param name="name">The <see cref="BuildablePivot.Name"/> value.</param>
 /// <param name="citizenCostToProduce">The <see cref="UnitPivot.CitizenCostToProduce"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="ignoreControlZone">Optional; the <see cref="UnitPivot.IgnoreControlZone"/> value.</param>
 /// <param name="ignoreCityWalls">Optional; the <see cref="UnitPivot.IgnoreCityWalls"/> value.</param>
 /// <param name="maintenanceCost">Optional; the <see cref="UnitPivot.MaintenanceCost"/> value.</param>
 protected LandUnitPivot(CityPivot city, int offensePoints, int defensePoints, int speed, int productivityCost,
                         AdvancePivot advancePrerequisite, AdvancePivot advanceObsolescence, int purchasePrice, string name, int citizenCostToProduce,
                         MapSquarePivot location, PlayerPivot player, bool ignoreControlZone = false, bool ignoreCityWalls = false, int maintenanceCost = 1) :
     base(city, offensePoints, defensePoints, speed, productivityCost, advancePrerequisite, advanceObsolescence,
          purchasePrice, name, citizenCostToProduce, location, player, ignoreControlZone, ignoreCityWalls, 1, maintenanceCost)
 {
 }
예제 #2
0
        private Tuple <uint, uint> DebugRankingForPlayer(uint id, uint playerId, string date)
        {
            if (!DateTime.TryParse(date, out DateTime realDateEnd))
            {
                throw new ArgumentException(Messages.InvalidInputDateException, nameof(date));
            }

            var rankingVersion = RankingVersionPivot.Get(id);

            if (rankingVersion == null)
            {
                throw new ArgumentException(Messages.RankingRulesetNotFoundException, nameof(id));
            }

            var player = PlayerPivot.Get(playerId);

            if (player == null)
            {
                return(null);
            }

            // Ensures monday.
            while (realDateEnd.DayOfWeek != DayOfWeek.Monday)
            {
                realDateEnd = realDateEnd.AddDays(1);
            }

            SqlMapper.LoadMatches((uint)(realDateEnd.Year - 1));
            SqlMapper.LoadMatches((uint)realDateEnd.Year);

            return(rankingVersion.DebugRankingForPlayer(player, realDateEnd));
        }
예제 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="player">The <see cref="Player"/> value.</param>
 /// <param name="rank">The <see cref="Rank"/> value.</param>
 /// <param name="uma">The <see cref="Uma"/> value.</param>
 /// <param name="initialPoints">The initial points.</param>
 internal PlayerScorePivot(PlayerPivot player, int rank, int uma, int initialPoints)
 {
     Player = player;
     Rank   = rank;
     Uma    = uma;
     Score  = ((player.Points - initialPoints) / 1000) + uma;
 }
예제 #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="defensePoints">The <see cref="UnitPivot.DefensePoints"/> value.</param>
 /// <param name="offensePoints">The <see cref="UnitPivot.OffensePoints"/> value.</param>
 /// <param name="speed">The <see cref="UnitPivot.Speed"/> value.</param>
 /// <param name="productivityCost">The <see cref="BuildablePivot.ProductivityCost"/> value.</param>
 /// <param name="advancePrerequisite">The <see cref="BuildablePivot.AdvancePrerequisite"/> value.</param>
 /// <param name="advanceObsolescence">The <see cref="BuildablePivot.AdvanceObsolescence"/> value.</param>
 /// <param name="purchasePrice">The <see cref="BuildablePivot.PurchasePrice"/> value.</param>
 /// <param name="name">The <see cref="BuildablePivot.Name"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="ignoreControlZone">Optional; the <see cref="UnitPivot.IgnoreControlZone"/> value.</param>
 /// <param name="ignoreCityWalls">Optional; the <see cref="UnitPivot.IgnoreCityWalls"/> value.</param>
 /// <param name="squareSight">Optional; the <see cref="UnitPivot.SquareSight"/> value.</param>
 /// <param name="transportCapacity">Optional; the <see cref="TransportCapacity"/> value.</param>
 /// <param name="canAttackCoastUnit">Optional; the <see cref="CanAttackCoastUnit"/> value.</param>
 /// <param name="maintenanceCost">The <see cref="UnitPivot.MaintenanceCost"/> value.</param>
 protected SeaUnitPivot(CityPivot city, int offensePoints, int defensePoints, int speed, int productivityCost,
                        AdvancePivot advancePrerequisite, AdvancePivot advanceObsolescence, int purchasePrice, string name, MapSquarePivot location,
                        PlayerPivot player, bool ignoreControlZone, bool ignoreCityWalls, int squareSight, int transportCapacity, bool canAttackCoastUnit, int maintenanceCost) :
     base(city, offensePoints, defensePoints, speed, productivityCost, advancePrerequisite, advanceObsolescence, purchasePrice, name, 0,
          location, player, ignoreControlZone, ignoreCityWalls, squareSight, maintenanceCost)
 {
     TransportCapacity  = transportCapacity;
     CanAttackCoastUnit = canAttackCoastUnit;
 }
예제 #5
0
        /// <summary>
        /// Creates a new instance from the current one.
        /// </summary>
        /// <param name="city">The <see cref="City"/> value.</param>
        /// <param name="location">The <see cref="MapSquareLocation"/> value; pertinent only if <paramref name="city"/> is <c>Null</c>.</param>
        /// <param name="player">The <see cref="Player"/> value; pertinent only if <paramref name="city"/> is <c>Null</c>.</param>
        /// <returns>A new <see cref="UnitPivot"/> from the current one.</returns>
        internal UnitPivot CreateInstance(CityPivot city, MapSquarePivot location, PlayerPivot player)
        {
            var method = GetType().GetMethod(
                "CreateAtLocation",
                BindingFlags.Static | BindingFlags.NonPublic,
                null,
                new[] { typeof(CityPivot), typeof(MapSquarePivot), typeof(PlayerPivot) },
                null);

            return((UnitPivot)method?.Invoke(null, new object[] { city, location, player }));
        }
예제 #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="mapSize">Map size.</param>
        /// <param name="mapShape">Map shape.</param>
        /// <param name="landCoverage">Map land coverage.</param>
        /// <param name="temperature">Map temperature.</param>
        /// <param name="age">Map age.</param>
        /// <param name="humidity">Map humidity.</param>
        /// <param name="playerCivilization">Human player civilization.</param>
        /// <param name="playerGender">The <see cref="PlayerPivot.Gender"/> value.</param>
        /// <param name="iaPlayersCount">Number of IA civilizations (except barbarians).</param>
        /// <param name="randomCityNames">Sets <c>True</c> to active random city names for the human player.</param>
        /// <exception cref="ArgumentNullException"><paramref name="playerCivilization"/> is <c>Null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="iaPlayersCount"/> invalid.</exception>
        public EnginePivot(SizePivot mapSize, LandShapePivot mapShape, LandCoveragePivot landCoverage, TemperaturePivot temperature,
                           AgePivot age, HumidityPivot humidity, CivilizationPivot playerCivilization,
                           bool playerGender, int iaPlayersCount, bool randomCityNames)
        {
            if (playerCivilization == null)
            {
                throw new ArgumentNullException(nameof(playerCivilization));
            }
            iaPlayersCount = iaPlayersCount < 0 ? 0 : iaPlayersCount;
            if (iaPlayersCount > CivilizationPivot.GetCivilizations(false).Count / (6 - (int)mapSize))
            {
                throw new ArgumentException("The IA players count is too high for this map size !", nameof(iaPlayersCount));
            }

            Map = new MapPivot(mapSize, mapShape, landCoverage, temperature, age, humidity);

            List <MapSquarePivot> excludedSpots = new List <MapSquarePivot>();

            HumanPlayer = new PlayerPivot(this, playerCivilization, false, GetRandomLocation(excludedSpots), playerGender, randomCityNames);

            var allCivs = CivilizationPivot.GetCivilizations(false);

            for (int i = 0; i < iaPlayersCount; i++)
            {
                CivilizationPivot iaCiv = null;
                do
                {
                    iaCiv = allCivs.ElementAt(Tools.Randomizer.Next(0, allCivs.Count));
                }while (HumanPlayer.Civilization == iaCiv || _opponentPlayers.Any(ia => ia.Civilization == iaCiv));
                _opponentPlayers.Add(new PlayerPivot(this, iaCiv, true, GetRandomLocation(excludedSpots), Tools.Randomizer.Next(0, 2) == 0, false));
            }

            BarbarianPlayer = new PlayerPivot(this, CivilizationPivot.Barbarian, true, null, false, true);

            // Sets war between every civilizations.
            for (int i = 0; i < Players.Count - 1; i++)
            {
                for (int j = i + 1; j < Players.Count; j++)
                {
                    Players.ElementAt(i).SwitchPeaceStatusWithOpponent(Players.ElementAt(j));
                }
            }

            CurrentTurn = 0;
        }
예제 #7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="player">The <see cref="Player"/> value.</param>
        /// <param name="currentTurn">The <see cref="CreationTurn"/> value.</param>
        /// <param name="name">The <see cref="Name"/> value.</param>
        /// <param name="location">The <see cref="MapSquareLocation"/> value.</param>
        /// <param name="production">The <see cref="Production"/> value.</param>
        internal CityPivot(PlayerPivot player, int currentTurn, string name, MapSquarePivot location, BuildablePivot production)
        {
            Player            = player;
            Name              = name;
            MapSquareLocation = location;
            CreationTurn      = currentTurn;
            Production        = production;

            _improvements = new List <CityImprovementPivot>();
            _wonders      = new List <WonderPivot>();

            _specialistCitizens = new List <CitizenPivot>();
            _areaMapSquares     = new List <CityAreaMapSquarePivot>
            {
                new CityAreaMapSquarePivot(this, MapSquareLocation)
            };
            _areaMapSquares.Add(new CityAreaMapSquarePivot(this, BestVacantMapSquareLocation()));

            location.ApplyCityActions();
        }
예제 #8
0
 private LegionPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 3, 1, 1, 20, AdvancePivot.IronWorking, AdvancePivot.Conscription, 120, null, 0, location, player)
 {
 }
예제 #9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="player">The <see cref="Player"/> value.</param>
 /// <param name="killer">The <see cref="Killer"/> value.</param>
 internal DeadPlayerEventArgs(PlayerPivot player, PlayerPivot killer)
 {
     Player = player;
     Killer = killer;
 }
예제 #10
0
 private KnightPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 4, 2, 2, 40, AdvancePivot.Chivalry, AdvancePivot.Automobile, 320, null, 0, location, player)
 {
 }
예제 #11
0
 private ArmorPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 10, 5, 3, 80, AdvancePivot.Automobile, null, 960, null, 0, location, player)
 {
 }
예제 #12
0
 /// <summary>
 /// Removes a defeated opponent.
 /// </summary>
 /// <param name="opponent">The opponent.</param>
 internal void RemoveOpponent(PlayerPivot opponent)
 {
     _opponentPlayers.Remove(opponent);
 }
예제 #13
0
 private CaravanPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 0, 1, 1, 50, AdvancePivot.Trade, null, 450, null, 0, location, player, ignoreControlZone: true, maintenanceCost: 0)
 {
 }
예제 #14
0
 private SubmarinePivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 8, 2, 3, 50, AdvancePivot.MassProduction, null, 450, null, location, player, false, false, 2, 0, false, 1)
 {
 }
예제 #15
0
 private MusketeerPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 2, 3, 1, 30, AdvancePivot.Gunpowder, AdvancePivot.Conscription, 210, null, 0, location, player)
 {
 }
예제 #16
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="CatapultPivot"/>.</returns>
 internal static CatapultPivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new CatapultPivot(city, location, player));
 }
예제 #17
0
 private FrigatePivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 2, 2, 3, 40, AdvancePivot.Magnetism, AdvancePivot.Industrialization, 320, null, location, player, false, false, 1, 4, true, 1)
 {
 }
예제 #18
0
 private CatapultPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 6, 1, 1, 40, AdvancePivot.Mathematics, AdvancePivot.Metallurgy, 320, null, 0, location, player)
 {
 }
예제 #19
0
 private CavalryPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 2, 1, 2, 20, AdvancePivot.HorsebackRiding, AdvancePivot.Conscription, 120, null, 0, location, player)
 {
 }
예제 #20
0
 private DiplomatPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 0, 0, 2, 30, AdvancePivot.Writing, null, 210, null, 0, location, player, ignoreControlZone: true, maintenanceCost: 0)
 {
 }
예제 #21
0
 private TransportPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 0, 3, 4, 50, AdvancePivot.Industrialization, null, 450, null, location, player, false, false, 1, 8, false, 1)
 {
 }
 // Makes the singleton equal to this script.
 private void Awake()
 {
     _PlayerPivot = this;
 }
예제 #23
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="TransportPivot"/>.</returns>
 internal static TransportPivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new TransportPivot(city, location, player));
 }
예제 #24
0
 private CarrierPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 1, 12, 5, 160, AdvancePivot.AdvancedFlight, null, 3200, null, location, player, false, false, 2, 8, false, 1)
 {
 }
예제 #25
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="MusketeerPivot"/>.</returns>
 internal static MusketeerPivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new MusketeerPivot(city, location, player));
 }
예제 #26
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="city">The <see cref="City"/> value.</param>
 /// <param name="defensePoints">The <see cref="DefensePoints"/> value.</param>
 /// <param name="offensePoints">The <see cref="OffensePoints"/> value.</param>
 /// <param name="speed">The <see cref="Speed"/> value.</param>
 /// <param name="productivityCost">The <see cref="BuildablePivot.ProductivityCost"/> value.</param>
 /// <param name="advancePrerequisite">The <see cref="BuildablePivot.AdvancePrerequisite"/> value.</param>
 /// <param name="advanceObsolescence">The <see cref="BuildablePivot.AdvanceObsolescence"/> value.</param>
 /// <param name="purchasePrice">The <see cref="BuildablePivot.PurchasePrice"/> value.</param>
 /// <param name="name">The <see cref="BuildablePivot.Name"/> value.</param>
 /// <param name="citizenCostToProduce">The <see cref="CitizenCostToProduce"/> value.</param>
 /// <param name="location">The <see cref="MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="ignoreControlZone">The <see cref="IgnoreControlZone"/> value.</param>
 /// <param name="ignoreCityWalls">The <see cref="IgnoreCityWalls"/> value.</param>
 /// <param name="squareSight">The <see cref="SquareSight"/> value.</param>
 /// <param name="maintenanceCost">The <see cref="MaintenanceCost"/> value.</param>
 protected UnitPivot(CityPivot city, int offensePoints, int defensePoints, int speed, int productivityCost, AdvancePivot advancePrerequisite,
                     AdvancePivot advanceObsolescence, int purchasePrice, string name, int citizenCostToProduce, MapSquarePivot location, PlayerPivot player,
                     bool ignoreControlZone, bool ignoreCityWalls, int squareSight, int maintenanceCost) :
     base(productivityCost, advancePrerequisite, advanceObsolescence, purchasePrice, name, false)
 {
     Player               = city?.Player ?? player;
     City                 = city;
     MapSquareLocation    = city?.MapSquareLocation ?? location;
     DefensePoints        = defensePoints;
     OffensePoints        = offensePoints;
     Speed                = speed;
     RemainingMoves       = ComputeRealSpeed();
     CitizenCostToProduce = citizenCostToProduce;
     IgnoreControlZone    = ignoreControlZone;
     IgnoreCityWalls      = ignoreCityWalls;
     SquareSight          = squareSight;
     MaintenanceCost      = maintenanceCost;
 }
예제 #27
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="opponent">The <see cref="Opponent"/> value.</param>
 internal AttackInPeaceEventArgs(PlayerPivot opponent)
 {
     Opponent = opponent;
 }
예제 #28
0
 private BomberPivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 12, 1, 8, 120, AdvancePivot.AdvancedFlight, null, 1920, null, location, player, false, false, true, 2, 2, 1)
 {
 }
예제 #29
0
 /// <summary>
 /// Static constructior.
 /// </summary>
 /// <param name="city">The <see cref="UnitPivot.City"/> value.</param>
 /// <param name="location">The <see cref="UnitPivot.MapSquareLocation"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <param name="player">The <see cref="UnitPivot.Player"/> value, if <paramref name="city"/> is <c>Null</c>.</param>
 /// <returns>An instance of <see cref="SubmarinePivot"/>.</returns>
 internal static SubmarinePivot CreateAtLocation(CityPivot city, MapSquarePivot location, PlayerPivot player)
 {
     return(new SubmarinePivot(city, location, player));
 }
예제 #30
0
 private TriremePivot(CityPivot city, MapSquarePivot location, PlayerPivot player) :
     base(city, 1, 0, 3, 40, AdvancePivot.MapMaking, AdvancePivot.Navigation, 320, null, location, player, false, false, 1, 2, false, 1)
 {
 }