Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created September 22, 2019 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/e7b26371c0efc012e7d84851e2b18659 to your computer and use it in GitHub Desktop.
Save IntegerMan/e7b26371c0efc012e7d84851e2b18659 to your computer and use it in GitHub Desktop.
private OneOf<WorkCompletedResult, ProgressMadeResult, SetbackResult>
GetWorkOnItemResult(CrewContext context, WorkItem item)
{
var roll = context.GetRandomNumber(1, 20);
// Something went wrong. Likely a mistaken assumption or bad requirement
if (roll == 1)
{
return new SetbackResult(Priority.High);
}
// We got a massive success or we've previously made significant progress
if (roll >= 20 - item.ProgressMade)
{
return new WorkCompletedResult(item);
}
// Okay, not a great roll, let's call it a setback
if (roll < 3)
{
return new SetbackResult(Priority.Normal);
}
// Just a bit of progress
return new ProgressMadeResult(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment