# MTG Random Interface

This small project provides a web based tool for running a bespoke randomized MTG card game.

## This project requires

* PHP ImageMagick

## Don't forget to:

* Create a MySQL/MariaDB database for the app with privileges granted to a user
  * `create database mtgrandom`
  * `create user 'mtgrandom'@'localhost' identified by 'password'`
  * `grant all privileges on mtgrandom.* to 'mtgrandom'@'localhost'`
* Import the `install/initial_db_mysql.sql` database structure
  * `mysql --host=localhost --user=mtgrandom -p mtgrandom < install/initial_db_mysql.sql`
* Change the ownership of the `images/` folder to the web server user
  * `chown :www-data images`
  * `chmod g+ws images`
* Copy the `config-dist.php` file to `config.php` and edit that file appropriately

## Usage Instructions

Here is a collection of notes about how the interface operates:

* When the page loads (or reloads) the game is reset
  * Card count is set to zero, but not displayed
  * The server-side list of played cards is emptied
  * Any displayed cards are removed
* Long pressing (press and hold) an image will toggle a card enabled or disabled
  * Disabled images are not in the pool of available cards when selecting a random card
  * If it is semi-transparent it is disabled
  * if it is not semi-transparent it is enabled
  * Card state can be edited in the management interface
* Clicking the **Show First Card** button will show the first card
  * Note that the very first card does NOT increment the card count
* Clicking the **Show Second Card** button will:
  * If a single card is displayed it will show a second card
  * If a second card is displayed it will replace the existing second card
  * Note that the **Show Second Card** button does not appear until at least one card is displayed
* Clicking the **Sun** (yellow) icon starts a game
  * A dice is rolled (turn up the volume to hear a dice roll!)
  * The dice results are set to the server as the starting card count
  * The dice roll is displayed over the diamond icon
* Clicking the **Fire** (red) icon will replace the most recently played card
  * The replacement card is **NOT** flagged as played for the current session
  * The replaced card is **STILL** flagged as played
* Clicking the **Skull** (gray) icon will reverse the most recent card play
  * The removed card will be set as "unplayed" in the current session and may show up again
  * It is impossible to go back further than the first card played
  * The card count will go backwards to match the reversed play
* Clicking the **Water** (blue) icon will hide the dice roll number displayed on the **Sun** icon
  * This is currently pointless as the dice roll is always hidden, but the functionality is retained
* Clicking the **Diamond** (bottom right) icon will reset the game session
  * Click once to stage the reset and the number will turn red
  * Click a second time to finish resetting the session
  * If it is not clicked a second time before another action is made it will go back to normal
* Clicking the **Tree** (green) icon will open the management interface in a new tab
  * This requires login credentials
