Ejemplo n.º 1
0
        //////////////////////////////////////////////////

        ///// STRUCTORS //////////////////////////////////
        public Ability(int id, string description, int value,
                       AbilityEffect abilityEffect, TargetStrategy targetStrategy, TargetType targetType)
        {
            this.Id             = id;
            this.Description    = description;
            this.Value          = value;
            this.AbilityEffect  = abilityEffect;
            this.TargetStrategy = targetStrategy;
            this.TargetType     = targetType;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a list of targets for a Boss,
        /// given the initially chosen target and target strategy & target type
        /// </summary>
        /// <param name="target">a username</param>
        /// <returns>A list of usernames</returns>
        private List <string> GetBossTargets(string target, TargetStrategy ts, TargetType tt)
        {
            List <string> targets = new List <string>();

            switch (ts)
            {
            case TargetStrategy.Manual:
                targets.Add(target);
                break;

            case TargetStrategy.HighestHitting:
                targets.Add(GetHighestHittingPlayer());
                break;

            case TargetStrategy.Random:
                targets.Add(GetRandomPlayer());
                break;
            }

            return(targets);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a list of targets for a Hero,
        /// given the initially chosen target and target strategy & target type
        /// </summary>
        /// <param name="target">a username (or the Boss.PUID)</param>
        /// <returns>A list of usernames (or the Boss.PUID)</returns>
        private List <string> GetHeroTargets(string target, TargetStrategy ts, TargetType tt)
        {
            List <string> targets = new List <string>();

            if (target == Boss.PUID)
            {
                targets.Add(target);
            }
            else
            {
                switch (tt)
                {
                case TargetType.Single:
                    targets.Add(target);
                    break;

                case TargetType.Team:
                    targets.AddRange(GetPlayerTeam(Hero.TEAM));
                    break;
                }
            }

            return(targets);
        }
 public override HistoricalEventViewable Activate(AgentInstanceContext agentInstanceContext)
 {
     var strategy = new PollExecStrategyMethod(TargetStrategy.Make(agentInstanceContext), ConversionStrategy);
     return new HistoricalEventViewableMethod(this, strategy, agentInstanceContext);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the target regions based on the given target strategy.
        /// </summary>
        /// <param name="superRegion">The super region.</param>
        /// <param name="allSuperRegions">All super regions.</param>
        /// <param name="transfers">The transfers.</param>
        /// <param name="targetStrategy">The target strategy.</param>
        /// <returns></returns>
        public static IEnumerable <Region> GetTargetRegions(SuperRegion superRegion, IEnumerable <ArmyTransfer> transfers, TargetStrategy targetStrategy)
        {
            IEnumerable <Region> targetRegions = new List <Region>();

            switch (targetStrategy)
            {
            case TargetStrategy.ConquerCurrentSuperRegion:
                /*
                 * Searches for regions in this super region that are not occupied (neutral)
                 * Order by:
                 *  - Take regions away from the borders first
                 *  - Regions with neutral armies first, to ensure our expansion drift
                 *  - The amount of our regions nearby
                 * */
                targetRegions = superRegion
                                .ChildRegions
                                .OccupiedBy(PlayerType.Neutral)
                                .OrderRegions(OrderStrategy.InternalFirst)
                                .ThenOrderRegions(OrderStrategy.NeutralNeighboursFirst)
                                .ThenOrderRegions(OrderStrategy.MostArmiesNearby);

                break;

            case TargetStrategy.ConquerAll:
                /*
                 * Searches for regions in all super regions that are not occupied (neutral)
                 * Order by:
                 *  - Take regions away from the borders first
                 *  - Regions with neutral armies first, to ensure our expansion drift
                 *  - The amount of our regions nearby
                 * */
                var internalRegions = superRegion
                                      .ChildRegions
                                      .OccupiedBy(PlayerType.Neutral);

                var externalRegions = superRegion
                                      .ChildRegions
                                      .OccupiedBy(PlayerType.Me)
                                      .SelectMany(region => region.Neighbours.Where(neighbour => neighbour.IsOccupiedBy(PlayerType.Neutral) && neighbour.SuperRegion != superRegion));

                targetRegions = internalRegions.Concat(externalRegions)
                                .OrderRegions(OrderStrategy.InternalFirst)
                                .ThenOrderRegions(OrderStrategy.NeutralNeighboursFirst)
                                .ThenOrderRegions(OrderStrategy.MostArmiesNearby);

                break;

            case TargetStrategy.ConquerOtherSuperRegions:
                /*
                 * Searches for regions in other super regions that are not occupied (neutral)
                 * */
                targetRegions = superRegion
                                .InvasionPaths
                                .OccupiedBy(PlayerType.Neutral)
                                .OrderRegions(OrderStrategy.MostArmiesNearby);

                break;

            case TargetStrategy.HostileRegions:
                /*
                 * Searches for regions in this super region that are occupied by the opponent
                 * */
                targetRegions = superRegion
                                .ChildRegions
                                .OccupiedBy(PlayerType.Opponent)
                                .AnyNeighboursOccupiedBy(PlayerType.Me)
                                .OrderRegions(OrderStrategy.LeastNumberOfArmies);

                break;

            case TargetStrategy.EnemyInvasionPaths:
                /*
                 * Searches for enemy invasion paths
                 * Skip regions that are a target already, we should have conquered them already in earlier moves
                 * */
                targetRegions = superRegion
                                .InvasionPaths
                                .OccupiedBy(PlayerType.Opponent)
                                .NoTargetYet(transfers)
                                .OrderRegions(OrderStrategy.MostNumberOfArmies);

                break;
            }

            return(targetRegions);
        }