archipelago

command module
v0.0.0-...-2379a7f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 11 Imported by: 0

README

Archipelago

A web-based multiplayer clone of the android game with the same name.

Screenshot Archipelago

CircleCI Codeclimate Maintainability

The game can be played at https://playarchipelago.com.

The Archipelago game

The game is about controlling islands by sending airplanes. Each players starts controlling a single island. In addition, there are multiple islands, controlled by neither player. Each island has an army, that for player-controlled islands increases over time. A player may at anytime choose to send an airplane from an island that the player controls to any other island. The airplane is created with half the army strength of the island, subtracted from the island.

As an airplane reaches its destination different things happen:

  1. If the owner of the airplane is the same as the owner of the island, then the island strength is increased by the strength of the army on the airplane.
  2. If the owner is not the same, then the army size of the island is subtracted by the army size of the airplane. This in turn can have additional effects:
    1. If the resulting island army size is <0, then the player controlling the airplane gets control of the island and the army size of the island is set to the absolute value.
    2. If the resulting island army size is == 0, then control of the island is given to the neutral player.

The game is over when there is only a single player controlling any islands or airplanes.

Project Overview

The project has two parts; A backend server written in go, and a frontend created in JavaScript. Communication between the backend and frontend is done over binary WebSockets messages, serialized using protocol buffers defined in the proto directory.

Frontend

The frontend project is found in the web directory. It is based on Pixi.js for WebGL/canvas rendering. The frontend is written in ES6, and is transpiled to ES5 via Babel. Yarn is used to manage dependencies, and Webpack4 is used to bundle the frontend application (including js, css and images).

Backend

The backend is written in go and uses standard go modules for managing dependencies. The backend relies primarily on the go standard library, but uses Gorilla/WebSocket for WebSocket handling, Logrus for logging, and pkg/errors for better error handling.

The backend code is found in the lib directory.

Running the Project

To run and build the project, make sure to have the following installed:

Then clone the project:

$ git clone git@github.com:verath/archipelago.git

This will include all dependencies required for the backend code. However, the client side dependencies are not included in the repo and have to be fetched via yarn, and then built/bundled:

$ cd web
$ yarn install
$ yarn run build:prod

Now run the project as a go project, e.g. using go run from the root directory:

$ go run main.go -debug -serveStatic -skipWSOriginCheck

This should start the server, and make it available at http://localhost:8080 by default.

Developing

Protocol Buffers (protobuf)

To regenerate the protobuf files it is necessary to install the protobuf compiler (protoc) and the go proto compiler plugin (protoc-gen-go), see the protoc-gen-go project for instructions. dcodeIO/protobuf.js is also required but should already be installed via yarn.

With these tools installed and available on the path, use the proto/build.ps1 PowerShell script to build both the server (.pb.go) and the client (.js, .d.ts) files.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL