Exemplo n.º 1
0
        public bool SetStarship(Player player, BoardVerticePath path)
        {
            // Disqualify if insufficiant resources.
            if (resources.GetDilithium() < 1 || resources.GetTritanium() < 1)
            {
                return(false);
            }
            // Disqualify if starship already present
            if (path.HasStarship())
            {
                return(false);
            }


            // Qualify if player owns an outpost at either end of the path.
            if ((path.GetFromVertice().HasOutpost() && path.GetFromVertice().GetOutpost().GetOwner().GetOrder() == order) ||
                (path.GetToVertice().HasOutpost() && path.GetToVertice().GetOutpost().GetOwner().GetOrder() == order))
            {
                // Add new starship
                Starship newStarship = new Starship(player, path);
                path.SetStarship(newStarship);
                // Remove resources from player
                resources.RemoveDilithium(1);
                resources.RemoveTritanium(1);
                return(true);
            }
            // Qualify if player owns an existing starship on leading paths
            bool ownsExistingStarship = false;

            foreach (BoardVerticePath nextDegreePath in path.GetFromVertice().GetPaths())
            {
                if (nextDegreePath.HasStarship() && nextDegreePath.GetStarship().GetOwner().GetOrder() == order)
                {
                    ownsExistingStarship = true;
                }
            }
            foreach (BoardVerticePath nextDegreePath in path.GetToVertice().GetPaths())
            {
                if (nextDegreePath.HasStarship() && nextDegreePath.GetStarship().GetOwner().GetOrder() == order)
                {
                    ownsExistingStarship = true;
                }
            }
            if (ownsExistingStarship)
            {
                // Add new starship
                Starship newStarship = new Starship(player, path);
                path.SetStarship(newStarship);
                // Remove resources from player
                resources.RemoveDilithium(1);
                resources.RemoveTritanium(1);
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 public Starship(Player owner, BoardVerticePath location)
 {
     this.location = location;
     this.owner    = owner;
 }