Ejemplo n.º 1
0
        private bool plunderSystem(Starship ship, CosmicAdventureDTO.CosmosSystem system)
        {
            increaseCrewAge(system, ship);
            ship.Crew.RemoveAll(cm => cm.Age > 90);

            if (ship.ShipPower > system.MinShipPower)
            {
                ship.Gold += system.Gold;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 private void increaseCrewAge(CosmicAdventureDTO.CosmosSystem system, Starship ship)
 {
     if (ship.ShipPower <= 20)
     {
         ship.Crew.ForEach(cm => cm.Age = cm.Age + (2 * system.BaseDistance) / 12);
     }
     else if (ship.ShipPower > 20 && ship.ShipPower < 30)
     {
         ship.Crew.ForEach(cm => cm.Age = cm.Age + (2 * system.BaseDistance) / 6);
     }
     else
     {
         ship.Crew.ForEach(cm => cm.Age = cm.Age + (2 * system.BaseDistance) / 4);
     }
 }
Ejemplo n.º 3
0
        public Starship SendStarship(Starship starship, string systemName)
        {
            if (_systems.Exists(s => s.Name.Equals(systemName)))
            {
                CosmicAdventureDTO.CosmosSystem system = _systems.First(s => s.Name.Equals(systemName));
                if (plunderSystem(starship, system))
                {
                    _systems.Remove(system);
                }

                return(starship);
            }
            else
            {
                starship.Crew.Clear();

                return(starship);
            }
        }