mjhouse / warfare-rs

A strategy game written in rust
GNU General Public License v3.0
0 stars 0 forks source link

Warfare

This is the codebase for a multiplayer, 2d, turn-based strategy wargame tentatively titled Warfare (imaginative, I know). It's written in rust (because I like rust) and uses the bevy game engine. Warfare is set in the modern day (using weapons and units currently available in 202X) and is intended to be a highly granular, detailed game.

You can see the latest progress on YouTube.

Proposed Features

I'll expand this list as I go along.

Implemented Features

Goals

The goal here is total battlefield simulation. Everything from the rockiness of the soil to cloud cover should have some impact (no matter how small) and everything should interact with everything else. Below, I've broken the gameplay down into a few large categories to make it easier to discuss.

(from here on, present tense is used even if the feature hasn't been implemented because I don't want to have to incrementally update these sections as features are added to the game)

Terrain and Environment

Terrain is made up of a grid of hexagonal tiles. Each tile is considered to be roughly 0.25 by 0.21 miles (0.0406 sq/mi) and has the following attributes:

(This list is subject to change)

Most attributes (with the exception of elevation and location) are determined through calculations based on other attributes. For example, fertility is calculated based on soil type, proximity to water and temperature.

Each turn is considered a single 24 hour period and will include a day and night stage. Environmental effects may apply to units differently depending on the stage (accident rates increased, visibility reduced etc.)

Every 365 turns is considered a year and each year is broken up into four seasons. The season will affect temperature, available food, accident rates and types of weather.

Units and Soldiers

Units contain some number of soldiers and a large number of attributes that modify the unit's state each turn:

(This list is subject to change)

Some of these attributes rely on others while some are entirely based on the affects of the environment. Readiness, for example, is the number of soldiers that are healthy and equipped for combat- increased accident and illness rates because of difficult terrain or injuries from combat would reduce this attribute.

Units can be merged or divided, changing their capabilities.

They have actions that they can take based on these capabilities, and will succeed or fail based on the experience and number of the individual soldiers. For example, a unit made up entirely of support personnel might have difficulty performing an assault, while a unit of infantry may have similar difficulty recovering damaged vehicles.

Logistics and Gear

Soldiers require resources in order to maintain their readiness:

These resources are supplied by logistics and support personnel to nearby units and are either limited or unlimited.

Limited resources are created at central locations chosen by the player (supplies from the state) and distributed throughout the map or used directly by logistics personnel.

Unlimited resources are created directly by logistics units- some types of food, medical care, vehicle and equipment maintenance etc. These resources can always be provided, but cost time on the part of the logistics personnel.

Non-Goals

There are some things that Warfare doesn't care about:

There are a lot of games out there for doing the rest of this stuff, but that isn't what I want to make here.

Contributing

If you want to contribute, make a pull request.

Building

This project is developed entirely on Ubuntu 20.04. There shouldn't be any issue building on another OS and the game doesn't have any platform-specific code, but there might be issues I don't know about. To build, you need rust installed. I'm using rustc=1.53.0.

Ubuntu / Debian

To install rust, run these commands in a terminal:

curl https://sh.rustup.rs -sSf | sh || exit 1;
source $HOME/.cargo/env;

Install these dependencies in the terminal:

sudo apt install -y    \
    curl               \
    libasound2-dev     \
    libudev-dev        \
    libxcb-render0-dev \
    libxcb-shape0-dev  \
    libxcb-xfixes0-dev;

Then:

$ git clone https://github.com/mjhouse/warfare-rs.git
$ cd warfare-rs && cargo run

Other platforms

Untested and I'm not sure what dependencies you'll need. If you get Warfare to build/run on another platform, submit a merge request to update this part of the README or send me an email and I'll do it myself.

Tests

Warfare has some tests, although it's far from 100% code coverage. To execute all tests, run the following command in the root directory:

cargo test -- --test-threads=1

Some tests just print output:

cargo test -- --test-threads=1 --nocapture --show-output