Пример #1
0
        public TerritoryStanding Clone()
        {
            TerritoryStanding territoryStanding = TerritoryStanding.Create(this.ID, this.OwnerPlayerID, this.NumArmies);

            territoryStanding.ArmiesMarkedAsUsed      = ArmiesMarkedAsUsed;
            territoryStanding.TerritoriesMarkedAsUsed = TerritoriesMarkedAsUsed;
            return(territoryStanding);
        }
Пример #2
0
        public static TerritoryStanding Create(TerritoryIDType territoryID, PlayerIDType owner, Armies armies)
        {
            TerritoryStanding cs = new TerritoryStanding();

            cs.ID            = territoryID;
            cs.OwnerPlayerID = owner;
            cs.NumArmies     = armies;
            return(cs);
        }
Пример #3
0
        public static TerritoryStanding Create(TerritoryIDType territoryID, PlayerIDType owner, Armies armies)
        {
            TerritoryStanding cs = new TerritoryStanding();

            cs.ID                      = territoryID;
            cs.OwnerPlayerID           = owner;
            cs.NumArmies               = armies;
            cs.ArmiesMarkedAsUsed      = new Armies();
            cs.TerritoriesMarkedAsUsed = new List <TerritoryIDType>();
            return(cs);
        }
Пример #4
0
        private static GameStanding ReadMap(string[] mapInput)
        {
            var ret = new GameStanding(Map.Territories.Values.Select(o => TerritoryStanding.Create(o.ID, TerritoryStanding.FogPlayerID, new Armies(fogged: true))));

            for (var i = 1; i < mapInput.Length; i++)
            {
                var ts = ret.Territories[(TerritoryIDType)int.Parse(mapInput[i++])];
                ts.OwnerPlayerID = (PlayerIDType)ToPlayerID(mapInput[i++]);
                ts.NumArmies     = new Armies(int.Parse(mapInput[i]));
            }
            return(ret);
        }
Пример #5
0
        public static GameStanding ReadGameStanding(JToken jToken)
        {
            var ret = new GameStanding();

            if (jToken == null || (jToken.Type == JTokenType.String && (string)jToken == "null"))
            {
                return(null);
            }

            foreach (var terr in (JArray)jToken)
            {
                var terrID   = (TerritoryIDType)(int)terr["terrID"];
                var playerID = ToPlayerID((string)terr["ownedBy"]);
                var armies   = ToArmies((string)terr["armies"]);
                ret.Territories.Add(terrID, TerritoryStanding.Create(terrID, playerID, armies));
            }

            return(ret);
        }
Пример #6
0
        /// <summary>
        /// Determines who controls this bonus. Will return null if nobody does or at least one territory is fogged
        /// </summary>
        public PlayerIDType?ControlsBonus(GameStanding standing)
        {
            Assert.Fatal(standing != null, "standing is null");

            PlayerIDType playerID = (PlayerIDType)int.MinValue;

            foreach (var territoryID in this.Territories)
            {
                TerritoryStanding cs = standing.Territories[territoryID];
                if (cs.OwnerPlayerID == TerritoryStanding.AvailableForDistribution)
                {
                    return(null);
                }
                if (cs.IsNeutral)
                {
                    return(null);
                }
                else if (cs.OwnerPlayerID == TerritoryStanding.FogPlayerID)
                {
                    return(null);
                }
                else if ((int)playerID == int.MinValue)
                {
                    playerID = cs.OwnerPlayerID;
                }
                else if (playerID != cs.OwnerPlayerID)
                {
                    return(null);
                }
            }

            Assert.Fatal(playerID != TerritoryStanding.FogPlayerID && playerID != TerritoryStanding.NeutralPlayerID);
            if ((int)playerID == int.MinValue)
            {
                throw new Exception("Bonus " + this.Name + " (" + this.ID + ") has no territories assigned");
            }

            return(new Nullable <PlayerIDType>(playerID));
        }
Пример #7
0
        /*
         * Bot1: setup_map super_regions 1 5 2 4 3 1 4 3 5 4 6 3 7 3 8 2 9 3 10 3 11 6 12 5 13 4
         * Bot1: setup_map regions 1 1 2 1 3 1 4 1 5 1 6 2 7 2 8 2 9 2 10 3 11 3 12 3 13 3 14 4 15 4 16 4 17 4 18 4 19 4 20 5 21 5 22 5 23 5 24 6 25 6 26 6 27 6 28 7 29 7 30 7 31 7 32 7 33 8 34 8 35 8 36 8 37 9 38 9 39 9 40 9 41 10 42 10 43 10 44 10 45 10 46 10 47 11 48 11 49 11 50 11 51 11 52 11 53 11 54 12 55 12 56 12 57 12 58 12 59 13 60 13 61 13 62 13 63 13 64 13
         * Bot1: setup_map neighbors 1 3,2,6 2 3,5,4,8,6 3 4 4 24,5,25 5 24,20,7,8 6 8,7 7 9,8,20 9 20,21 10 11,12 11 12,13 12 13,29 13 29,28 14 15 15 18,28,16 16 17,18 17 18,33,19 18 33,28,34,29,30 19 33 20 21,22,24,26,23 21 23 22 26,23,38,24,59 24 26,27,25,38 25 27 27 37 28 30,29 29 31,30,34,32 31 48,32,51 32 34 33 35,34 34 36,35 35 36 37 38,39,40 38 40,55,60 39 54,40,49 40 55,54,56 41 44,42,46,62 42 44,43,45 43 45 44 61,62,45 45 59,61 46 62 47 48,50 48 51,50 49 50,56,54 50 56,51,52,53 51 52 52 53 53 56,58 54 56 55 57,56 56 58,57 57 58 59 61,63,64,60 60 63 61 62,64 62 64 63 64
         * Bot1: setup_map wastelands 5 13 40 49 62
         */
        private static void SetupMap(string[] mapInput)
        {
            if (Map == null)
            {
                Map = new MapDetails();
            }


            if (mapInput[1] == "super_regions")
            {
                for (var i = 2; i < mapInput.Length; i++)
                {
                    var bonusID = (BonusIDType)int.Parse(mapInput[i]);
                    i++;
                    var reward = int.Parse(mapInput[i]);
                    Map.Bonuses.Add(bonusID, new BonusDetails(Map, bonusID, reward));
                }
            }
            else if (mapInput[1] == "regions")
            {
                for (var i = 2; i < mapInput.Length; i++)
                {
                    var terrID = (TerritoryIDType)int.Parse(mapInput[i]);
                    i++;
                    var bonusID = (BonusIDType)int.Parse(mapInput[i]);
                    Map.Territories.Add(terrID, new TerritoryDetails(Map, terrID));
                    Map.Bonuses[bonusID].Territories.Add(terrID);
                    Map.Territories[terrID].PartOfBonuses.Add(bonusID);
                }
            }
            else if (mapInput[1] == "neighbors")
            {
                for (var i = 2; i < mapInput.Length; i++)
                {
                    var terrID = (TerritoryIDType)int.Parse(mapInput[i++]);

                    var terr = Map.Territories[terrID];
                    mapInput[i].Split(',').Select(o => (TerritoryIDType)int.Parse(o)).ForEach(o => terr.ConnectedTo.Add(o, null));
                    foreach (var conn in terr.ConnectedTo.Keys)
                    {
                        Map.Territories[conn].ConnectedTo[terrID] = null;
                    }
                }

                //Map is now done being read
                DistributionStanding = new GameStanding();
                foreach (var terr in Map.Territories.Values)
                {
                    DistributionStanding.Territories.Add(terr.ID, TerritoryStanding.Create(terr.ID, TerritoryStanding.NeutralPlayerID, new Armies(2)));
                }
            }
            else if (mapInput[1] == "wastelands")
            {
                foreach (var terrID in mapInput.Skip(2).Select(o => (TerritoryIDType)int.Parse(o)).ToList())
                {
                    DistributionStanding.Territories[terrID].NumArmies = new Armies(6);
                }
            }
            else if (mapInput[1] == "opponent_starting_regions")
            {  /* don't care */
            }
            else
            {
                throw new Exception("Unexpected map input: " + mapInput[1]);
            }
        }
Пример #8
0
 public TerritoryStanding Clone()
 {
     return(TerritoryStanding.Create(this.ID, this.OwnerPlayerID, this.NumArmies));
 }