The game code currently is majorly circular-dependent. Issues this creates:
The game logic is not modular, we can't extract the logic for legal move calculation, check detection, checkmate algorithm, etc. to use on the server-side, without having to pull out nearly every script in the game, because they are all dependent on each other.
Solution
Gradually reduce the dependancies of each game script, one by one, reformatting them to not depend on so many other scripts.
Theoretically, scripts like math.js, gamefileutility.js, and movesscript.js should have zero or very close to zero dependancies. And main.js would be at the top of the tree, depending on everything else, but nothing depending on main.js!
I'm sharing this dependancy graph generated by Idonotus. The red scripts are all circular dependant.
222 Would work on converting each game script into an ESM, to help us make them more modular, and allow use of the same scripts on both the server and client-side.
The game code currently is majorly circular-dependent. Issues this creates:
Solution
Gradually reduce the dependancies of each game script, one by one, reformatting them to not depend on so many other scripts. Theoretically, scripts like
math.js
,gamefileutility.js
, andmovesscript.js
should have zero or very close to zero dependancies. Andmain.js
would be at the top of the tree, depending on everything else, but nothing depending onmain.js
!