Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add .adventure command #1653

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Strengthless
Copy link

@Strengthless Strengthless commented Mar 1, 2025

Relevant Issues

This adds a text-based RPG adventure game. Closes #238.

Description

In this PR, we added an adventure.py file, and several JSON files as game assets.

The architecture of adventure.py is basically as follows:

  • the setup function loads the Adventure cog;
  • the Adventure cog contains all the commands that can be invoked;
  • when .adventure [game_code_or_index] is run, we instantiate a GameSession which contains all the states, business logic, event handlers, and helper functions for the actual game to run.
  • when .adventures or .adventure is run, we instantiate a GameSession without game_data, raising a GameCodeNotFoundError error, and is subsequently handled by sending a message to the channel.

Note: we are currently working on a few feature additions, e.g. support display of images in the rooms, and a retry button for restarting the game after it has ended. However, we would still like to get some early feedback from the dev team. Thanks!

Scope

  • Write a playable prototype of your game as a bot command.
    • Use .adventure [game_code] or .adventure [index] to play the game.
    • Use .adventures or .adventure to view a list of available games.
  • Make all player interactions reactions instead of having the player type commands.
  • Make the entire game happen in a single message that the bot edits, instead of having the bot post new messages.
  • Make a system that is possible to easily extend with new campaigns.
    • Define your own rooms, choices, collectibles (i.e., effects) and endings in a JSON format!
    • Customize game settings such as embed color, timeout seconds, etc.
    • Display a list of available games, or an error message if the game does not exist.
  • Support multiple concurrent games.
    • One player can instantiate multiple games at once.
    • More than one game can be played at the same time, and players can only react to their own game.

How to use

As a player

To test out the command, simply run .adventure or .adventures to see available games. You can then run .adventure [index] or .adventure [code] to start a game.

As a game developer

You need to include your game info in the available_games.json file. Then, design your rooms, collectibles and endings in [game_code].json.

You will need to include a starting room with "start" as key, and choices that lead to other rooms. Repeat this until your storyline reaches an ending (of course, you can have multiple endings). Trust us, the JSON format is very intuitive. Take a look at the three sample JSON files we've provided, and you shall understand it quickly. :)

The only interesting caveat here, is effect, requires_effect and effect_restricts (optional fields in OptionData).

Basically, they're "items" or "collectibles" that you can get by choosing a specific option.

Once you have obtained the item, options with requires_effect set to that item will become unlocked, and is now a valid option for the player; at the same time, options with effect_restricts set to that item will become locked.

This "memory" mechanism allows you to design your game much more efficiently, and opens up a lot more interesting possibilities. Just as an example, you can introduce hidden paths, collectible items, ever-changing scenes, and much more!

Showcase video

Screen.Recording.2025-03-01.at.1.22.44.AM.mp4

Future considerations

  • Allow aborting of games
  • Allow display of images in the rooms
  • Allow the user to see a report of their choices/ collectibles at the end of the game
  • Add a retry button to restart the game after it has ended
  • Annotate type of endings with "neural", "good" or "bad"
  • Use LinePaginator for the list of available games

Did you:

Strengthless and others added 7 commits February 26, 2025 16:05
* feat: added scary haunted mansion story and choices now affect the game later

* refactor: refactored and cherry picked according to comments

* refactor: refactored and cherry picked according to comments

* feat: added effect_restricts

* docs: changed comments describing effect_restrics

---------

Co-authored-by: Johan Nilsson <[email protected]>
Co-authored-by: Strengthless <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text Based Adventure
2 participants