Skip to content

Instantly share code, notes, and snippets.

@ZacharyPatten
Last active June 6, 2021 07:14
Show Gist options
  • Save ZacharyPatten/a1050eedc239469dc3f87fb6df6809f4 to your computer and use it in GitHub Desktop.
Save ZacharyPatten/a1050eedc239469dc3f87fb6df6809f4 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using Towel;
class Program
{
public enum Location
{
Rivendell,
Trail1,
Gondor,
Trail2,
Mordor,
SanFrancisco,
}
static Dictionary<Location, Location[]> AdjacentLocations = new()
{
{ Location.Rivendell, new[] { Location.Trail1, Location.SanFrancisco } },
{ Location.Trail1, new[] { Location.Rivendell, Location.Gondor } },
{ Location.Gondor, new[] { Location.Trail1, Location.Trail2 } },
{ Location.Trail2, new[] { Location.Gondor, Location.Mordor, Location.SanFrancisco, } },
{ Location.Mordor, new[] { Location.SanFrancisco, Location.Trail2, Location.Rivendell, } },
{ Location.SanFrancisco, new[] { Location.Mordor, Location.Trail2, Location.Rivendell, } },
};
static void Main()
{
Location location = Location.Rivendell;
bool exit = false;
while (!exit)
{
var adjacents = AdjacentLocations[location];
List<(string, Action)> menuOptions = new();
foreach (Location adjacent in adjacents)
{
menuOptions.Add((adjacent.ToString(), () => location = adjacent));
}
menuOptions.Add(("Exit Game", () => exit = true));
Console.Clear();
ConsoleHelper.IntMenu(
title: $"You are in {location}.",
prompt: "Where To Next? ",
invalidMessage: default,
menuOptions.ToArray());
}
ConsoleHelper.PromptPressToContinue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment