You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DOCUMENTATION.md
+23-28Lines changed: 23 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,6 @@ In the root of this project you'll find configuration files as well as three fol
11
11
-[public →](public/) Copied to the web root as-is
12
12
-[tests →](tests/) Contains all tests for the game engine. Nothing for the UI. Run `npm test`.
13
13
14
-
## Coding style
15
-
16
-
- JavaScript (ES modules)
17
-
- Web components and Preact HTM for rendering
18
-
- Immer for immutable state updates
19
-
- Error handling: Use try/catch sparingly; prefer validation and early returns
20
-
- JSDoc for documentation
21
-
- No semicolons, single quotes, tabs
22
-
23
14
### Game
24
15
25
16
#### Game State
@@ -82,28 +73,10 @@ Every card must define two exports:
82
73
- default: the card
83
74
- upgrade: upgrade(card) => card
84
75
85
-
#### dungeon-encounters.js
76
+
#### dungeons.js
86
77
87
78
Contains different monsters, room and dungeons. All created with methods from the game.
88
79
89
-
### UI
90
-
91
-
The UI is made with htm and preact. I've tried not to create too many components and abstractions, although this might come back to haunt us.
92
-
93
-
Everything starts with [index.html](https://github.com/oskarrough/slaytheweb/blob/main/index.html). When loaded,
94
-
we show a splash/welcome screen as defined in [index.js](https://github.com/oskarrough/slaytheweb/blob/main/src/ui/index.js).
95
-
96
-
Next, when you tap "Start Game", we load [app.js](https://github.com/oskarrough/slaytheweb/blob/main/src/ui/app.js).
97
-
This one connects everything and manages the game state.
98
-
99
-
#### Animations
100
-
101
-
See [animations.js](src/ui/animations.js). Most are made with gsap.
102
-
103
-
#### Sounds
104
-
105
-
See [sounds.js](src/ui/sounds.js) using the Web Audio API.
106
-
107
80
## Tests
108
81
109
82
Scripts are checked with [eslint](https://eslint.org/), formatted with [prettier](https://prettier.io/) and tested with [ava](https://github.com/avajs/ava).
@@ -118,10 +91,32 @@ Additionally you can run `npm run lint` to automatically format all scripts acco
118
91
119
92
You can also just run ava directly and do as you please. Example: `npm test tests/actions.js --watch`
120
93
94
+
## UI
95
+
96
+
The UI is made with web components, htm and preact. I've tried not to create too many components and abstractions, and copy/paste more, although this might come back to haunt us.
97
+
98
+
In order to have easy HTML layouts (and more :tm:), we have Astro set up here. This means you can define new routes in src/ui/pages.
99
+
100
+
### Animations
101
+
102
+
See [animations.js](src/ui/animations.js). Most are made with gsap.
103
+
104
+
### Sounds
105
+
106
+
See [sounds.js](src/ui/sounds.js) using the Web Audio API.
107
+
121
108
## Backend
122
109
123
110
With the integration of https://github.com/oskarrough/slaytheweb-backend in `game/backend.js`, you can choose to save your current run state in the Slay the Web database. Nothing but game state & date is stored. All runs are visible on `stats.html`.
124
111
125
112
## Footnotes
126
113
127
114
In the beginning I made this diagram of how the game works. It's probably outdated now but keeping it here for reference: https://kinopio.club/slay-the-web-Dh3xUjjHbol7RbCuqZQDn.
115
+
116
+
- JavaScript (ES modules)
117
+
- Web components and Preact HTM for rendering
118
+
- Immer for immutable state updates
119
+
- Error handling: Use try/catch sparingly; prefer validation and early returns
0 commit comments