This idea was originated in a hackathon - the concept was a silly take on text based adventures where the fun bit was literally using sms. The goal here is to parse a twilio message body, updating game state for the given number, and responding to the requested action. The engine will rely on a structured story map with actions like use and take relying on deep merging map values. A thing I'd like to eventually make is a way to generate a game using a website.
This app is auto deployed using heroku and using github to run tests. In order to set this up you need to:
- Create a new heroku project
- Add a DB connection
- Add a new DB_URL env var to the app (Heroku's default DATABASE_URL can't be parsed easily by ragtime or next.jdbc)
- Set up a twilio account, and secure a number
- point the sms webhook to the deployed app
https://adventures-in-texting.herokuapp.com/
Interact by texting (608)-471-6866
- POST
/api/v1/sms
, expects two query parameters: From and Body - GET
/
, html page
core
- main app entrypoint, where the service livesengine
- parses out a request string into a command map the game can work withtwilio
- generates a TwiML payload from a response stringdb.migrations
- runs migrations on startupdb.game
- handles upsert, delete, and getting game instancesgame.core
- dispatches on command value and returns an updated game with a responsegame.message
- holds default messages for error states etcgame.story
- contains the default game map as well as helper functions to deal with handling game state
- use - use an item in your inventory
- look - Get descriptions for the room etc
- take - Pick up an item
- guide - "Help" functionality, help means something special to twilio so this is a way to get through that
- inventory - see items you've picked up so far
- meow - do it for the bit
- restart - reset your game state
Nested under :interactions
items are represented by a collection of applicable commands
{:key {:look "look at the key"}}
The keys are the name of the location and are nested directly under the :maps
key.
{:maps
{:location1 {}
:location2 {}}}
The main things in a location are interactions and initial description.
{:initial "You walk into the room"
:interactions {:key {:look "It's a key"}}}
Note that under interactions
there should be a default key to provide backup values for when things are tried in certain rooms.
run tests by running
lein test
Copy the env file and update the DB_URL to have a jdbc connection string
cp env.example .env
Then source the env file
source .env
Start the DB
docker-compose up -d
Start the server
lein ring server
Go to http://localhost:8080 to see the homepage
or test the sms endpoint
http POST localhost:8080/api/v1/sms From==woof Body=="look around"