public static string GetLocationList() { List <string> locationKeys = new List <string>(); foreach (string key in LocationLookupDictionary.Keys) { locationKeys.Add(key); } return(TextUtils.Borderize(TextUtils.Columnize(locationKeys))); }
private string GetMenu() { string result = ""; if (playerGender == Gender.Unset) { result = "CHOOSE A GENDER: 'M' / 'F'"; if (MenuState == MenuState.Error) { result += "\nPLEASE TYPE 'M' FOR MALE AND 'F' FOR FEMALE."; } result = $"\n{TextUtils.Borderize(result)}\n >> "; return(result); } else if (playerName == "") { result = "CHOOSE A PLAYER NAME"; if (MenuState == MenuState.Error) { result += $"\nPLAYER NAME MUST BE {GameEngine.MinimumNameLength} - {GameEngine.MaximumNameLength} CHARACTERS LONG."; } result = $"\n{TextUtils.Borderize(result)}\n >> "; return(result); } else { StringBuilder sb = new StringBuilder(); result = $"Welcome, {playerName} to the world of Fuchar Gonzol (name subject to copyright)! Your goal is to get inside the town. Explore and try not to die! Good luck!"; sb.Append(Environment.NewLine).Append(TextUtils.Borderize(result, 80)); sb.Append($"\n\n Some commands have arguments:"); sb.Append($"\nTo chat with people nearby, input 'c how are you' and the game will output 'How are you?'!"); sb.Append("\nTo pick up an item, type 'get [item name substring]' or 'g [item name substring]'\n Examples: 'get stick' 'get sti' 'g s'"); sb.Append("\nTo drop an item, you can use To drop an item it's 'drop [item name substring]' or 'd [item name substring]'\n Examples: 'drop stick' 'drop ck' 'd sti'"); sb.Append("\nThe game will check player inventory in this order: item bag first, then weapon, then armor."); sb.Append("\n\n REAL-TIME TURN-BASED MULTIPLAYER ON CONSOLE:"); sb.Append("\nText will be streamed to your console even as you are typing. Despite this, anything"); sb.Append("\nyou type will still be remembered by the console and you can backspace through it even"); sb.Append("\nif it is no longer 'there'. Likewise, despite it not being visible, when you submit your"); sb.Append("\naction, even if you don't see it, it will be submitted along with whatever text you typed"); sb.Append("\nfollowing the most recent screen refresh(es).\n\n"); result = $"The resulting experience should still be amazing and I really hope you enjoy your visit!"; result = TextUtils.Borderize(result, 80); sb.Append(result); if (Plugins.AllPlugins.Count > 0) { sb.Append("\n\nLoaded plugins:\n"); foreach (IPluggable plugin in Plugins.AllPlugins) { sb.Append(TextUtils.Borderize($"{plugin.Name}: {plugin.Description}", 80)).Append(Environment.NewLine); } } sb.Append("\n\n >> OK"); return(sb.ToString()); } }
public string GetFullInGameView() { StringBuilder sb = new StringBuilder(); sb.Append(Environment.NewLine).Append(TextUtils.Borderize(GuiStringHorizontal(), margin: 2)); sb.Append(Environment.NewLine).Append(TextUtils.Columnize( TextUtils.Borderize(Location.Name, 20), TextUtils.WordWrap(Location.GetDescription(this), 48), centerMargin: 4 )); sb.Append(Environment.NewLine); AssignActions(); if (actions.Count > 0) { sb.Append(Environment.NewLine).Append(TextUtils.GetOptionsMenuString(actions)); } sb.Append(Environment.NewLine).Append($"Notifications:\n{TextUtils.Borderize(TextUtils.WordWrap(GetNotifications(), 72), 72)}"); sb.Append(Environment.NewLine); return(sb.ToString()); }
public static string GetPrefabUnitList() { return(TextUtils.Borderize(TextUtils.Columnize(TextUtils.GetStringListFromEnum <UnitType>(numbered: true)))); }
private static void HandleKeyInput(ConsoleKey key) { bool subdueMenuRepeat = false; if (!GameEngine.Running) { switch (key) { case ConsoleKey.X: case ConsoleKey.Q: WriteLine("Exiting..."); done = true; break; case ConsoleKey.S: GameTask = Task.Factory.StartNew(() => LaunchGameWithThreadName()); while (!GameEngine.Running) { Thread.Sleep(100); } break; case ConsoleKey.L: GameTask = Task.Factory.StartNew(() => LaunchGameWithThreadName()); while (!GameEngine.Running) { Thread.Sleep(100); } GameEngine.PlayAsServer(); break; case ConsoleKey.K: GameTask = Task.Factory.StartNew(() => LaunchGameWithThreadName(false)); while (!GameEngine.Running) { Thread.Sleep(100); } GameEngine.PlayAsServer(); break; case ConsoleKey.C: StandaloneClient.RunClient(); break; case ConsoleKey.D: StandaloneClient.RunClient("dstults.net", 11111); break; default: subdueMenuRepeat = true; break; } } else { switch (key) { case ConsoleKey.X: case ConsoleKey.Q: WriteLine("Exiting..."); GameEngine.Shutdown(); GameTask.Wait(); done = true; break; case ConsoleKey.S: WriteLine(WorldMap.GetLocationList()); Write($" Where? > "); Location unitLoc = WorldMap.GetLocation(Console.ReadLine()); if (unitLoc == null) { WriteLine("Invalid location name"); break; } WriteLine(Prefabs.GetPrefabUnitList()); Write($" What unit? > "); Player myUnit = Prefabs.SpawnUnitAtLocation(Console.ReadLine(), unitLoc); if (myUnit != null) { WriteLine($"Playable unit [{myUnit.Name}] spawned at [{unitLoc.Name}]."); } else { WriteLine($"Invalid unit type or incomplete unit creation."); } break; case ConsoleKey.I: WriteLine(WorldMap.GetLocationList()); Write($" Where? > "); Location itemLoc = WorldMap.GetLocation(Console.ReadLine()); if (itemLoc == null) { WriteLine("Invalid location name"); break; } WriteLine(Prefabs.GetPrefabItemList()); Write($" What item? > "); Item myItem = Prefabs.SpawnItemAtLocation(Console.ReadLine(), itemLoc); if (myItem != null) { WriteLine($"Item [{myItem.Title}] spawned at [{itemLoc.Name}]."); GameEngine.SayToLocation(itemLoc, $"All of the sudden {myItem.SetName()} appears!"); } else { WriteLine($"Invalid item name."); } break; case ConsoleKey.P: WriteLine("Polling current clients:"); WriteLine(NetworkServer.GetConnectionPolling(verbose: true, detailed: false)); break; case ConsoleKey.D: WriteLine("Polling current clients (detailed):"); WriteLine(NetworkServer.GetConnectionPolling(verbose: true, detailed: true)); break; case ConsoleKey.G: WriteLine(GameEngine.GameInfo()); break; case ConsoleKey.V: WriteLine(TextUtils.Borderize(TextUtils.Columnize(TextUtils.GetCustomListFromNamedList(GameEngine.Players, numbered: true, lowered: true)))); Write($" ? (1-{GameEngine.Players.Count}) > "); Player viewPlayer = GameEngine.GetPlayer(Console.ReadLine()); if (viewPlayer != null) { WriteLine("\n================================================================"); WriteLine(viewPlayer.GetFullInGameView()); } else { WriteLine("No such player."); } break; case ConsoleKey.O: WriteLine(TextUtils.Borderize(TextUtils.Columnize(TextUtils.GetCustomListFromNamedList(GameEngine.Players, numbered: true, lowered: true)))); Write($" ? (1-{GameEngine.Players.Count}) > "); Player possessPlayer = GameEngine.GetPlayer(Console.ReadLine()); if (possessPlayer != null) { GameEngine.PlayAsServer(possessPlayer); } else { WriteLine("No such player."); } break; case ConsoleKey.Z: GameEngine.TogglePause(); break; default: subdueMenuRepeat = true; break; } } if (!subdueMenuRepeat && !done) { ShowMenu(); } }