This repository contains the code that runs the website. By forking this, you will be able to develop the site, use real (GitHub player AI code), or use test data to generate a battle.
Visit https://jsfight.club to play the game. You do not need a copy of this repo to play.
See the Docker website for more information.
cp config-template.js config.js
docker-compose up
Note this may take a few moments to set up. The server is being configured, updated, and additional dependencies are being installed.
docker build -t ai-battle-website .
docker run -it -v $(pwd):/app -p 8080:8080 ai-battle-website
Once inside, running ./docker-startup.sh
will get everything started. It should start the PostgreSQL service, install npm modules, create the database and tables, run a test game, and start the web server. Access the site at http://localhost:8080/.
If you make changes to any .tag files, they will need to be built again using yarn run compile-tags
before the changes appear.
See the Vagrant website for more information.
vagrant up
vagrant ssh
Then, navigate to the /vagrant directory.
To run a test battle:
yarn node gamerunner/run-test-game.js
yarn run build
You must build one time before starting the server in order to provide the game engine to the browser.
To start the server without connecting to GitHub, run:
yarn start
Run yarn start --help
for additional start-up options.
Once it's running, you can navigate to http://localhost:8080/ to view the site. (if you're using the Vagrant environment, navigate to http://localhost:4000/ instead)
There are currently no build steps, so once the server is up and running, only changing the website UI files is enough to see the changes. When making changes to the server, it will need to be restarted each time.
Database changes and queries are handled by http://knexjs.org/.
To create a new Knex migration:
$ yarn run migrate:make migration_name
Example:
Suppose you want to add the column 'foo' to 'players' table:
$ yarn run migrate:make add_foo_to_players
The migration file will be created under ./database/migrations.
IMPORTANT: Always add the up and down changes to the Knex migration file. This is what will allow easy rollbacks in case something goes wrong.