JSJitsu / ai-battle-website

Run and replay game battles.
https://jsfight.club
12 stars 18 forks source link
ai game hacktoberfest

Build Status

Javascript Fight Club

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.

Playing The Game

Visit https://jsfight.club to play the game. You do not need a copy of this repo to play.

Development

Via Docker (recommended)

See the Docker website for more information.

Copy the Configuration

cp config-template.js config.js

Docker Compose

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.

Raw Docker

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.

Via Vagrant (might be outdated)

See the Vagrant website for more information.

vagrant up
vagrant ssh

Then, navigate to the /vagrant directory.

Running a Battle

To run a test battle:

yarn node gamerunner/run-test-game.js

Starting the Web Server

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)

Changing the Website

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.

Changing the Database Schema

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.