@@ -6,33 +6,30 @@ are implemented entirely in client-side JavaScript, backed by IndexedDB.
66
77Copyright (C) ZenGM, LLC. All rights reserved.
88
9- Email: jeremy@zengm.com
9+ Email: < jeremy@zengm.com >
1010
1111Website: < https://zengm.com/ >
1212
1313Development: < https://github.com/zengm-games/zengm >
1414
1515Discussion:
1616
17- * < https://www.reddit. com/r/BasketballGM/ >
18- * < https://www.reddit.com/r/Football_GM/ >
19- * < https://www.reddit.com/r/ZenGMBaseball/ >
20- * < https://www.reddit.com/r/ZenGMHockey/ >
21- * < https://zengm. com/discord/ >
17+ * [ Discord ] ( https://zengm. com/discord/ )
18+ * Reddit: [ Basketball GM ] ( https://www.reddit.com/r/BasketballGM/ ) ,
19+ [ Football GM ] ( https://www.reddit.com/r/Football_GM/ ) ,
20+ [ ZenGM Baseball ] ( https://www.reddit.com/r/ZenGMBaseball/ ) ,
21+ [ ZenGM Hockey ] ( https://www.reddit. com/r/ZenGMHockey/ )
2222
2323** This project is NOT open source, but it is also not completely closed. Please
2424see [ LICENSE.md] ( LICENSE.md ) for details.**
2525
26- ## Development Info
26+ ## Who is this for?
2727
28- If you just want to play the game, go to < https://zengm.com/ > . Instructions
29- below are for developers who want to run a copy locally so they can make changes
30- to the code.
28+ If you just want to play a game, go to < https://zengm.com/ > . Instructions below
29+ are for developers who want to run a copy locally so they can make changes to
30+ the code.
3131
32- If you want to contribute but get stuck somewhere, please contact me! I'm happy
33- to help.
34-
35- ### License and Contributor License Agreement
32+ ## License and contributor license agreement
3633
3734** This project is NOT open source, but it is also not completely closed. Please
3835see [ LICENSE.md] ( LICENSE.md ) for details.**
@@ -48,81 +45,64 @@ Make a copy of the form, fill in your information at the bottom, and send an
4845email to jeremy@zengm.com with the subject line, "Contributor License Agreement
4946from YOUR_NAME_HERE (GITHUB_USERNAME_HERE)".
5047
51- ### Step 1 - Installing
52-
53- Make sure you're using a recent version of [ Node.js] ( https://nodejs.org/ ) , older
54- versions probably won't work. Then, all of the tooling used in development can
55- be set up by simply installing [ pnpm] ( https://pnpm.io/ ) and
56- running:
57-
58- pnpm install
59-
60- from within this folder.
48+ ## Setup
6149
62- ### Step 2 - Building
50+ First install [ Node.js ] ( https://nodejs.org/ ) 22 and [ pnpm ] ( https://pnpm.io/ ) 9.
6351
64- To build the app along with all its assets, run
52+ Then within this folder run:
6553
66- pnpm run build
54+ pnpm install
6755
68- However during development, you probably would rather do
56+ to install dependencies and:
6957
70- pnpm run start-watch
58+ pnpm run dev
7159
72- which will start the server and watch JS and CSS files for changes and
73- recompile. This simply runs both ` pnpm run start ` and ` pnpm run watch ` together,
74- which alternatively can be run separately if you wish.
60+ to start the dev server and watch the source code for changes.
7561
7662By default this will build the basketball version of the game. For other sports,
77- set the SPORT environment variable to "football", "baseball", or "hockey", like:
78-
79- SPORT=football pnpm run start-watch
80-
81- Open ` package.json ` to see all available development scripts.
82-
83- ### Step 3 - Running
63+ set the ` SPORT ` environment variable to ` football ` , ` baseball ` , or ` hockey ` ,
64+ like:
8465
85- To run the game locally, you need some way of running a web server to display
86- the content. There are currently two ways to do it. It doesn't matter which you
87- use as long as you can get it to run on your computer.
66+ SPORT=football pnpm run dev
8867
89- #### 1. Node.js (easiest)
68+ The ` dev ` script will also tell you a URL to open in your browser to view the
69+ game, < http://localhost:3000 > unless that port is already in use.
9070
91- Run
71+ ## Other dev info
9272
93- pnpm run start
94-
95- and point your browser to < http://localhost:3000/ > (or it will use a different
96- port if 3000 is already used by somethign else). If you use the command `pnpm
97- run start-watch` from above, then running the command ` pnpm run start` is not
98- necessary.
99-
100- #### 2. Apache
101-
102- The mod_rewrite rules in ` .htaccess ` let the game run in Apache. Everything
103- should work if you point it at the ` build ` folder with mod_rewrite enabled.
104-
105- ### Step 4 - Testing
73+ ### Tests
10674
10775TypeScript and ESLint are used to enforce some coding standards. To run them on
108- the entire codebase, run
76+ the entire codebase, run:
10977
11078 pnpm run lint
11179
11280Integration and unit tests spread out through the codebase in * .test.ts files.
113- Coverage is not great. They can be run from the command line with
81+ Coverage is not great. They can be run from the command line with:
11482
115- pnpm test
83+ pnpm run test
11684
11785There is also a single end-to-end test which creates a league and simulates a
118- season. To execute the end-to-end test, run
86+ season. To execute the end-to-end test, run:
11987
12088 pnpm run test-e2e
12189
122- For the end-to-end test, by default it is basketball. If you want it to do
123- football, stick ` SPORT=football ` in front.
90+ Like the dev command, you can stick ` SPORT=football ` or whatever in front of
91+ this command to run it for a non-basketball sport.
92+
93+ ### Git workflow
94+
95+ If you want to contribute changes back to the project, first create a fork on
96+ GitHub. Then make your changes in a new branch. Confirm that the tests
97+ (hopefully including new ones you wrote!) and lint scripts all pass. Finally,
98+ send me a pull request.
99+
100+ It's also probably a good idea to create an [ issue on
101+ GitHub] ( https://github.com/zengm-games/zengm/issues ) before you start working
102+ on something to keep me in the loop. I don't want you to spend lots of time on
103+ something that I don't want to put in the game!
124104
125- ### Code Overview
105+ ### Code overview
126106
127107This is a single-page app that runs almost entirely client-side by storing data
128108in IndexedDB. The core of the game runs inside a Shared Worker (or a Web Worker
@@ -149,7 +129,7 @@ In both the worker and UI processes, there is a global variable `self.bbgm`
149129which gives you access to many of the internal functions of the game from
150130within your browser.
151131
152- ### Shared Worker Debugging
132+ ### Shared Worker debugging
153133
154134As mentioned above, the core of a game runs in a Shared Worker. This makes
155135debugging a little tricky. For instance, in Chrome, if you ` console.log `
@@ -161,45 +141,6 @@ In any browser, if you have two tabs open and you reload one of them, the worker
161141process will not reload. So make sure you close all tabs except one before
162142reloading if you want to see changes in the worker.
163143
164- ### Service Worker
165-
166- This only applies if you use Apache, not if you use ` pnpm run start ` !
167-
168- A service worker is used for offline caching. This can make development tricky,
169- because if you load the game in your browser, make a change, wait for
170- build/watch to finish, and then reload... you will not see your change because
171- it will cache the original version and then not update it on a reload. This is
172- the normal behavior for service workers (they only switch to a new version when
173- you actually close the website and reopen it, not on a reload), but it makes
174- development annoying.
175-
176- To work around that, in Chrome you can [ use the "Update on reload" option] [ 1 ]
177- and keep your devtools open. Then reloading will always get you the latest
178- version.
179-
180- Even with that, ctrl+shift+r may be a good idea to make sure you're seeing your
181- latest changes.
182-
183- [ 1 ] : https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#update_on_reload
184-
185- ### Git Workflow
186-
187- If you want to contribute changes back to the project, first create a fork on
188- GitHub. Then make your changes in a new branch. Confirm that the tests
189- (hopefully including new ones you wrote!) and ESLint all pass. Finally, send me
190- a pull request.
191-
192- It's also probably a good idea to create an [ issue on
193- GitHub] ( https://github.com/zengm-games/zengm/issues ) before you start working
194- on something to keep me in the loop.
195-
196- ## Less Important Development Info
197-
198- ### Sport-specific stuff
199-
200- Abbreviations of stats should be done like basketball-reference.com and
201- football-reference.com stat pages. For instance, "defensive rebounds" is "drb".
202-
203144### Thank you BrowserStack
204145
205146Shout out to [ BrowserStack] ( https://www.browserstack.com/ ) for helping with
0 commit comments