Skip to content

Game Installation

Andrew edited this page Jun 13, 2024 · 6 revisions

WARNING: This page is very much work in progress! Do not trust any of it at the moment.

Might & Fealty was designed to run on a Debian Server using Apache2, PHP5, Python, Tilecache, and PostgreSQL, with additional installations of a QGIS Server, Graphviz, and the libraries required to connect them all to each other. Installation on other OS's may be doable (Ubuntu, for instance), but are not officially supported. This installation guide will assume you're loading everything on to a freshly installed copy of Debian 10 or Ubuntu 20, and logged in as a user with sudo privileges.

Minimum System Requirements (Known Functional Configuration)

  • Ubuntu 24.04
  • A CPU -- This mostly determines how fast the game turns will process. Faster is better. More cores will allow some turn scripts to multi-thread AND assist the users with not slowing each other's access down.
  • 4 GB RAM -- Certain game scripts (mostly battles, but also some game turn code) require a considerable amount of memory, and will check php.ini's config value for max memory to use. Update that in your local config as appropriate.
  • HDD with at least 5GB of free space. -- This is mostly to allow space for the statistics logging, which will in time take up the bulk of your database--stats and messages anyways.

Because someone will ask, M&F itself runs on a 4 CPU vHost with 8GB of RAM, hosted at Linode (and yes, that's a referral link, you can web search Linode yourself if that bothers you, but using it gets you $100 credit and if you do spend $25 we get a $25 credit for referring you).

Note: The game code here assumes that there is a GIS map server at https://maps.[YOURHOST.YOURTLD]/ in order to render the map. If you want to change these, you'll need to edit map.js so that basepath points to the appropriate location. If you're setting up a development instance, I recommend just pointing them to the live game--that is, overwrite the host variable to mightandfealty.com.

Part 1 - Installing Supporting Software

Bare essentials to get this running.

  • sudo apt-get install php -- Versions 8.3+ are supported.
  • sudo apt-get install php-dom
  • sudo apt-get install php-xml
  • sudo apt-get install php-fpm
  • sudo apt-get install php-intl
  • sudo apt-get install postgresql
  • sudo apt-get install postgis
  • sudo apt-get install php-pgsql
  • sudo apt-get install unzip
  • sudo apt-get install graphviz

Part 1.1 - Map Server (Optional)

If you just want to code, overwrite the host variable in map.js before basepath is declared to set it to mightandfealty.com. If you're feeling adventurous though, you can setup your own.

  • sudo apt-get install python-flup
  • sudo apt-get install python-paste
  • sudo apt-get install qgis-server
  • sudo apt-get install libapache2-mod-fcgid

Part 1.2 - Web Server

Regardless of how you're running it, you're going to want to have a directory setup for the game. We will assume /var/www/maf for this guide but it's possible to run it out of /var/somethingelse or even your home directory if you want (but why?).

  • cd /var/www
  • sudo mkdir maf
  • sudo wget https://github.com/lemcomm/ReMaF/archive/refs/heads/main.zip
  • sudo unzip main.zip
  • sudo mv ReMaF-main/* maf
  • sudo chown -R $USER:$USER maf -- Sets maf folder permissions to youruser:yourusergroup, which is needed so you don't run composer as root (which you shouldn't do)
  • cp maf/.env maf/.env.local -- All direct configurations for M&F should be in .env.local for your local instance.

Yes, there are better ways to do this that are probably easier to maintain, but we're trying to keep this as simple as possible.

Part 1.2.1 - Local Development

If you only want to develop locally to contribute to this (or other similar) projects, you don't need a webserver. Install the Symfony Command Line, navigate to the directory you've loaded the game files into and run symfony server:start -d to run it as a background task.

Part 1.2.2 - Apache Instance

Run the following command:

  • sudo cp /var/www/maf/examples/maf.conf.example /etc/apache2/sites-available/maf.conf

Then sudo nano /etc/apache2/sites-available/maf.conf and edit it as follows:

  • Edit yourhostname.example to whatever your DNS host name is that points to this server.
  • Edit www.yourhostname.example similarly, but with a www. in front.

After that run the following:

  • sudo a2enmod proxy
  • sudo a2enmod proxy_fcgi
  • sudo a2ensite maf
  • sudo service apache2 restart

Part 2 - Configuring Supporting Software

M&F is setup to run in basically any operating environment, but it works best if PHP is given access to sufficient quantities of RAM and allowed atleast a thousand variables for web server users (this allows users to manage sufficient numbers of soldiers--we're working on making soldiers more user friendly, so this may change).

More RAM lets the turn processing happen faster and in fewer database actions, while more variables allows users to field more soldiers.

If you're using a local database, you'll also want to setup PostgreSQL to have a user and database for M&F. We recommend calling them both "maf", as it keeps things simpler. You could skip on giving This can be done pretty simply just by using the following commands:

  • sudo su postgres -- Login as psql super user
  • psql -- Launch PSQL
  • CREATE ROLE maf LOGIN CREATEDB PASSWORD 'yourpasswordhere'; -- Create custom user role.
  • \q -- Quit PSQL
  • createdb -O maf maf -- Create "maf" database with ownership give to "maf" user.
  • exit -- Exit psql super user

And yes, you should change that to a password you'll remember--you'll need it later.

Part 3 - Loading the database

Thankfully, we store the developer database code in the exact same format we use for backups, so once you have a copy of the map database, which we'll assume is maf-dev-db.sql.gz, you can follow the below instructions:

  • gzip -d maf-dev-db.sql.gz -- Decompress the SQL file.
  • psql -d maf -va -f maf-dev-db.sql -- Run the SQL file against the "maf" database. This will generate a couple errors as certain users may be missing from our database--it shouldn't cause any issues.

Part 4 - Installing M&F

This is a two step process. First, you're going to want to edit that .env.local file to match your local environment.

Part 4.1 - .env.local Detailed

TODO.

Part 4.2 - Composer Install

, install composer PHP Composer. We're going to assume you've put it on your System Path with the following command:

  • sudo mv composer.phar /usr/local/bin/composer

Now, we tell composer to install the game!

  • php composer.phar install

Part 5 - Initializing the Game World

While M&F is fairly tolerant towards having no in-game data, there are certain tables it requires exists in order to semi-function, a few of which must have atleast one entry.

Part 5.1 - Building the Rest of the Database

So, lets build that database, and by that we mean lets tell Doctrine to do it for us. First, lets make sure it can talk to the database right:

  • php app/console doctrine:schema:update --dump-sql

If that dumps out hundreds and hundreds of lines of create and alter table commands, excellent! There should be over 1000 of them, and that's what we want. It means Doctrine can not only talk to the database, but knows what it needs to do to bring it up to what the game expects!

  • php app/console doctrine:schema:update --force

Part 5.2 - Loading Type Data

The Development database doesn't include the basic type data, so next we can load those in:

  • php app/console doctrine:fixtures:load --append

This should generate less than 20 lines of console output, telling you it's loading in different DataFixture files. If you drop --append and do the confirmation, you'll need to drop the database and rebuild it, because you've dumped your map data. Sorry.

Part 5.3 - Setting GeoFeature type data

Next, you need to run a single simple command inside the SQL database you made earlier. For simplicity, we'll do this as the PSQL super user--if you've made a PSQL user to match your username, that has access to the game database, you can skip the first and last commands.

  • sudo su postgres -- Login as psql super user
  • psql -d maf -- Connect to the maf database
  • update geofeature set type_id = (select id from types.featuretype where name = 'settlement'); -- Set the feature type IDs for the existing settlement features to the correct feature type ID, now that relations exist again.
  • \q -- Logout of the database
  • exit -- Logout of psql super user

Part 5.4 - Creating a User

You will need some credentials to log into your own instance, so run the following command and provide the requested data.

  • php app/console maf:user:create

If you want to test GM or Admin sides, you'll also need to run:

  • php app/console maf:user:promote

And assign the appropriate role you wish to test.

Part 5.5 - Essential Data

At this point, its best to test your configuration. The easiest way to do this, if you're installing it locally, is to navigate to the maf directory and have PHP start a server up, then navigate to 127.0.0.1:8000/en/ in the machine's browser and see if the homepage will load.

  • cd /var/www/maf/
  • php app/console server:start

At this point, you should have a user account to log in with. Go ahead and click login on the M&F landing page, fill out the boxes, and press submit. If you get a blank page going nowhere, restart your machine. This means PHP isn't loading the SQL drivers correctly.

You will probably get an offset error at this point, because the game expects some UpdateNote to already exist. So lets make one:

  • sudo su postgres
  • psql -d maf
  • insert into updatenote (id, ts, version, title, text) values (1, 'now', '1.0.0.0', 'Dev Instance', 'Filler Text');

Stay logged in for now, but refresh that page that errored earlier. You should be able to create a character now. There are no places, but once we get to the point of choosing an arrival location, simple go back to the terminal you have open for the SQL and run the following:

  • update playercharacter set location = (select location from geofeature where id = 855), alive = true, retired = false where id = 1;
  • \q
  • exit

This will put your character outside, but in the same spot as the, at the time of writing this, settlement of Bonrick. From here you can do whatever it is you wish.