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

javscript should target node.js #686

Closed
wants to merge 2,078 commits into from
Closed

javscript should target node.js #686

wants to merge 2,078 commits into from

Conversation

mojoaxel
Copy link
Collaborator

@mojoaxel mojoaxel commented Mar 27, 2022

These games are meant as simple CLI scripts (see #117 (comment)).
I therefor think javascript should target mainly node.js instead of the browser (in opposite of whats currents implemented).

  • So, I started porting the existing javascript implementations to be simple node-scripts.
  • I also introduced very basic common function like print, input and tab. (see Intellij complains about dependencies in ConsoleTest.kt. #548 (comment)).
  • I decided to use modern ES-modules instead of the legacy commonCJ node-syntax. That way the scripts can easily load the common function (also in the browser). For this to work the files have a *.mjs extension.
  • To not loose the ability to play the games in the browser I created a simple node-terminal-emulator that lets run our node-scripts directly in the browser. For this to work I overwrote the default process.stdout/stdin of node and hocked them up to some browser mockups. I know this is very hacky but it works just fine (at least for the simple scripts I've tested).

Here is an example of the emulator in action: https://mojoaxel.github.io/basic-computer-games/00_Common/javascript/WebTerminal/terminal.html#74_Rock_Scissors_Paper/javascript/rockscissors.mjs

This way we have the best of both worlds:

  • ✔️ The JavaScript implementations get very slim and easy to ready also for beginners. All the browser-specific stuff is gone!
  • ✔️ The scripts can simply be executed and played in every shell, just like e.g. the python or perl implementations.
  • ✔️ We still have the possibility to run the games in the browser.
  • ✔️ The terminal-emulator even feels more "real" because the input fields are gone.
  • ❌ It is no longer super easy for the user to run the games locally IN THE BROWSER, but I think that is ok ant it is still possible using the emulator.

This is only a DRAFT for now and I need to clean it up a little more over the next days.

Please let me know what you think!!

dave-burke and others added 30 commits March 3, 2022 22:10
Just because it's fun.
ruby version of 92_Trap
Apply black to the 00_Utilities/markdown_todo.py
Remove byte-order-marker pre-commit check as there would be
many adjustments necessary
The break statement would prevent infinite loop when player choose 'o' or 'O'
MartinThoma and others added 20 commits March 23, 2022 18:44
Python: Add tests for bounce and bowling
- Rename files to follow PEP8 convention / make them testable
- Add type annotations
- Fix Flake8 issues
- Variable naming
- Add unit test
Introduces a new error message:
    ({start_x}, {start_y}) has no legal moves. Choose again.

Closes #677

Additionally, add type annotations
Checkers (Python): Check if field has valid moves
updated implementation with proper OO design, provided link to video
Boxing (Python): Split configuration from logic
* Add Unit Test
* Add Type Annotations
* Use variable/function names
CI: Prevent large files from being added
* Use functions to structure code
* Remove 1-line function
* Use dataclass
* Replace dictionaries by a list
@mojoaxel mojoaxel force-pushed the 74-minimal-terminal branch 3 times, most recently from 10aaf69 to 13483fb Compare March 27, 2022 21:29
implemented minimal html terminal emulator
@coding-horror
Copy link
Owner

This is all fine, but we definitely want to be able to run the games in the browser as the end state for JS, somehow.. as long as that is retained it is all good!

@MartinThoma
Copy link
Collaborator

Hi @mojoaxel , I didn't close this on purpose. This was done automatically when the history was re-written for #681

I didn't see this PR 🙈 As there were super many changes, I hope those were done automatically 🤞 If not and if this was a bigger amount of work, we could temporarily restore the old state.

Otherwise, I suggest you to do the following:

  1. Manually copy the files you worked on (hopefully not that many)
  2. delete your local clone of the repository (except for the files you were working on)
  3. Clone again
  4. Add your files back; make a new PR

Sorry for the inconvenience.

@mojoaxel
Copy link
Collaborator Author

I didn't close this on purpose.

No problem! I'll rebase my branch.
Sadly I can not reopen this pull request (maybe @coding-horror can?). I'll propably open a new one!

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

Successfully merging this pull request may close these issues.

None yet