public PlanetManagementMenu(Planet planetAssigned)
 {
     assignedPlanet = planetAssigned;
     Initialize();
 }
Пример #2
0
 //Adds Ownership of a Planet
 public void AddPlanet(Planet p)
 {
     ownedPlanets.Add(p);
     addResourcesPerTurn(p.resourceNumbers);
 }
Пример #3
0
 //Removes Ownership of a Planet
 public void RemovePlanet(Planet p)
 {
     ownedPlanets.Remove(p);
 }
Пример #4
0
        //Preforms Attacking Think Axis and Allies
        public bool Attack(List <Ship> attack, List <Ship> defense, Planet p, Planet surrender)
        {
            Random die      = new Random();
            Player defender = null;
            int    ahits    = 0;
            int    dhits    = 0;

            //Gets Defender
            foreach (Player player in board.players)
            {
                if (player.ownedPlanets.Contains(p))
                {
                    defender = player;
                }
            }

            if (!defender.Equals(null))
            {
                //Gets Number Of Hits
                foreach (Ship aship in attack)
                {
                    int roll = die.Next(1, 21);
                    if (roll <= aship.getAttack())
                    {
                        ahits++;
                    }
                }

                foreach (Ship dship in defense)
                {
                    int roll = die.Next(1, 21);
                    if (roll <= dship.getDefence())
                    {
                        dhits++;
                    }
                }

                //Removes Ships
                for (int i = 1; i <= ahits; i++)
                {
                    if (defense.Count > 0)
                    {
                        int  index = die.Next(0, defense.Count);
                        Ship temp  = defense[index];
                        defense.Remove(temp);
                        defender.ships.Remove(temp);
                        p.planetShips.Remove(temp);
                    }
                }
                for (int i = 1; i <= dhits; i++)
                {
                    if (attack.Count > 0)
                    {
                        int  index = die.Next(0, attack.Count);
                        Ship temp  = attack[index];
                        attack.Remove(temp);
                        this.ships.Remove(temp);
                    }
                }

                //Takeover Planet
                if (defense.Count <= 0 && attack.Count > 0)
                {
                    defender.ownedPlanets.Remove(p);
                    this.ownedPlanets.Add(p);
                    foreach (Ship ship in attack)
                    {
                        p.planetShips.Add(ship);
                    }
                    return(true);
                }
            }
            return(false);
        }