Skip to content

Commit

Permalink
Fix bug: Filter out null values for effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Jun 19, 2017
1 parent 70797f8 commit d2cd8ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Sanderling.ABot/Bot/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public BotStepResult Step(BotStepInput input)

foreach (var taskPath in outputListTaskPath.EmptyIfNull())
{
foreach (var effectParam in (taskPath?.LastOrDefault()?.Effects).EmptyIfNull().WhereNotDefault())
foreach (var effectParam in (taskPath?.LastOrDefault()?.ApplicableEffects()).EmptyIfNull())
{
listMotion.Add(new MotionRecommendation
{
Expand Down
8 changes: 6 additions & 2 deletions src/Sanderling.ABot/Bot/BotExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BotEngine.Common;
using Sanderling.ABot.Bot.Task;
using Sanderling.Interface.MemoryStruct;
using Sanderling.Motor;
using Sanderling.Parse;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -32,13 +33,16 @@ static public int AttackPriorityIndex(
AttackPriorityIndexForOverviewEntryEWar(bot?.OverviewMemory?.SetEWarTypeFromOverviewEntry(entry));

static public bool ShouldBeIncludedInStepOutput(this IBotTask task) =>
null != task?.Effects || task is DiagnosticTask;
(task?.ContainsEffect() ?? false) || task is DiagnosticTask;

static public bool LastContainsEffect(this IEnumerable<IBotTask> listTask) =>
listTask?.LastOrDefault()?.ContainsEffect() ?? false;

static public IEnumerable<MotionParam> ApplicableEffects(this IBotTask task) =>
task?.Effects?.WhereNotDefault();

static public bool ContainsEffect(this IBotTask task) =>
0 < task?.Effects?.Count();
0 < task?.ApplicableEffects()?.Count();

static public IEnumerable<IBotTask[]> TakeSubsequenceWhileUnwantedInferenceRuledOut(this IEnumerable<IBotTask[]> listTaskPath) =>
listTaskPath
Expand Down

0 comments on commit d2cd8ca

Please sign in to comment.