Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:setup
function loads theAdventure
cog;Adventure
cog contains all the commands that can be invoked;.adventure [game_code_or_index]
is run, we instantiate aGameSession
which contains all the states, business logic, event handlers, and helper functions for the actual game to run..adventures
or.adventure
is run, we instantiate aGameSession
withoutgame_data
, raising aGameCodeNotFoundError
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
.adventure [game_code]
or.adventure [index]
to play the game..adventures
or.adventure
to view a list of available games.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
andeffect_restricts
(optional fields inOptionData
).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 witheffect_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
LinePaginator
for the list of available gamesDid you: