/**
  * Add a SuperRegion to the map
  * @param superRegion : SuperRegion to be Added
  */
 public void Add(SuperRegion superRegion)
 {
     foreach (SuperRegion sr in superRegions)
         if (sr.Id == superRegion.Id)
         {
             Console.Error.WriteLine("SuperRegion cannot be Added: id already exists.");
             return;
         }
     superRegions.Add(superRegion);
 }
Exemple #2
0
        public Region(int id, SuperRegion superRegion, string playerName, int armies)
        {
            Id          = id;
            SuperRegion = superRegion;
            Neighbors   = new List <Region>();
            PlayerName  = playerName;
            Armies      = armies;

            superRegion.AddSubRegion(this);
        }
Exemple #3
0
        public Region(int id, SuperRegion superRegion)
        {
            Id          = id;
            SuperRegion = superRegion;
            Neighbors   = new List <Region>();
            PlayerName  = "unknown";
            Armies      = 0;

            superRegion.AddSubRegion(this);
        }
Exemple #4
0
 /**
  * Add a SuperRegion to the map
  * @param superRegion : SuperRegion to be Added
  */
 public void Add(SuperRegion superRegion)
 {
     foreach (SuperRegion sr in SuperRegions)
     {
         if (sr.Id == superRegion.Id)
         {
             Console.Error.WriteLine("SuperRegion cannot be Added: id already exists.");
             return;
         }
     }
     SuperRegions.Add(superRegion);
 }
        public Region(int id, SuperRegion superRegion, String playerName, int armies)
        {
            this.id = id;
            this.superRegion = superRegion;
            this.neighbors = new List<Region>();
            this.playerName = playerName;
            this.armies = armies;
            this.previousturnarmies = armies;
            this.deployedthisturn = false;
            //this.deployedlastturn = false;

            this.reservedArmies = 0;
            this.pledgedArmies = 0;

            superRegion.AddSubRegion(this);
        }
Exemple #6
0
        /**
         * @return : a new Map object exactly the same as this one
         */
        public Map GetMapCopy()
        {
            Map newMap = new Map();

            foreach (SuperRegion sr in SuperRegions) //copy superRegions
            {
                SuperRegion newSuperRegion = new SuperRegion(sr.Id, sr.ArmiesReward);
                newMap.Add(newSuperRegion);
            }
            foreach (Region r in Regions) //copy regions
            {
                Region newRegion = new Region(r.Id, newMap.GetSuperRegion(r.SuperRegion.Id), r.PlayerName, r.Armies);
                newMap.Add(newRegion);
            }
            foreach (Region r in Regions) //Add neighbors to copied regions
            {
                Region newRegion = newMap.GetRegion(r.Id);
                foreach (Region neighbor in r.Neighbors)
                {
                    newRegion.AddNeighbor(newMap.GetRegion(neighbor.Id));
                }
            }
            return(newMap);
        }
 /**
  * @return : a new Map object exactly the same as this one
  */
 public Map GetMapCopy()
 {
     Map newMap = new Map();
     foreach (SuperRegion sr in superRegions) //copy superRegions
     {
         SuperRegion newSuperRegion = new SuperRegion(sr.Id, sr.ArmiesReward);
         newMap.Add(newSuperRegion);
     }
     foreach (Region r in regions) //copy regions
     {
         try
         {
             Region newRegion = new Region(r.Id, newMap.GetSuperRegion(r.SuperRegion.Id), r.PlayerName, r.Armies);
             newMap.Add(newRegion);
         }
         catch (Exception exc) {
             Console.Error.WriteLine(exc.Message);
             Console.Error.WriteLine("couldn't copy region");
             Console.Error.WriteLine("id: " + r.Id);
             Console.Error.WriteLine("parent: " + r.SuperRegion.Id);
             Console.Error.WriteLine("playername: " + r.PlayerName);
             Console.Error.WriteLine("armies: " + r.Armies);
         }
     }
     foreach (Region r in regions) //Add neighbors to copied regions
     {
         Region newRegion = newMap.GetRegion(r.Id);
         foreach (Region neighbor in r.Neighbors)
             newRegion.AddNeighbor(newMap.GetRegion(neighbor.Id));
     }
     return newMap;
 }