Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game code is circular dependant. #83

Open
Naviary2 opened this issue Jul 14, 2024 · 5 comments
Open

Game code is circular dependant. #83

Naviary2 opened this issue Jul 14, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@Naviary2
Copy link
Member

Naviary2 commented Jul 14, 2024

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!

@Naviary2 Naviary2 added the enhancement New feature or request label Jul 14, 2024
@Heinrich-XIAO
Copy link
Contributor

This sounds like an enhancement for making unit tests.

@Naviary2
Copy link
Member Author

dependancyGraph

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.

@Naviary2
Copy link
Member Author

Naviary2 commented Nov 3, 2024

Once the new gamefile format is finished, and the server is able to borrow the same logic to perform legal move calculations, that opens the door for #25 , as that feature should wait until the new gamefile format, because games will need to be converted into BigInts instead of integers when people move beyond Number.MAX_SAFE_INTEGER. @Idonotus I'm not sure if you're currently working on a new format or not, I know you had a blueprint, but let's just keep this in mind!

@Heinrich-XIAO
Copy link
Contributor

Heinrich-XIAO commented Nov 5, 2024

dependancyGraph

That looks like a mess, but I've seen worse.

@Naviary2
Copy link
Member Author

Naviary2 commented Nov 6, 2024

dependancyGraph copy

Updated dependancy graph. There's still a lot of red, but it does look better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants