encounter_argumentation/critical_moves.rs
1//! Maps critical questions to encounter beat candidates.
2//!
3//! Each critical question on a [`SchemeInstance`] can be posed as a challenge
4//! in an encounter. This module converts them into [`Beat`] values that the
5//! encounter engine can process.
6
7use argumentation_schemes::instance::{CriticalQuestionInstance, SchemeInstance};
8use encounter::types::{Beat, Effect};
9
10/// Convert a [`SchemeInstance`]'s critical questions into encounter beat
11/// candidates, one beat per critical question.
12///
13/// All beats are produced with `accepted = false` (challenges are adversarial
14/// by nature) and an empty `effects` list. Use [`cq_to_beat`] directly if you
15/// need to attach effects to individual beats.
16///
17/// # Arguments
18///
19/// * `instance` - The instantiated scheme whose critical questions are to be
20/// mapped.
21/// * `challenger` - The name of the character posing the challenges.
22pub fn critical_question_beats(instance: &SchemeInstance, challenger: &str) -> Vec<Beat> {
23 instance
24 .critical_questions
25 .iter()
26 .map(|cq| cq_to_beat(cq, challenger, Vec::new()))
27 .collect()
28}
29
30/// Convert a single [`CriticalQuestionInstance`] into an encounter [`Beat`].
31///
32/// The beat's `action` is formatted as `"cq<number>:<text>"` so that both
33/// the question index and its resolved text are visible in logs and tests.
34///
35/// # Arguments
36///
37/// * `cq` - The critical question instance to convert.
38/// * `challenger` - The name of the character posing the challenge.
39/// * `effects` - Effects to attach to the beat (caller-supplied).
40pub fn cq_to_beat(cq: &CriticalQuestionInstance, challenger: &str, effects: Vec<Effect>) -> Beat {
41 Beat {
42 actor: challenger.to_string(),
43 action: format!("cq{}:{}", cq.number, cq.text),
44 accepted: false,
45 effects,
46 }
47}