Skip to content

Debug Terminal

Lucas Hicks edited this page Oct 14, 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. These can be accessed in the commands folder.

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
removeItem <itemName> This command removes an item from 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
addWeatherEvent <weatherEvent> <numHoursUntil> <duration> <priority> <severity> This command will set the in-game weather according to the given arguments
  • weatherEvent:
setTimeScale <timeScale> <numHoursUntil> <duration> <priority> <severity> This command will set the in-game time scale to the given argument
  • timeScale: in-game time scale > 0
  • numHoursUntil: hours until event
  • duration: duration of event
  • priority: priority of the event
  • severity: severity of the event
plant <growth stage> This command will set all plants in the game to a desired growth stage.
  • seedling: All plants become seedlings
  • sprout: All plants become sprouts
  • juvenile: All plants become juvenile
  • adult: All plants become adults
  • decay: All plants start to decay
  • dead: All plants die

Add Item

The current implementation of the addItem command only works on items that are included in AddItemCommand.java. The currently implemented itemName parameters and their associated items are as follows:

  • hoe - Hoe
  • shovel - Shovel
  • can - Watering Can
  • scythe - Scythe
  • sprinkler - Sprinkler
  • pump - Pump
  • fence - Fence
  • gate - Gate
  • chest - Chest
  • shipPart - Ship Part

Remove Item

The current implementation of the removeItem command only works on items that are included in removeItemCommand.java. The currently implemented itemName parameters and their associated items are as follows:

  • hoe - Hoe
  • shovel - Shovel
  • can - Watering Can
  • scythe - Scythe
  • sprinkler - Sprinkler
  • pump - Pump
  • fence - Fence
  • gate - Gate
  • chest - Chest

Spawn

The current implementation of the spawn command only spawns in animals that are included in SpawnCommand.java. The currently implemented entity parameters are as follows:

  • cow - Cow
  • chicken - Chicken
  • astrolotl - Astrolotl
  • oe - Oxygen Eater

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
  • rainStorm - Rain Storm
  • blizzard - Blizzard

For more information on the meaning of the arguments given in this command, see here.

UML Diagram

Clone this wiki locally