b203f0e4de
Escape-room mechanic: the retro phone can call the players on its own and tell them a story when they pick up. Approach: a story_ring_task rings at a random 15-30 min interval (only when the line is idle and a story pack is on the SD). Picking up routes through enter_story_from_ring(), which silences the bell and launches a random story via plip_gamebook_begin_random() straight into the gamebook state — no menu. If nobody answers within 1 min the bell stops and the next ring is rescheduled; hanging up mid-ring also silences it. The whole feature is gated behind CONFIG_PLIP_AUTO_RING (default n), so the phone stays silent unless explicitly enabled in menuconfig. The hook pickup paths (raw SLIC poll + debounced edge) mirror the existing NPC incoming-call handling, which is unreliable while the bell rings.
49 lines
1.9 KiB
C
49 lines
1.9 KiB
C
#pragma once
|
|
// plip_gamebook — "livre dont vous êtes le héros" AUDIO pour le téléphone PLIP.
|
|
//
|
|
// Pas d'écran : tout passe par l'écouteur. On décroche, le narrateur lit le
|
|
// menu des histoires ("pour le dragon, faites le 1..."), on compose un chiffre
|
|
// au cadran pour choisir une histoire, puis à chaque passage le narrateur lit
|
|
// le texte ET les choix numérotés ("pour examiner la machine, faites le 1..."),
|
|
// et on compose le chiffre du choix. Raccrocher arrête tout.
|
|
//
|
|
// Lit /sdcard/gamebook/{library.json, menu.wav, <id>.json, <id>_<passage>.wav}
|
|
// (pack audio "téléphone" produit par tools/gamebook/build_phone_gamebook.py,
|
|
// où la narration des WAV inclut déjà les invites "faites le N"). 100% local,
|
|
// aucun modèle, aucun réseau.
|
|
//
|
|
// Intégration : conversation.c lance plip_gamebook_begin() au décroché (si un
|
|
// pack est présent sur la SD), pousse chaque chiffre composé via
|
|
// plip_gamebook_feed_digit(), et appelle plip_gamebook_end() au raccroché.
|
|
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// La SD est-elle montée et un pack gamebook présent ? (à tester au décroché)
|
|
bool plip_gamebook_available(void);
|
|
|
|
// Démarre le mode livre-jeu : charge la bibliothèque et joue le menu audio.
|
|
void plip_gamebook_begin(void);
|
|
|
|
// Démarre directement UNE histoire tirée au hasard (sans passer par le menu) —
|
|
// utilisé quand le téléphone sonne tout seul et qu'on décroche.
|
|
void plip_gamebook_begin_random(void);
|
|
|
|
// Traite un chiffre composé (0..9). Menu → choisit l'histoire ; en histoire →
|
|
// choisit la réponse ; sur une fin → 0 revient au menu. Interrompt la
|
|
// narration en cours pour enchaîner.
|
|
void plip_gamebook_feed_digit(int digit);
|
|
|
|
// Quitte le mode livre-jeu (raccroché) : stoppe l'audio, libère la mémoire.
|
|
void plip_gamebook_end(void);
|
|
|
|
// Vrai tant qu'une partie est en cours.
|
|
bool plip_gamebook_active(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|