Files
room_glitch/tests/pcb/check_rfid_credit.gd
T
Jeff Luke 41ef12f954 Add Pac-Man power-on flow and document Odin integration
- Add a four-second arcade-style boot sequence followed by the
  Character / Nickname introduction.
- Separate cabinet power-on from RFID credit and player Start.
- Add operator Power on control and cabinet power-state reporting.
- Prevent repeated power commands from restarting boot or gameplay.
- Ignore RFID scans received before the cabinet is ready.
- Add power-state, RFID, controller, and GPIO feedback regression tests.

- Expand the master walkthrough with export, packaging, file transfer,
  fresh-Pi setup, RFID compilation, and end-to-end testing instructions.
- Correct tester hardware documentation: BCM23/J20 drives an LED;
  physical buttons connect through a separate I2C1 input board.
- Document operator-triggered power-on as the current test workflow
  and retain the temporary 2.4 configuration compatibility notes.
- Record successful physical testing of power-on, RFID credit,
  and player Start.

- Add an Odin integration README describing the proposed Rust/NATS
  bridge, shared messages, Flutter GM interface, autopilot sequencing,
  hardware ownership, and Starfish SSH-management role.
- Define migration milestones and information needed from the
  framework owner; link the integration guide from the root README.

Validation: 69 controller tests, 10 GPIO tests, Pac-Man power/RFID
checks, managed-cabinet lifecycle checks, and visual screen inspection.
2026-10-17 18:47:26 -07:00

46 lines
2.3 KiB
GDScript

extends SceneTree
var failures := 0
func check(ok: bool, message: String) -> void:
if not ok:
failures += 1
push_error(message)
func sample(id: String, uid := "1234ABCD", device := "cab1_rfid1", fresh := true, age := 0) -> Dictionary:
return {"fresh": fresh, "events": [{"id": id, "device": device, "kind": "rfid", "value": uid, "error": ""}], "devices": [{"id": device, "value": uid, "age_ms": age, "error": ""}]}
func _initialize() -> void:
call_deferred("run")
func run() -> void:
var game = load("res://games/pacman/pacman.gd").new()
root.add_child(game)
game.configure({"rfid_credit_device": "cab1_rfid1", "rfid_allowed_uids": ["1234ABCD"]})
game.set_physics_process(false)
game._physics_process(4.0)
check(not game.start_game(), "Start must require a credit")
game.receive_device_feedback({})
game.receive_device_feedback(sample("old"))
check(game.credits == 0, "First fresh snapshot must baseline historical scans")
game.receive_device_feedback(sample("wrong-reader", "1234ABCD", "other"))
game.receive_device_feedback(sample("wrong-card", "99999999"))
game.receive_device_feedback(sample("stale", "1234ABCD", "cab1_rfid1", true, 5000))
game.receive_device_feedback(sample("offline", "1234ABCD", "cab1_rfid1", false))
check(game.credits == 0, "Wrong reader/card, stale and offline samples must not credit")
game.receive_device_feedback(sample("scan"))
check(game.credits == 1 and game.view.credits == 1, "New accepted scan grants one visible credit")
game.receive_device_feedback(sample("scan"))
game.receive_device_feedback(sample("scan2"))
check(game.credits == 1, "Duplicate and additional scans must not stack credits")
check(game.start_game() and game.credits == 0, "Start consumes one credit")
game.receive_device_feedback(sample("during-play"))
check(game.credits == 0, "Playing scans must not bank credits")
game.reset_game()
game.receive_device_feedback(sample("scan"))
check(game.credits == 0, "Reset must not replay a prior event")
game.receive_device_feedback(sample("new-scan"))
check(game.credits == 1, "New scan works after reset")
game.configure({})
game._physics_process(4.0)
check(game.start_game(), "Ordinary non-RFID Pac-Man remains free start")
game.queue_free()
await process_frame
print("RFID credit tests: ", "PASS" if failures == 0 else "FAIL")
quit(1 if failures else 0)