Skip to content

Debug Terminal

Lucas Hicks edited this page Sep 16, 2023 · 27 revisions

Introduction

The debug terminal is for developers to run commands while the game is running. When visible, the terminal is displayed in the bottom-left of the screen and commands can be typed into the terminal using the keyboard.

The terminal uses the Command Pattern to action entered commands.

Key Components

  1. Terminal - Maintains the state of the terminal and actions commands: Terminal.
  2. Terminal Input Component - Processes input and triggers state changes in the terminal:KeyboardTerminalInputComponent.
  3. Terminal Display - Displays the terminal's UI: TerminalDisplay.
  4. Command - Defines actions to be taken when the command is triggered: e.g. DebugCommand.

Usage

The terminal can be toggled in and out of view using the F1 key.

Commands can be triggered by typing into the terminal and pressing enter. When the name of the command followed by valid arguments is entered, the command is actioned. As an example, the "debug" command accepts the arguments "on" and "off". So debug on or debug off would be valid commands.

Commands must be added to the commands map in Terminal.java using addCommand(). They are composed of a name and an instance of the Command interface. The following is an example for adding the debug command:

addCommand("debug", new DebugCommand());

Game Commands

Commands

These are the following commands that are available in the game.

Game Command Description Parameters
setTime <time> This command will set the game time to the specified time
  • time:game time (0-23)
addItem <itemName> This command adds an item to the player's inventory
  • itemName: name of the game item
See here
spawn <entity> <x> <y> This command will spawn a living entity at a given position
  • entity: name of the entity to be spawn See here
  • x and y: optional position argument
setDay <day> This command will set the in-game day to the given argument.
  • day: in-game day value

Add Item

The current implementation of the addItem command only adds player tools to their inventory. More information on these can be found here. The itemName parameter and their associated tools are as follows:

  • hoe - Hoe
  • shovel - Shovel
  • can - Watering Can
  • scythe - Scythe

Spawn

The current implementation of the spawn command only spawns in two animals. More information on these can be found here. Possible values for the entity parameter are as follows:

  • cow - Cow
  • chicken - Chicken
  • astrolotl - Astrolotl

Weather

The current implementation of the AddWeather command only creates two weather events. More information on these can be found here. Possible values for the weatherEvent parameter are as follows:

  • solarSurge - Solar Surge
  • acidShower - Acid Shower

UML Diagram

Clone this wiki locally