Skip to content

Game Engine (src/game-base)

Included in the backend project is a src/game-base. This can be considered the actual game engine of the solution. On it’s own, it just a collection of cleverly crafted files that don’t really do anything. To actually build a game with it, you need to make an implementation of the BaseGameService-class.

An initial implemention of that class can be found under src/game-implementation. This directory can be considered the actual game logic of the solution. Before you can extend this implementation with your own game logic, you have to understand how the game engine is structured.

Basically, there are three important concepts you have to remember:

  • GameObjects
  • Actions
  • ActionResults

GameObjects are entities that can be interacted with in the game world. The game engine comes with the following three:

  • Room
  • Item
  • Character

Actions determine which kind of interactions exist in the game world. The game engine comes with the following three:

  • ExamineAction
  • TalkAction
  • SimpleAction

If you put these two concepts together, you get the following:

GameObject Supported Actions
Room Examine
Item None
Character Talk

This means that, for example, you can execute an Examine action on a Room, but not on an Item. Unless, you add support for that action in your game logic.

Last but not least, there are ActionResults. ActionResults represent the result of an executed action, which is eventually used to instruct the frontend what to show the user. The game engine comes with the following two:

  • TextActionResult
  • TalkActionResult

Most, if not all executed actions will result in a TextActionResult. For example, when executing an Examine action the user expects to learn something about the game object its examining. The TextActionResult would then contain the text to show to the user.

The TalkActionResult is specific to the Talk action, as the game logic has to keep track of which character is talking, what the character is saying and which choices the user has on the frontend to respond to the character.