Check out Janggi (Korean Chess), our featured variant for December, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Jocly. An html-based web platform for playing 2-player abstract stategy games.[All Comments] [Add Comment or Rating]
H. G. Muller wrote on Mon, Feb 13, 2023 09:42 AM UTC in reply to Fergus Duniho from Sun Feb 12 10:32 PM:

Well, I have managed now to port your custom files for Cavalier Chess to the Jocly installation on my website ( http://hgm.nubati.net/jocly/jocly-master/examples/browser/control.html?game=cavalier-chess ), from which I think the installation here was cloned. I uploaded the same files to the CVP server, but I cannot see the changes even if I access the files directly through the browser and refresh the browser cache. I can see the changes with SCP, so I know they must be there. (Even on my own website it is a pain to make changes active; normal cache flushing on the Jocly page by Shift+Reload does not affect the browser caching of .js files that are not directly linked from the page, but which are accessed by JavaScript. So I have to surf to the changed .js files themselves, and then do a Shift+Reload on those, and then run Jocly again.)

Anyway, the relevant files are:

  • /play/jocly/dist/browser/jocly-allgames.js
  • /play/jocly/dist/browser/games/chessbase/cavalier-chess-config.js
  • /play/jocly/dist/browser/games/chessbase/cavalier-chess-model.js
  • /play/jocly/dist/browser/games/chessbase/cavalier-chess-view.js

The way it works is this: Each new game needs to be declared through a line in the jocly-allgames.js file, which provides enough information to generate the entry in the list of "other Jocly games" (so a thumbnail image, name, and short description), and allows Jocly to find the *-config.js file that defines what other 'resources' the game actually needs. I have the feeling that the config file might only be used during 'compilation' (i.e. creating in jocly/dist/ the 'library' of uglified .js files from the source code in jocly/src/), but I am not entirely sure. To run the game Jocly needs a *-model.js and a *-view.js file, but these files in the chessbase directory are not just uglified versions of the custom files supplied by the user, but an uglified concatenation of all files that the *-config.js (or the html page, in the old way of embedding) mentions as necessary for the model or the view. This uglified concatenation must have been created during compilation as  per specification in the *-config.js file; Jocly is then perfectly able to derive the filename of the *-model.js and *-view.js filenames from the game name, as it would create the filename of the *-config.js file from it.

Anyway, my procedure for hacking in new games is that I once identified the uglified part of the custom model and view source files in the uglified model and source for that game, and deleted that part. I can then replace it by the custom source files of other games. This only works if the new game uses the same standard files in addition to the custom code. (So I could not do hexagonal games, because the variant I used as a template has a rectangular board. One should start with uglified files that use the same standard files.)

The cavalier-chess-model.js and cavalier-chess-view.js are now excellent templates for other chess variants with 'regular' rules; almost all variants I had added this way have some rules that were not supported by the standard Jocly scripts (like piece drops in Shogi, extinction royalty in Spartan Chess, locust and multiple capture in Chu Shogi) so that I also needed to hack the chessbase.js part of the model files for those (or even redefine routines in the Jocly core). Even for Team-Mate Chess I had to redefine parts of the Jocly core for getting more natural move animation of bent sliders (turning a corner in the right place, rather than moving in a straight line through other pieces). So these make less suitible templates.

[Edit] The changes in the files eventually became effective; there must have been some caching going on along the way through the internet. Anyway, Cavalier Chess now works in the Jocly we have on CVP (if you start it through the 'other Jocly games' link). I also copied Chu Shogi and Tenjiku Shogi here. (I had implemented those on my own Jocly install after it was cloned here.)