Spaces:
Running on Zero
Running on Zero
| from __future__ import annotations | |
| import random | |
| import threading | |
| from typing import Any | |
| CASE_CATALOG: list[dict[str, Any]] = [ | |
| { | |
| "case_id": "glass_finch", | |
| "case_title": "The Glass Finch Affair", | |
| "crime": "theft of the Beaumont glass automaton", | |
| "stolen_item": "a crystal songbird automaton", | |
| "victim": "the Beaumont Gallery", | |
| "scene": "a private gallery viewing room", | |
| "detail": "Only a scatter of glass feathers and a cut telephone wire remained.", | |
| "culprit_alias": "The Glass Finch", | |
| "description": "A sharp-featured woman in a cream trench coat and emerald scarf, carrying a slim black portfolio case.", | |
| "image_url": "/static/assets/suspects/glass_finch.png", | |
| }, | |
| { | |
| "case_id": "copper_saint", | |
| "case_title": "The Copper Saint Robbery", | |
| "crime": "theft of the St. Aldwyn reliquary", | |
| "stolen_item": "a copper-and-enamel reliquary", | |
| "victim": "St. Aldwyn's Chapter House", | |
| "scene": "a locked cathedral treasury", | |
| "detail": "Wax from a false seal was found beside an open service hatch.", | |
| "culprit_alias": "The Copper Saint", | |
| "description": "A wary man in a rust overcoat and navy flat cap, wearing brass-rim spectacles and carrying a violin case.", | |
| "image_url": "/static/assets/suspects/copper_saint.png", | |
| }, | |
| { | |
| "case_id": "violet_cipher", | |
| "case_title": "The Violet Cipher", | |
| "crime": "theft of a diplomatic code wheel", | |
| "stolen_item": "the Foreign Office violet code wheel", | |
| "victim": "the Crown Signals Bureau", | |
| "scene": "a guarded decoding room", | |
| "detail": "A copied key card and a silver cigarette ash were the only clues.", | |
| "culprit_alias": "The Violet Cipher", | |
| "description": "A poised woman in a charcoal suit and violet veiled cloche hat, carrying a silver cigarette case.", | |
| "image_url": "/static/assets/suspects/violet_cipher.png", | |
| }, | |
| { | |
| "case_id": "ivory_rook", | |
| "case_title": "The Ivory Rook Gambit", | |
| "crime": "theft of an ancient ivory chess rook", | |
| "stolen_item": "the lost rook from the Caliph's chess set", | |
| "victim": "the Royal Antiquities Society", | |
| "scene": "a guarded archive", | |
| "detail": "A rolled museum plan had been exchanged for a flawless forgery.", | |
| "culprit_alias": "The Ivory Rook", | |
| "description": "An older man in a camel coat, burgundy bow tie, and black homburg, carrying a walking cane and rolled plans.", | |
| "image_url": "/static/assets/suspects/ivory_rook.png", | |
| }, | |
| { | |
| "case_id": "saffron_pen", | |
| "case_title": "The Saffron Pen Forgery", | |
| "crime": "theft of the Prime Minister's sealed treaty", | |
| "stolen_item": "a signed copy of the Calcutta Accord", | |
| "victim": "the Cabinet Records Office", | |
| "scene": "a document conservation room", | |
| "detail": "The treaty was replaced by a copy whose ink was still warm.", | |
| "culprit_alias": "The Saffron Pen", | |
| "description": "A moustached man in a bottle-green rain cape and mustard scarf, carrying a leather document tube.", | |
| "image_url": "/static/assets/suspects/saffron_pen.png", | |
| }, | |
| { | |
| "case_id": "blue_hour", | |
| "case_title": "The Blue Hour Break-In", | |
| "crime": "burglary of the Kingsley sapphire vault", | |
| "stolen_item": "the uncut Kingsley sapphire", | |
| "victim": "Harrow & Blythe Jewellers", | |
| "scene": "an underground cutting vault", | |
| "detail": "The safe dial was clean, but blue wool fibres clung to the hinge.", | |
| "culprit_alias": "The Blue Hour", | |
| "description": "A composed woman in a midnight-blue coat and pale headscarf, wearing pearl earrings and carrying a metal tool case.", | |
| "image_url": "/static/assets/suspects/blue_hour.png", | |
| }, | |
| { | |
| "case_id": "brass_moth", | |
| "case_title": "The Brass Moth Mystery", | |
| "crime": "theft of an experimental clockwork navigator", | |
| "stolen_item": "the Halden brass navigator", | |
| "victim": "master clockmaker Elias Halden", | |
| "scene": "a workshop above Bellmaker Lane", | |
| "detail": "Every clock stopped at 11:47 as the workshop lights went dark.", | |
| "culprit_alias": "The Brass Moth", | |
| "description": "An observant man in an olive duffle coat, round spectacles, and burgundy scarf, carrying a mahogany clock box.", | |
| "image_url": "/static/assets/suspects/brass_moth.png", | |
| }, | |
| { | |
| "case_id": "scarlet_lark", | |
| "case_title": "The Scarlet Lark Reel", | |
| "crime": "theft of a classified newsreel", | |
| "stolen_item": "a film canister containing a secret weapons test", | |
| "victim": "Crown News Pictures", | |
| "scene": "a Soho film laboratory", | |
| "detail": "A delivery motorcycle vanished seconds before the fire alarm sounded.", | |
| "culprit_alias": "The Scarlet Lark", | |
| "description": "A defiant woman in a black motoring coat, scarlet beret, and white gloves, carrying a cylindrical film canister.", | |
| "image_url": "/static/assets/suspects/scarlet_lark.png", | |
| }, | |
| { | |
| "case_id": "thames_ghost", | |
| "case_title": "The Thames Ghost Cargo", | |
| "crime": "theft of a customs evidence pouch", | |
| "stolen_item": "a pouch of confiscated black pearls", | |
| "victim": "the Port of London Authority", | |
| "scene": "a river-police evidence room", | |
| "detail": "River mud marked the floor although every dock gate was locked.", | |
| "culprit_alias": "The Thames Ghost", | |
| "description": "A guarded man in a slate pea coat, cream fisherman's jumper, and dark knit cap, carrying a tarred canvas satchel.", | |
| "image_url": "/static/assets/suspects/thames_ghost.png", | |
| }, | |
| { | |
| "case_id": "madame_mercury", | |
| "case_title": "Madame Mercury's Deception", | |
| "crime": "theft of the Marlowe ruby suite", | |
| "stolen_item": "a lacquered box of Burmese rubies", | |
| "victim": "Lady Marlowe", | |
| "scene": "a Mayfair hotel strongroom", | |
| "detail": "The night clerk remembered two identical guests leaving minutes apart.", | |
| "culprit_alias": "Madame Mercury", | |
| "description": "An imperious older woman in a silver-grey fur-collared coat and teal turban, carrying a lacquered red jewel box.", | |
| "image_url": "/static/assets/suspects/madame_mercury.png", | |
| }, | |
| { | |
| "case_id": "green_signal", | |
| "case_title": "The Green Signal Heist", | |
| "crime": "theft of the Night Mail master key", | |
| "stolen_item": "the master key to the Royal Night Mail", | |
| "victim": "British Rail Postal Service", | |
| "scene": "a station sorting office", | |
| "detail": "A signal lantern flashed green on a line closed since midnight.", | |
| "culprit_alias": "The Green Signal", | |
| "description": "A restless young man in a dark green overcoat over a porter's jacket, carrying a timetable case and signal lantern.", | |
| "image_url": "/static/assets/suspects/green_signal.png", | |
| }, | |
| { | |
| "case_id": "amber_quill", | |
| "case_title": "The Amber Quill Manuscript", | |
| "crime": "theft of an illuminated royal manuscript", | |
| "stolen_item": "the gold-leaf Chronicle of Eleanor", | |
| "victim": "the Kensington Manuscript Library", | |
| "scene": "a climate-controlled reading room", | |
| "detail": "Amber sealing wax was pressed with a ring no archivist recognised.", | |
| "culprit_alias": "The Amber Quill", | |
| "description": "A watchful woman in a chocolate-brown coat, amber headscarf, and cat-eye spectacles, carrying a wrapped manuscript.", | |
| "image_url": "/static/assets/suspects/amber_quill.png", | |
| }, | |
| { | |
| "case_id": "velvet_mask", | |
| "case_title": "The Velvet Mask Caper", | |
| "crime": "theft of the Garrick death mask", | |
| "stolen_item": "a priceless carved theatrical mask", | |
| "victim": "the Royal Players' Archive", | |
| "scene": "a locked West End prop room", | |
| "detail": "A stage cue rang in an empty theatre just before the mask disappeared.", | |
| "culprit_alias": "The Velvet Mask", | |
| "description": "A theatrical man in a plum dinner jacket and black opera cloak, carrying a carved mask and compact attache case.", | |
| "image_url": "/static/assets/suspects/velvet_mask.png", | |
| }, | |
| { | |
| "case_id": "rose_diamond", | |
| "case_title": "The Rose Diamond Cut", | |
| "crime": "theft of the uncut Rose Diamond", | |
| "stolen_item": "the newly discovered Rose Diamond", | |
| "victim": "the Hatton Garden Exchange", | |
| "scene": "a gem examination chamber", | |
| "detail": "Fine diamond dust traced a path to a service stair no guest should know.", | |
| "culprit_alias": "The Rose Diamond", | |
| "description": "An unsmiling woman in a dove-grey fitted coat, dusty rose scarf, and round sunglasses, carrying a padded sample case.", | |
| "image_url": "/static/assets/suspects/rose_diamond.png", | |
| }, | |
| { | |
| "case_id": "white_raven", | |
| "case_title": "The White Raven Dispatch", | |
| "crime": "theft of a sealed diplomatic dispatch", | |
| "stolen_item": "the ambassador's blue dispatch pouch", | |
| "victim": "the Nordic Embassy", | |
| "scene": "a guarded diplomatic reception", | |
| "detail": "The embassy seal was intact, but the pouch inside contained blank paper.", | |
| "culprit_alias": "The White Raven", | |
| "description": "A silver-haired man in a white dinner jacket beneath a black overcoat, carrying a sealed blue dispatch pouch.", | |
| "image_url": "/static/assets/suspects/white_raven.png", | |
| }, | |
| ] | |
| _CASE_ROTATION: list[dict[str, Any]] = [] | |
| _LAST_CASE_ID: str | None = None | |
| _CASE_ROTATION_LOCK = threading.Lock() | |
| def choose_case() -> dict[str, Any]: | |
| global _CASE_ROTATION, _LAST_CASE_ID | |
| with _CASE_ROTATION_LOCK: | |
| if not _CASE_ROTATION: | |
| _CASE_ROTATION = list(CASE_CATALOG) | |
| random.SystemRandom().shuffle(_CASE_ROTATION) | |
| if len(_CASE_ROTATION) > 1 and _CASE_ROTATION[-1]["case_id"] == _LAST_CASE_ID: | |
| _CASE_ROTATION[0], _CASE_ROTATION[-1] = _CASE_ROTATION[-1], _CASE_ROTATION[0] | |
| selected = _CASE_ROTATION.pop() | |
| _LAST_CASE_ID = selected["case_id"] | |
| return dict(selected) | |