If you're looking to contribute, first: thank you very much ^^! Read below to get a feel of the codebase, and look at some issues for examples of things to help with.
- Clone the repo
- Install dependencies with
yarn
- Run the dev server with
yarn dev
- Open http://localhost:3000 with your browser to see the result.
- Next.JS
both
– Backend framework built for react - tRPC
both
– Really nice way to make APIs with type-safety and Next.js SSR support - Zustand
frontend
– Really nice state management library for react (see: transient updates) - Framer Motion
frontend
– Used for animating elements - Tone.js
frontend
– Audio library, eventually will be used for music - Prisma
backend
– ORM for the postgres database
I use the free-tier of everthing listed here
- Vercel – Pretty good serverless hosting with great Next.JS support
- Upstash – Redis cache with a sufficient free-tier and low latency with Vercel
- PlanetScale – Really cool postgres host with an interesting git-like branch system for schemas
- Pusher – Lets you push events to your clients fast without hosting your own WebSocket server, has a builtin authentication system
.
├─ components/
│ └─ client/ - All the gameplay UI
│ └─ animations/ - All the animation code
│
├─ hooks/ - Mostly stores, but also utility hooks
│ ├─ useClientStore.ts - Where client data is stored
│ └─ useGameStore.ts - *Where game host data is stored and saved locally
├─ lib/ - Code for both frontend and backend
│ ├─ defs/ - The actual card/sigil data exists
│ ├─ engine/ - All the core game logic
│ ├─ online/ - Zod schemas for engine types
│ ├─ spritesheets/ - Defines the locations of things in each spritesheet
├─ pages/ - Root components for each page
│ ├─ _app.tsx - Global wrapper component for all pages
│ ├─ _document.tsx - html <head> stuff
│ └─ 404.tsx - 404 page
├─ prisma/ - Database schema
├─ public/ - Assets
└─ server/ - Serverside code
├─ trpc/ - API endpoints
├─ redis/ - Redis scripts to do some operations in one request
├─ auth.ts - Discord NextAuth handler
└─ kv.ts - Some reuseable cache methods
* Client-side game hosting current only exists in the playtest page
To make things hopefully easier for you, here's a breakdown of terms I use around the codebase.
-
Fight
- A battle, keeps track of basic rules (hammer limits, lives, etc), which cards are on field/in hand, player score, who's turn it is, etc. -
Side
- At the moment, eitherplayer
oropposing
1 -
Turn
/Phase
- At any given moment of aFight
it is one of theSide
's turn -
Event
- Represents any action that mutates aFight
-
Effect
- Something that reacts to anEvent
, either by mutating/canceling it or creating new events -
"settling" an event - Calling all the effects of an event, and then taking the finalized event and applying it's mutations to a
Fight
-
Action
- Any type of routine user-input from theSide
of the current turn. -
Request
+Response
- An event may call for immediate user input of eitherSide
, for example: the [Bomb Latch] sigil may ask it's owner where to place [Detonator], in which case all game logic is halted until it receives aResponse
. -
FightPacket
- Represents a summary of fight progress resulting from anAction
orResponse
. Eg: everyEvent
after yourbellRing
action: starting with thephase: [player, pre-attack]
event, and ending withphase: [opponent, draw]
Event. -
Host
- TheHost
is where the Fight logic is ran, usually server-side unless its a local game. -
Client
- The client keeps track of it's ownFight
instance, and updates it everyFightPacket
-
Adapter
- In charge of retrieving anything that may be externally stored: the player's decks, their shuffle order, etc. -
Tick
- A short-lived wrapper around aFight
, keeps track of whichEvent
s are settled and which still need to be settled. When aRequest
is raised, this will also store abacklog
ofEvent
s that still need to be settled after the respectiveResponse
is received
Footnotes
-
yes, server-side, one of the players is the canonically the antagonist ↩