lijim / monks-and-mages

Monks and Mages is a TCG-game built on React and socket.io
https://www.monksandmages.com
MIT License
17 stars 0 forks source link
game-development games react socket-io typescript

Monks and Mages

Monks and Mages is a trading card-style game inspired by Heroes of Might and Magic / Magic the Gathering. The gameplay is similar to Magic, but with vastly simplified rules. Players build decks, then pit these decks against 1-3 other players. Cards are inspired from a mix of medieval and Chinese settings

To play, visit: https://www.monksandmages.com/

This game is a work in progress. If you find bugs, feel free to let me know on the issues section of this project

Installation and Running

This game can be run locally if you have node v16.x and yarn installed globally

To get started:

yarn install
yarn dev

Go to http://localhost:3000/ to see the game (and open it in multiple browser windows to simulate multiple players)

To see sockets.io debug screen:

open https://admin.socket.io/#/sockets while running the app

This project also strives for extensive TDD and unit testing. To run tests in watch mode:

yarn test

To run tests for a particular file:

yarn test src/server/gameEngine/gameEngine.spec.ts

To run tests once through:

yarn ci

Note: with the new auth0 and DB service integrations, you may need to contact me as a project owner for additional setup help

Core technologies

This project runs on a few core technologies:

Linting on this project is done via a combination of typescript, prettier, and eslint

Unit testing is covered via Jest and React Testing Library

Gameplay

Game rules

Game philosophy

Scripts

Normally, downloading images from pexels / unsplash, processing them to be 520px in width, converting them to avif is a very manual process that we do through tools like https://squoosh.app/

Luckily, we've written some scripts to help with this process.

For all the cards in cardDb, imgSrc is not used in the components, but rather in these scripts as part of the 'download -> compress' chain. The img src's for each card are actually calculated via @/transformers/getImgSrcForCard

To run these scripts:

yarn images

To get an image into assets/images:

  1. Make sure to brew install imagemagick
  2. add a new unit / spell / token card to src/cardDb
  3. set that imgSrc to be a jpg image off the internet (starting with http)
  4. run the scripts above ^
  5. prosper!

Note: on occassion, some imageMagick conversions will rotate the image b/c of orientation. The camera may have originally recorded the picture in a different rotation, and imageMagick is trying to re-orient it:

https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=33900

To fix this, I recommend taking a screenshot of the image and pushing it through https://squoosh.app - it's hacky, but it gets the job done.

Also in terms of dev tooling on Macs, the easiest way to inspect the generated avif's is actually through Github Desktop client.