Developing

Otter is mostly written in Rust.

The web UI frontend is written in Typescript, with a small amount of Rust support code delivered via WebAssembly.

The HTML and SVG skeleton is in a templating language called Tera, which is a jinja-like but from the Rust community.

Ad-hoc testing, playing about, etc.

In one shell:

     target/debug/daemon-otter server-test.toml

The server does not daemonise, and the default config there makes it quite verbose. So, in another shell:

    target/debug/otter                                               \
        --account server: --config server-test.toml --spec-dir=specs \
        --game test server::test reset --reset-table demo

    target/debug/otter                                               \
        --account server: --config server-test.toml --spec-dir=specs \
        --game server::test join-game

The URL printed can then be visited in a local browser.

Resetting/restoring things after tests, updating server, etc.

After the server is updated, you can just ^C and restart it. Games are constantly saved (although there is an up-to-1s lag on the most frequently updated game state).

If you want to clear out the server state, delete the files [ag]-* and accounts. NB that you should do this with the server not running, because the server has most of that information in memory and will like to write it out again.

If you update Typescript (JS code) you will need to rerun make to rebuild the JS output.

Apart from that, if you update JS or WASM code or Tera templates, you do not need to restart the server - it will pick up changes automatically.

When testing, you do not need to make bundled-sources more than once, at the beginning. So don’t, because it’s slow. But you definitely should run it for every update if you make a deployment for other people to use. Otherwise you might be running a privately modified server without offering your users its source code. See LICENCE.

If you Do Something to the output from cargo, you should rm stamp/*, since the Makefile won’t notice, otherwise, that the relevant cargo rune(s) need to be re-run. Needlessly deleting all the stamp files wastes only a handful of seconds (on my stupidly fast laptop). Deleting the stamp files is not needed if you simply edit Rust source files.

Adding shapes (pieces, cards, etc.) to the builtin library

(Consider making an uploadable game bundle instead.)

Otter’s builtin shape libraries use SVGs. The sources for the SVGs are all in the otter source tree, in the library/ directory.

Each shape is listed in one of the library/*.toml files, in a files entry. These are shape library catalogues, although in a slightly different format to the ones found in bundles. (In particular, the builtin libraries are not processed with Tera.)

You can preview the shapes, including any changes you make, without a whole game server, by running make -j8 shapelib, and looking at templates/shapelib.html. As above, this make rune will print the file:// url for you.

See the build instructions for information about how to install the tools you will need.

Some of these SVGs were scraped from Wikimedia. The scraper machinery can perhaps be adapted to scrape SVGs from elsewhere.

You can also add your own SVGs in the library/edited/ directory. If you do that, please make sure to include the actual source code there too. If you copied or adapted an SVG from somewhere, note the details of where you got it (eg, in a git commit message).

Contributions should be via git branch, eg a merge request on Salsa: https://salsa.debian.org/iwj/otter

NB that shapes must come with a licence compatible with CC-BY-SA 4.0 or GNU AGPLv3+. See LICENCE for more information about copyright status.

Automatic in-browser tests (wdriver)

make check runs all the tests; make wdt runs only the webdriver (in-browser) tests. You can run an individual test with a rune like this:

  OTTER_TEST_LOG=otter_webdriver_tests=trace CARGO_MANIFEST_DIR=~ian/Rustup/Game/server time target/debug/wdriver --test=wdt-simple --geckodriver-args=

(This rune has some example logging options in it, for you to change if you like. You can omit the CARGO_MANIFEST_DIR for an in-tree non-privsep build.) After a test has run, you can find screenshots, etc. in tmp/wdt-simple or whatever. You can restart the same game server setup as the test used, with the state left by the test, with a rune like this:

  target/debug/daemon-otter tmp/wdt-simple/server-config.toml

and then play with it at these urls:

  http://localhost:8000/?kmqAKPwK4TfReFjMor8MJhdRPBcwIBpe
  http://localhost:8000/?ccg9kzoTh758QrVE1xMY7BQWB36dNJTx

(Yes, those are fixed game access links, hardcoded by the tests. You can bookmark them.)