Add admin system, registration gate, mudtool database editor, and test checklist
- Add is_admin flag to player DB schema with migration for existing databases - Add server_settings table for key-value config (registration_open, etc.) - Add 10 in-game admin commands: promote, demote, kick, teleport, registration, announce, heal, info, setattitude, list — all gated behind admin flag - Registration gate: new players rejected when registration_open=false, existing players can still reconnect - Add mudtool binary with CLI mode (players/settings/attitudes CRUD) and interactive ratatui TUI with tabbed interface for database management - Restructure to lib.rs + main.rs so mudtool shares DB code with server - Add TESTING.md with comprehensive pre-commit checklist and smoke test script - Stats and who commands show [ADMIN] badge; help shows admin section for admins Made-with: Cursor
This commit is contained in:
157
TESTING.md
Normal file
157
TESTING.md
Normal file
@@ -0,0 +1,157 @@
|
||||
# Pre-Commit Test Checklist
|
||||
|
||||
Run through these checks before every commit to ensure consistent feature coverage.
|
||||
|
||||
## Build
|
||||
- [ ] `cargo build` succeeds with no errors
|
||||
- [ ] `cargo build --bin mudtool` succeeds
|
||||
|
||||
## Server Startup
|
||||
- [ ] Server starts: `RUST_LOG=info ./target/debug/mudserver`
|
||||
- [ ] World loads all rooms, NPCs, objects, races, classes (check log output)
|
||||
- [ ] Database opens (or creates) successfully
|
||||
|
||||
## Character Creation
|
||||
- [ ] New player SSH → gets chargen flow (race + class selection)
|
||||
- [ ] Chargen accepts both number and name input
|
||||
- [ ] After chargen, player appears in spawn room with correct stats
|
||||
- [ ] Player saved to DB after creation
|
||||
|
||||
## Player Persistence
|
||||
- [ ] Reconnecting player skips chargen, sees "Welcome back!"
|
||||
- [ ] Room, stats, inventory, equipment all restored from DB
|
||||
- [ ] Verify with: `sqlite3 mudserver.db "SELECT * FROM players;"`
|
||||
|
||||
## Movement & Navigation
|
||||
- [ ] `go north`, `n`, `south`, `s`, etc. all work
|
||||
- [ ] Invalid direction shows error
|
||||
- [ ] Room view shows: NPCs (colored by attitude), objects, exits, other players
|
||||
|
||||
## NPC Interaction
|
||||
- [ ] `examine <npc>` shows description, stats, attitude label
|
||||
- [ ] `talk <friendly>` shows greeting dialogue
|
||||
- [ ] `talk <hostile>` shows snarl message
|
||||
- [ ] Dead NPCs don't appear in room view
|
||||
|
||||
## Combat
|
||||
- [ ] `attack <aggressive/hostile npc>` initiates combat
|
||||
- [ ] Can't attack friendly/neutral NPCs
|
||||
- [ ] Combat rounds show damage dealt and received
|
||||
- [ ] NPC death: awards XP, shifts attitude -10, shifts faction -5
|
||||
- [ ] Player death: respawns at spawn room with full HP
|
||||
- [ ] NPCs respawn after configured time
|
||||
- [ ] Combat lockout: can only attack/flee/look/quit during combat
|
||||
- [ ] `flee` exits combat
|
||||
|
||||
## Items
|
||||
- [ ] `take <item>` picks up takeable objects
|
||||
- [ ] `drop <item>` places item in room
|
||||
- [ ] `equip <weapon/armor>` works, old gear returns to inventory
|
||||
- [ ] `use <consumable>` heals and removes item
|
||||
- [ ] `inventory` shows equipped + bag items
|
||||
|
||||
## Attitude System
|
||||
- [ ] Per-player NPC attitudes stored in DB
|
||||
- [ ] `examine` shows attitude label per-player
|
||||
- [ ] Killing NPC shifts attitude (individual -10, faction -5)
|
||||
- [ ] Verify: `sqlite3 mudserver.db "SELECT * FROM npc_attitudes;"`
|
||||
|
||||
## Admin System
|
||||
- [ ] Non-admin can't use `admin` commands (gets error)
|
||||
- [ ] Set admin via mudtool: `mudtool players set-admin <name> true`
|
||||
- [ ] `admin help` shows admin command list
|
||||
- [ ] `admin promote <player>` grants admin (verify in DB)
|
||||
- [ ] `admin demote <player>` revokes admin
|
||||
- [ ] `admin kick <player>` disconnects target player
|
||||
- [ ] `admin teleport <room_id>` warps to room (shows room list on invalid)
|
||||
- [ ] `admin registration off` blocks new player creation
|
||||
- [ ] `admin registration on` re-enables it
|
||||
- [ ] `admin announce <msg>` broadcasts to all players
|
||||
- [ ] `admin heal` heals self; `admin heal <player>` heals target
|
||||
- [ ] `admin info <player>` shows detailed stats + attitudes
|
||||
- [ ] `admin setattitude <player> <npc> <value>` modifies attitude
|
||||
- [ ] `admin list` shows all players with online/offline status
|
||||
|
||||
## Registration Gate
|
||||
- [ ] With registration open (default), new players can create characters
|
||||
- [ ] With registration off, new SSH connections get rejection message
|
||||
- [ ] Existing players can still log in when registration is closed
|
||||
|
||||
## MUD Tool - CLI
|
||||
- [ ] `mudtool players list` shows all players
|
||||
- [ ] `mudtool players show <name>` shows details
|
||||
- [ ] `mudtool players set-admin <name> true` works
|
||||
- [ ] `mudtool players delete <name>` removes player + attitudes
|
||||
- [ ] `mudtool settings list` shows settings
|
||||
- [ ] `mudtool settings set registration_open false` works
|
||||
- [ ] `mudtool attitudes list <player>` shows attitudes
|
||||
- [ ] `mudtool attitudes set <player> <npc> <value>` works
|
||||
|
||||
## MUD Tool - TUI
|
||||
- [ ] `mudtool tui` launches interactive interface
|
||||
- [ ] Tab/1/2/3 switches between Players, Settings, Attitudes tabs
|
||||
- [ ] Arrow keys navigate rows
|
||||
- [ ] 'a' toggles admin on Players tab
|
||||
- [ ] 'd' prompts delete confirmation on Players tab
|
||||
- [ ] Enter edits value on Settings and Attitudes tabs
|
||||
- [ ] ←→ switches player on Attitudes tab
|
||||
- [ ] 'q' exits TUI
|
||||
|
||||
## Quick Smoke Test Script
|
||||
|
||||
```bash
|
||||
# Start server in background
|
||||
RUST_LOG=info ./target/debug/mudserver &
|
||||
SERVER_PID=$!
|
||||
sleep 2
|
||||
|
||||
# Test 1: New player creation + basic commands
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
1
|
||||
1
|
||||
look
|
||||
stats
|
||||
go north
|
||||
talk barkeep
|
||||
go south
|
||||
go south
|
||||
examine thief
|
||||
attack thief
|
||||
flee
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Test 2: Persistence - reconnect
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
look
|
||||
stats
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Test 3: Admin via mudtool
|
||||
./target/debug/mudtool players list
|
||||
./target/debug/mudtool players set-admin smoketest true
|
||||
./target/debug/mudtool players show smoketest
|
||||
./target/debug/mudtool settings set registration_open false
|
||||
./target/debug/mudtool settings list
|
||||
|
||||
# Test 4: Admin commands in-game
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 smoketest@localhost <<'EOF'
|
||||
admin help
|
||||
admin list
|
||||
admin registration on
|
||||
admin info smoketest
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Test 5: Registration gate
|
||||
./target/debug/mudtool settings set registration_open false
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 newplayer@localhost <<'EOF'
|
||||
quit
|
||||
EOF
|
||||
|
||||
# Cleanup
|
||||
./target/debug/mudtool settings set registration_open true
|
||||
./target/debug/mudtool players delete smoketest
|
||||
kill $SERVER_PID
|
||||
```
|
||||
Reference in New Issue
Block a user