LaurierCS / PHI-TextBasedGameEngine

A text based game engine for creating games
4 stars 1 forks source link

Room (string?) Templating #46

Open jbheard opened 3 years ago

jbheard commented 3 years ago

Allow templating for room descriptions. This could extend to other gameobjects as well.

For example:

- name: template_example
  description: |
    You enter the {{room_type}} room, there are cobwebs in the sides of the ceiling, and
    it seems as though nobody has entered for years.
  template:
    - room_type: 'template'
  actions:
    ...

The workflow would go as follows:

  1. Player enters the room; variables from template are loaded as gameobjects (only if they do not exist)
  2. Variables are loaded into the template, text displays "You enter the template room, ..."
  3. Player enters another room which sets room_type: 'something else', and then visits template_example room again.
  4. The text will now display as "You enter the something else room, ...", since the value of room_type has been modified.

This sets up rooms which can be modified at runtime, and the dev can create 1 room with a template rather than creating a whole different branch of rooms for the user. The same could be done with enemy descriptions and item descriptions.