# Technical Quest Vault

A passcode-cracking game for teams, played in batches. The game master starts
each batch's 25-minute clock. Every team in the batch then enters its own
passcode, with 5 attempts, until it opens the vault or the clock runs out.

All data (teams, passcodes, batches, attempts) is stored in the MySQL database `eduvault`.
Back it up with `php artisan vault:export-json`; load an old `data.json` with `php artisan vault:import-json`.

## Open it

The app is served by XAMPP's Apache through the folder link
`C:\xampp\htdocs\vault`, which points to `D:\vault\public`.

| Screen | URL | Who uses it |
|---|---|---|
| Vault (team kiosk) | http://localhost/vault/ | Teams |
| Leaderboard (live) | http://localhost/vault/leaderboard | Projector or big screen |
| Control room | http://localhost/vault/admin | Game master (password: `VAULT_ADMIN_PASSWORD` in `.env`, default `vault-master`) |

Other devices on the same network can open `http://<this-PC's-IP>/vault/`.
If they can't connect, allow Apache through the Windows firewall.

> Don't use `php artisan serve` on event day. On Windows it serves one
> request at a time and freezes when several screens are open.

### After changing `.env`

Run `php artisan config:cache`. Apache uses cached config because reading
`.env` on every request isn't thread-safe there. Don't run `route:cache`: it
breaks the root URL when the app is served from a subfolder like `/vault/`.

## Before the event (control room)

1. **Import teams:** upload a CSV or paste rows with the columns
   `team name, passcode`, plus an optional `batch` column (`2` or `Batch 2`).
2. **Assign batches:** tick teams in the table and choose **Move to Batch N**,
   or change a team's batch from its row dropdown. Teams without a batch can't play.
3. **Check the settings:** minutes per batch (25), attempts per team (5),
   number of batches (4), and the wait between attempts (3 s).

## During the event

- **Each batch card:** ▶ START, ⏸ PAUSE / ▶ RESUME, ■ STOP, +5 MIN, ↺ RESET.
  - Pause freezes the clock and blocks passcode entry; paused time doesn't count.
  - Stop ends the batch now.
  - +5 MIN also re-opens a batch that has finished.
  - Reset clears the batch's clock and all of its teams' attempts.
- **Each team row:** ↺ clears that team's attempts, and ✕ deletes the team.

## What the teams see

1. **Team list:** batch tabs with live clocks, search, and A–Z letter buttons.
2. **Open their team:**
   - If their batch hasn't started, a waiting room shows the rules. It switches
     to the vault by itself the moment the batch starts.
   - Once the batch is running, the vault opens with the batch clock in the top bar.
3. **Enter the code:** feed in the characters and press **OPEN THE VAULT**.
   No right/wrong marks are shown while typing.
   - **Wrong code:** "INVALID PASSCODE, N attempts left". The clock keeps running.
   - **Last attempt:** a confirmation appears first.
   - **Valid code:** "CONGRATULATIONS! Your passcode is valid", the door opens,
     and the batch-clock time is recorded as the team's time.
   - **All attempts wrong:** "INVALID", with the last code marked ✓/✗ per
     character and "You missed N of 10 characters".
   - **Clock reaches zero:** "TIME'S UP".

## Results

- **Leaderboard:**
  - Cracked teams are ranked by time.
  - Finished teams are then ranked by characters found.
  - Teams still playing are listed without a rank, and their character counts
    and entered codes are never shown, so they can't be used as hints.
- **REPORT CSV:** rank, team, batch, status, time taken, attempts, and
  characters right/missed.
- **ALL ATTEMPTS CSV:** every code entered, with the batch-clock time and timestamp.

## Hosting online

To put the game on https://vault.b2of.com, follow [DEPLOY.md](DEPLOY.md).
