Skip to content

Instantly share code, notes, and snippets.

@jamescurran
Created December 27, 2023 19:14
Show Gist options
  • Select an option

  • Save jamescurran/b56bc09895d386b564ed8bdf3566c541 to your computer and use it in GitHub Desktop.

Select an option

Save jamescurran/b56bc09895d386b564ed8bdf3566c541 to your computer and use it in GitHub Desktop.
Code from
public static int AskGunSkill(IIO io)
{
io.Display("How good a shot are you with your rifle?");
io.Display(" (1) Ace Marksman, (2) Good Shot, (3) Fair to Middlin'");
io.Display(" (4) Need more practice, (5) Shaky Knees");
io.Display("Enter one of the above . The better you claim you are, the");
return io.InputValue("faster you'll have to be with your gun to be successful... ", 1, "Enter 1-5", 5,
"Enter 1-5");
}
private static readonly string[] gunWords = new string[] { "BANG", "BLAM", "POW", "WHAM" };
public static int Shoot(GameContext context)
{
var goal = gunWords[context.Rnd.Next(gunWords.Length)];
var timer = new Stopwatch();
timer.Start();
var response = context.IO.InputString($"Type: {goal}: ");
var seconds = (int) timer.Elapsed.TotalSeconds;
seconds -= context.GunSkill - 1;
if (seconds < 0) seconds = 0;
if (String.Compare(goal, response, StringComparison.CurrentCultureIgnoreCase) == 0)
seconds = 100;
context.IO.Display($"Seconds: {seconds}");
return seconds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment