/catventure-game

Catventure! is a React browser-game where you assemble a team of fantasy role-playing-game cats, find treasure, and engage in JRPG-style turn-based combat.

Primary LanguageJavaScript

Catventure!

Catventure logo

Catventure! is a browser-based video game where you assemble a team of fantasy role-playing-game cats and go on a catventure! This videogame is built entirely in React.js with no external game engines. The user can add cats to their team, find treasure and engage in JRPG-style turn-based combat.

RPG gameplay demo

Deployed Link

Technical Details

Catventure! is a full-stack app with a React front end, RESTful API routes using Express.js, a Node.js backend and a MongoDB database.

For this application we built our own server and did not use any external API's. Our server utlizes Mongoose ODM, Bcrypt, Express, and JWT (Json Web Token/JWT Decode). JWT and Bcrypt handle our user authentication and password encryption. All of our data stems from our two models, which are our User model and our Cat model. The cat model is attached to our user model in the form of an array, allowing the user to save their cats and have their game progress/data persist. Since we used React for this project, our routes/controllers are only serving up one html page. The bulk of the work our server is doing is serving up and storing data relating to the user and the user's cats.

Screenshots

Full Screen Mobile UI 1 Mobile UI 2


Time Gating

One of the signature features of browser-based gamees is the implementation of time-gating mechanics, which enforce that users can only access certain benefits once per a set time interval, whether it's one hour or one day.

Cat Tavern

And from a game-balancing standpoint, we did not want our users to be able to consistently refresh the page to either spawn new cats or open infinitely many treasures. That led us to time-gating the user, which you can see on lines 99 & 101. We have an attribute in our user model called "lockoutTavern" in which the first time this function runs, the exact time/date are saved to our database.

Time gating function code snippet

Essentially, once the first set of three random cats is spawned into the Tavern page, the user is stuck with those cats for a set amount of hours. We conditionally render 1 of 2 things based on lockout times. We either render a fresh set of cats, or the first set of cats that spawned the first time they entered the Tavern. This function (and the jsx it affects) was a valuable lesson in state management/conditional rendering.

Time gating check code snippet

This time-gating method was similarly used to show/hide and allow/prevent opening of treasures on the Cave page.

Cave


Turn-Based RPG Battles

Inspired by beloved retro-JRPG franchises like Final Fantasy, Catventure! features turn-based battles. As a React app, this requires that the UI and sprite animations are controlled by multiple independent React useState hooks, that are passed between the various functions necessary to execute the turn-based battle mechanics.

Turn-based battle

In order to reduce the quantity of arguments that must be passed, associated useState hooks (for sprite animations, UI elements, or sound effects) were consolidated into single objects that could be passed to GUI behaviors that reflected the scripted mechanics occurring within the code.

Consolidated UI React useStates


Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

  • IDE to view/edit source code (e.g. Visual Studio Code).
  • Node.js.
  • MongoDB.

Installing

  1. Clone repository.
  2. Navigate to catventure-game directory in terminal.
  3. npm install dependencies.
  4. Run locally with npm run develop.
  5. Open http://localhost:3000/ in web browser.

Deployment

  1. Generate optimized build with npm run build.
  2. Upload to webhosting service, such as Heroku.
  3. Attach MongoDB hosting service, such as MongoDB Cloud.

License

License: MIT

MIT License

Built With

Authors

Emily Dorgan Vince Lee Derek Banister
- Portfolio - Portfolio - Portfolio
- Github - Github - Github
- LinkedIn - LinkedIn - LinkedIn

Acknowledgments

Catventure Logo