Esempio n. 1
0
        public Move GetNextMove(GameState state)
        {
            var args = new AttackItemPipelineArgs()
            {
                EligibleTargets = state.Leaderboard.ToList(),
                EligibleItems   = state.Items.ToList(),
            };

            foreach (var processor in _pipeline)
            {
                processor.Process(state, args);

                if (args.Aborted)
                {
                    return(null);
                }

                if (args.Selected)
                {
                    return(new Move()
                    {
                        Item = args.SelectedItem,
                        Target = args.SelectedTarget,
                        Mode = ItemMode.Automatic
                    });
                }
            }

            return(null);
        }
Esempio n. 2
0
        public void Process(GameState state, AttackItemPipelineArgs args)
        {
            if (state.OnLeaderboard)
            {
                List <LeaderboardResult> output = new List <LeaderboardResult>();
                var leaderboard = state.Leaderboard.ToArray();

                var myPosition = state.Position;
                for (int i = myPosition; i >= 0; i--)
                {
                    var target = args.EligibleTargets.FirstOrDefault(t => t.PlayerName == leaderboard[i].PlayerName);
                    if (target != null)
                    {
                        output.Add(target);
                    }
                }

                for (int i = leaderboard.Length - 1; i >= myPosition; i--)
                {
                    var target = args.EligibleTargets.FirstOrDefault(t => t.PlayerName == leaderboard[i].PlayerName);
                    if (target != null)
                    {
                        output.Add(target);
                    }
                }

                args.EligibleTargets = output;
            }
        }
Esempio n. 3
0
        public void Process(GameState state, AttackItemPipelineArgs args)
        {
            args.EligibleTargets = args.EligibleTargets
                                   .Where(CanBeDamaged)
                                   .ToList();

            if (args.EligibleTargets.Count == 0)
            {
                args.Abort();
            }
        }
Esempio n. 4
0
 public void Process(GameState state, AttackItemPipelineArgs args)
 {
     // assuming targets and weapons are already prioritized
     // just find the first compatible combination
     foreach (var target in args.EligibleTargets)
     {
         foreach (var item in args.EligibleItems)
         {
             if (!target.Effects.Contains(item.Name))
             {
                 args.Select(item, target.PlayerName);
                 return;
             }
         }
     }
 }
Esempio n. 5
0
        public void Process(GameState state, AttackItemPipelineArgs args)
        {
            if (state.OnLeaderboard && args.EligibleItems.Any(i => i.Name == "Banana Peel"))
            {
                var behindMe = state.OpponentAtDelta(1);
                var target   = behindMe == null
                    ? null
                    : args.EligibleTargets.FirstOrDefault(t => t.PlayerName == behindMe.PlayerName);

                if (target != null)
                {
                    var banana = args.EligibleItems.First(i => i.Name == "Banana Peel");
                    args.Select(banana, target.PlayerName);
                }
            }
        }
Esempio n. 6
0
 public void Process(GameState state, AttackItemPipelineArgs args)
 {
     if (state.OnLeaderboard)
     {
         var botAhead = state.OpponentAtDelta(-1);
         if (botAhead != null)
         {
             if (botAhead.Effects.Any(e => Constants.DefenseiveItems.Contains(e)))
             {
                 args.EligibleItems = args.EligibleItems
                                      .Where(i => !ItemsThatAutomaticallyAttackNextGuy.Contains(i.Name))
                                      .ToList();
             }
         }
     }
 }
Esempio n. 7
0
 public void Process(GameState state, AttackItemPipelineArgs args)
 {
     args.EligibleTargets = args.EligibleTargets
                            .Where(t => !_whiteList.Contains(t.PlayerName))
                            .ToList();
 }
Esempio n. 8
0
 public void Process(GameState state, AttackItemPipelineArgs args)
 {
     args.EligibleItems = args.EligibleItems.Where(i => i.IsOffensive).ToList();
 }