Dungeon verbs: attack, threaten and accuse are declared at Begin; the table view derives open grievances
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
06b9520b4d
commit
9e8600460e
5 changed files with 499 additions and 0 deletions
|
|
@ -348,6 +348,28 @@ async fn finish(
|
|||
key: Uuid,
|
||||
world_id: ghostlight::WorldId,
|
||||
) -> Result<(), BeginError> {
|
||||
// The deeds a table is made of are declared before the world opens, and
|
||||
// granted to every person the draft holds, the player included. A resumed
|
||||
// Begin finds them declared and goes on.
|
||||
let draft = current(host)
|
||||
.await
|
||||
.map_err(|error| from_mailbox("verbs", error))?
|
||||
.ok_or_else(|| stopped("verbs", "the world could not be read"))?;
|
||||
if !draft.affordances.iter().any(|entry| entry.entry.kind.0 == "attack") {
|
||||
let batch = crate::verbs::install(&draft).map_err(|error| stopped("verbs", error))?;
|
||||
host.world
|
||||
.submit_principal(
|
||||
PrincipalCommandIntent {
|
||||
id: derived_step_id(key, "verbs")?,
|
||||
world_id,
|
||||
expected_revision: draft.revision,
|
||||
body: CommandBody::AdmitPatch { answers: None, patch: batch.patch },
|
||||
},
|
||||
principal,
|
||||
)
|
||||
.await
|
||||
.map_err(|error| from_mailbox("verbs", error))?;
|
||||
}
|
||||
for (name, body) in [
|
||||
("approve", CommandBody::ApproveDraft),
|
||||
("activate", CommandBody::ActivateWorld),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ mod test_support;
|
|||
mod timelines;
|
||||
mod turn_log;
|
||||
mod vaults;
|
||||
mod verbs;
|
||||
|
||||
use anyhow::bail;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
|||
|
|
@ -188,6 +188,11 @@ tool, each `text` an exact quote from their prose. Commit every answer before yo
|
|||
- A deed that changes how someone regards another is state: record it with `adjust_attitude`, so the regard is \
|
||||
carried into every later meeting. A regard held with no deed behind it is `declare_attitude`, and the trait it turns \
|
||||
on is `declare_trait`.\n\
|
||||
- A deed is state the room holds: when the player acts on someone, commit it through the player's own `attack`, \
|
||||
`threaten` or `accuse` tool with a `display` quote, so everyone present has seen it. The table \
|
||||
view lists the open grievances the world has not answered. An office, a victim's kin and the witnesses answer \
|
||||
through their own people: give them their turns, and rule pressure (`advance_pressure`, from whoever would lean) or \
|
||||
a sworn reckoning (`create_commitment`, the victim's kin with the doer as counterparty) where you judge the world would.\n\
|
||||
- Call `end_turn` when the round's consequences are settled.";
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
|
|||
372
crates/ghostlight-dungeon/src/verbs.rs
Normal file
372
crates/ghostlight-dungeon/src/verbs.rs
Normal file
|
|
@ -0,0 +1,372 @@
|
|||
//! The Dungeon's verbs: the affordance catalog every world Begin makes
|
||||
//! declares, and the grant of it to every person.
|
||||
//!
|
||||
//! A fresh world knows only Speak. A deed the player may attempt but the world
|
||||
//! cannot lower is a gap, so the Dungeon declares the deeds a table is made of:
|
||||
//! attack, threaten and accuse. Each lowers to kernel effects the
|
||||
//! kernel alone writes: regard in the target (`AdjustAttitude`), pressure
|
||||
//! (`AdvancePressure`). The effects name no consequence
|
||||
//! beyond the deed. Nothing here refuses a verb on grounds of niceness: a
|
||||
//! sword is drawn when the preconditions hold (the target is in the room), and
|
||||
//! what the world does about it is state the table reads, not a rule.
|
||||
//!
|
||||
//! A deed carries its witnesses through the kernel's own display lowering: the
|
||||
//! table commits it with a `display` quote, which becomes a claim the whole room
|
||||
//! holds as `Seen`. Who saw it is therefore kernel state, and the Open
|
||||
//! grievances block of the table view is derived from it.
|
||||
|
||||
use ghostlight::{DecodedBatch, SubjectKind, WorldSnapshot, decode_authoring_calls};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// The deed kinds this catalog declares, in the order declared.
|
||||
pub(crate) const VERBS: [&str; 3] = ["attack", "threaten", "accuse"];
|
||||
|
||||
fn subject_role() -> Value {
|
||||
json!({"namespace": "subject", "kind": null})
|
||||
}
|
||||
|
||||
fn adjust(delta: i16) -> Value {
|
||||
json!({"op_kind": {"op": "adjust_attitude", "delta": delta, "decay": null}, "roles": ["target"], "bounds": {"bound": "none"}})
|
||||
}
|
||||
|
||||
fn colocated_target() -> Value {
|
||||
json!({"precondition": "can_reach", "subject": "target", "via": "colocated"})
|
||||
}
|
||||
|
||||
/// The declarations, as the authoring calls the Dungeon Master would make.
|
||||
fn declarations() -> Vec<(&'static str, Value)> {
|
||||
vec![
|
||||
(
|
||||
"declare_affordance",
|
||||
// Three grades of harm, weighted so a blow usually lands. The
|
||||
// regard the target holds of the actor falls by the grade; what the
|
||||
// wound or death means is the table's ruling.
|
||||
json!({
|
||||
"handle": "attack",
|
||||
"kind": "attack",
|
||||
"roles": [{"role": "target", "kind": subject_role()}],
|
||||
"preconditions": [colocated_target()],
|
||||
"effect_slots": [adjust(-35), adjust(-70), adjust(-100)],
|
||||
"outcome_bands": [
|
||||
{"weight": 3, "effects": [0]},
|
||||
{"weight": 3, "effects": [1]},
|
||||
{"weight": 2, "effects": [2]},
|
||||
],
|
||||
"carries_speech": false,
|
||||
}),
|
||||
),
|
||||
(
|
||||
"declare_affordance",
|
||||
json!({
|
||||
"handle": "threaten",
|
||||
"kind": "threaten",
|
||||
"roles": [{"role": "target", "kind": subject_role()}],
|
||||
"preconditions": [colocated_target()],
|
||||
"effect_slots": [
|
||||
{"op_kind": {"op": "advance_pressure", "by": 20}, "roles": ["target"], "bounds": {"bound": "none"}},
|
||||
adjust(-25),
|
||||
],
|
||||
"outcome_bands": [{"weight": 1, "effects": [0, 1]}],
|
||||
"carries_speech": false,
|
||||
}),
|
||||
),
|
||||
(
|
||||
"declare_affordance",
|
||||
// A grievance carried to someone who can lean on the accused:
|
||||
// pressure on the target from the accuser, who must hold the
|
||||
// charge as something believed. An office answers through its own
|
||||
// people using this same verb.
|
||||
json!({
|
||||
"handle": "accuse",
|
||||
"kind": "accuse",
|
||||
"roles": [
|
||||
{"role": "target", "kind": subject_role()},
|
||||
{"role": "charge", "kind": {"namespace": "entity", "kind": "fact"}},
|
||||
],
|
||||
"preconditions": [{"precondition": "knows", "fact": "charge", "at_least": "believed"}],
|
||||
"effect_slots": [
|
||||
{"op_kind": {"op": "advance_pressure", "by": 25}, "roles": ["target"], "bounds": {"bound": "none"}},
|
||||
],
|
||||
"outcome_bands": [{"weight": 1, "effects": [0]}],
|
||||
"carries_speech": false,
|
||||
}),
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// The one patch that declares the catalog and grants it to every person the
|
||||
/// world holds. A world that already carries a verb is a replay of this step
|
||||
/// and is not asked again by the caller.
|
||||
pub(crate) fn install(world: &WorldSnapshot) -> Result<DecodedBatch, String> {
|
||||
let mut calls: Vec<(String, String)> = declarations()
|
||||
.into_iter()
|
||||
.map(|(name, arguments)| (name.to_owned(), arguments.to_string()))
|
||||
.collect();
|
||||
for subject in world
|
||||
.subjects
|
||||
.iter()
|
||||
.filter(|subject| subject.kind == SubjectKind::Person && !subject.retired)
|
||||
{
|
||||
for verb in VERBS {
|
||||
calls.push((
|
||||
"grant_affordance".to_owned(),
|
||||
json!({
|
||||
"subject": {"ref": "existing", "value": subject.id},
|
||||
"affordance": {"ref": "draft", "value": verb},
|
||||
})
|
||||
.to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
let borrowed: Vec<(&str, &str)> = calls.iter().map(|(name, arguments)| (name.as_str(), arguments.as_str())).collect();
|
||||
decode_authoring_calls(&borrowed)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ghostlight::{
|
||||
CommandBody, CommandId, CreateWorldIntent, Lens, LensWeights, PlayPort, PrincipalCommandIntent,
|
||||
SubjectId, VerifiedPrincipalEvidence, WorldMailbox, decode_actor_call, table_view,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
struct Scenario {
|
||||
_directory: tempfile::TempDir,
|
||||
world: WorldMailbox,
|
||||
principal: VerifiedPrincipalEvidence,
|
||||
}
|
||||
|
||||
fn text(id: SubjectId) -> String {
|
||||
serde_json::to_value(id).unwrap().as_str().unwrap().to_owned()
|
||||
}
|
||||
|
||||
fn existing(id: impl serde::Serialize) -> Value {
|
||||
json!({"ref": "existing", "value": id})
|
||||
}
|
||||
|
||||
async fn snapshot(scene: &Scenario) -> ghostlight::WorldSnapshot {
|
||||
scene.world.snapshot().await.unwrap()
|
||||
}
|
||||
|
||||
fn who(snapshot: &ghostlight::WorldSnapshot, label: &str) -> SubjectId {
|
||||
snapshot.subjects.iter().find(|subject| subject.label == label).expect("a subject by that label").id
|
||||
}
|
||||
|
||||
async fn submit(scene: &Scenario, body: CommandBody) {
|
||||
let snapshot = snapshot(scene).await;
|
||||
scene
|
||||
.world
|
||||
.submit_principal(
|
||||
PrincipalCommandIntent {
|
||||
id: CommandId::new(),
|
||||
world_id: snapshot.world_id,
|
||||
expected_revision: snapshot.revision,
|
||||
body,
|
||||
},
|
||||
&scene.principal,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn batch(calls: &[(&str, Value)]) -> ghostlight::WorldPatch {
|
||||
let owned: Vec<(&str, String)> = calls.iter().map(|(name, arguments)| (*name, arguments.to_string())).collect();
|
||||
let borrowed: Vec<(&str, &str)> = owned.iter().map(|(name, arguments)| (*name, arguments.as_str())).collect();
|
||||
decode_authoring_calls(&borrowed).expect("the calls decode").patch
|
||||
}
|
||||
|
||||
/// The table's own ruling, through the one door the Dungeon Master holds.
|
||||
async fn rule(scene: &Scenario, calls: &[(&str, Value)]) {
|
||||
PlayPort::new(scene.world.clone()).submit_patch(CommandId::new(), batch(calls)).await.unwrap();
|
||||
}
|
||||
|
||||
/// A tavern with Dorra, her kin Brannoch and a witness, Grix; the Hold's
|
||||
/// watch stands at the gate with Hilda. The player, Korr, is in the tavern.
|
||||
/// Dorra counts Korr a friend, so nothing about the room is hostile.
|
||||
async fn consequence_world() -> Scenario {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let (world, _owner) = WorldMailbox::open(directory.path().join("world.cc")).unwrap();
|
||||
let principal = VerifiedPrincipalEvidence::new("consequence-scenario", chrono::Utc::now() + chrono::Duration::hours(4));
|
||||
let receipt = world
|
||||
.create(
|
||||
CreateWorldIntent {
|
||||
id: CommandId::new(),
|
||||
title: "Consequence Scenario".into(),
|
||||
brief: "A tavern, a gate and a watch.".into(),
|
||||
human_subject_label: "Korr".into(),
|
||||
narrative_persona_label: None,
|
||||
operational_agent_label: None,
|
||||
targets: BTreeMap::new(),
|
||||
jurisdictions: Vec::new(),
|
||||
lens_weights: LensWeights::new(BTreeMap::from([(Lens::Hearth, 1)])),
|
||||
era: None,
|
||||
},
|
||||
&principal,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let scene = Scenario { _directory: directory, world, principal };
|
||||
let start = snapshot(&scene).await;
|
||||
let commons = start.places.iter().find(|place| place.label == "The Commons").unwrap().id;
|
||||
let speak = start.affordances.iter().find(|entry| entry.entry.kind.0 == "speak").unwrap().id;
|
||||
let person = |handle: &str, label: &str, position: Value| {
|
||||
(
|
||||
"declare_subject",
|
||||
json!({
|
||||
"handle": handle,
|
||||
"label": label,
|
||||
"kind": "person",
|
||||
"controller": {"type": "narrative_persona"},
|
||||
"affordances": [existing(speak)],
|
||||
"position": position,
|
||||
}),
|
||||
)
|
||||
};
|
||||
let patch = batch(&[
|
||||
("declare_place", json!({"handle": "gate", "label": "The Gate", "container": null})),
|
||||
(
|
||||
"declare_route",
|
||||
json!({"handle": "road", "label": "The Road", "from": existing(commons), "to": {"ref": "draft", "value": "gate"}, "access": {"access": "public"}, "cost": 1}),
|
||||
),
|
||||
person("dorra", "Dorra Ironkettle", existing(commons)),
|
||||
person("brann", "Brannoch Deepvein", existing(commons)),
|
||||
person("grix", "Grix Sparkfinger", existing(commons)),
|
||||
person("hilda", "Hilda Gatewright", json!({"ref": "draft", "value": "gate"})),
|
||||
]);
|
||||
submit(&scene, CommandBody::AdmitPatch { answers: None, patch }).await;
|
||||
let drafted = snapshot(&scene).await;
|
||||
let (dorra, korr) = (who(&drafted, "Dorra Ironkettle"), who(&drafted, "Korr"));
|
||||
submit(
|
||||
&scene,
|
||||
CommandBody::AdmitPatch {
|
||||
answers: None,
|
||||
patch: batch(&[(
|
||||
"declare_attitude",
|
||||
json!({"holder": existing(dorra), "toward": {"toward": "subject", "of": existing(korr)}, "delta": 80, "basis": {"basis": "prejudice"}, "decay": null}),
|
||||
)]),
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let drafted = snapshot(&scene).await;
|
||||
submit(&scene, CommandBody::AdmitPatch { answers: None, patch: install(&drafted).unwrap().patch }).await;
|
||||
submit(&scene, CommandBody::ApproveDraft).await;
|
||||
submit(&scene, CommandBody::ActivateWorld).await;
|
||||
let _ = receipt;
|
||||
scene
|
||||
}
|
||||
|
||||
async fn attack(scene: &Scenario, victim: &str, display: &str) -> Result<(), ghostlight::MailboxError> {
|
||||
let now = snapshot(scene).await;
|
||||
let (korr, victim) = (who(&now, "Korr"), who(&now, victim));
|
||||
let arguments = json!({"target": text(victim), "display": display}).to_string();
|
||||
let (opportunity, invocation) = decode_actor_call(&now, korr, "", "attack", &arguments).expect("the player may attack");
|
||||
scene
|
||||
.world
|
||||
.submit_principal(
|
||||
PrincipalCommandIntent {
|
||||
id: CommandId::new(),
|
||||
world_id: now.world_id,
|
||||
expected_revision: now.revision,
|
||||
body: CommandBody::ExerciseDecision { opportunity, invocation },
|
||||
},
|
||||
&scene.principal,
|
||||
)
|
||||
.await
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
const DEED: &str = "Korr buries his axe in Dorra.";
|
||||
|
||||
fn open_grievances(view: &str) -> String {
|
||||
view.split("Open grievances").nth(1).unwrap().split("\n Persona material").next().unwrap().to_owned()
|
||||
}
|
||||
|
||||
fn between<'a>(text: &'a str, from: &str, to: &str) -> &'a str {
|
||||
let start = text.find(from).unwrap_or_else(|| panic!("`{from}` not in view")) + from.len();
|
||||
let end = start + text[start..].find(to).unwrap_or(text.len() - start);
|
||||
&text[start..end]
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn nothing_forbids_the_sword_and_the_room_sees_it() {
|
||||
let scene = consequence_world().await;
|
||||
// Dorra is the player's friend, and the attack is admitted all the same.
|
||||
attack(&scene, "Dorra Ironkettle", DEED).await.expect("an attack on a friend is admitted");
|
||||
let view = table_view(&snapshot(&scene).await);
|
||||
let grievances = open_grievances(&view);
|
||||
let seen = between(&grievances, "acts seen by:", "forums covering");
|
||||
for witness in ["Grix Sparkfinger", "Brannoch Deepvein", "Dorra Ironkettle"] {
|
||||
assert!(seen.contains(witness), "{witness} stands in the room and saw it: {seen}");
|
||||
}
|
||||
assert!(!seen.contains("Hilda"), "the gate is out of earshot and out of sight: {seen}");
|
||||
assert!(grievances.contains("Korr"), "{grievances}");
|
||||
assert!(grievances.contains("nothing has answered it yet"), "{grievances}");
|
||||
assert!(view.contains("Dorra Ironkettle ["), "{view}");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn an_unseen_world_has_no_open_grievance() {
|
||||
let scene = consequence_world().await;
|
||||
assert!(open_grievances(&table_view(&snapshot(&scene).await)).trim().ends_with("none"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn word_spreads_law_presses_and_kin_swear() {
|
||||
let scene = consequence_world().await;
|
||||
attack(&scene, "Dorra Ironkettle", DEED).await.unwrap();
|
||||
let now = snapshot(&scene).await;
|
||||
let view = table_view(&now);
|
||||
let (korr, grix, hilda, brann) =
|
||||
(who(&now, "Korr"), who(&now, "Grix Sparkfinger"), who(&now, "Hilda Gatewright"), who(&now, "Brannoch Deepvein"));
|
||||
let quoted = format!("\"{DEED}\" [");
|
||||
let deed = between(&view, "ed, "]").to_owned();
|
||||
let road = now.routes.iter().find(|route| route.label == "The Road").unwrap().id;
|
||||
assert!(!between(&view, &format!("\"{DEED}\" [{deed}]: "), "\n").contains("Hilda"), "the guard has not heard");
|
||||
|
||||
// The witness walks to the gate and tells the guard.
|
||||
rule(&scene, &[("relocate", json!({"subject": existing(grix), "via": existing(road)}))]).await;
|
||||
rule(&scene, &[("communicate", json!({"speaker": existing(grix), "fact": existing(&deed), "to": "colocated"}))]).await;
|
||||
let view = table_view(&snapshot(&scene).await);
|
||||
assert!(between(&view, &format!("\"{DEED}\" [{deed}]: "), "\n").contains("Hilda"), "the guard was told");
|
||||
|
||||
// Believing it, the guard regards the killer worse than a stranger.
|
||||
rule(
|
||||
&scene,
|
||||
&[(
|
||||
"declare_attitude",
|
||||
json!({"holder": existing(hilda), "toward": {"toward": "subject", "of": existing(korr)}, "delta": -60, "basis": {"basis": "rumour", "fact": existing(&deed)}, "decay": null}),
|
||||
)],
|
||||
)
|
||||
.await;
|
||||
let view = table_view(&snapshot(&scene).await);
|
||||
assert!(between(&view, "Regard (", "Persona material").contains("Hilda Gatewright ["), "{view}");
|
||||
|
||||
// The law leans on the player, and the grievance is no longer unanswered.
|
||||
assert!(open_grievances(&view).contains("nothing has answered it yet"));
|
||||
rule(&scene, &[("advance_pressure", json!({"source": {"from": "subject", "of": existing(hilda)}, "target": existing(korr), "by": 30}))]).await;
|
||||
let pressed = open_grievances(&table_view(&snapshot(&scene).await));
|
||||
assert!(between(&pressed, "pressed by:", "reckonings").contains("Hilda Gatewright"), "{pressed}");
|
||||
assert!(!pressed.contains("nothing has answered it yet"), "{pressed}");
|
||||
|
||||
// The victim's kin swear a reckoning with the player as counterparty.
|
||||
rule(
|
||||
&scene,
|
||||
&[(
|
||||
"create_commitment",
|
||||
json!({"subject": existing(brann), "counterparty": existing(korr), "kind": "obligation", "due": 600, "period": null, "checks": [], "statement": "Make Korr answer for Dorra."}),
|
||||
)],
|
||||
)
|
||||
.await;
|
||||
let sworn = open_grievances(&table_view(&snapshot(&scene).await));
|
||||
assert!(between(&sworn, "reckonings sworn against them:", "answered").contains("Brannoch Deepvein"), "{sworn}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_verb_text_refuses_violence() {
|
||||
let lower = serde_json::to_string(&declarations()).unwrap().to_lowercase();
|
||||
assert!(!lower.contains("not allowed to attack"));
|
||||
assert!(lower.find("refuse").is_none_or(|at| !lower[at..].contains("violence")));
|
||||
assert_eq!(declarations().len(), VERBS.len());
|
||||
}
|
||||
}
|
||||
|
|
@ -983,6 +983,103 @@ fn render_dependency_target(snapshot: &WorldSnapshot, target: &DependencyTarget)
|
|||
}
|
||||
}
|
||||
|
||||
/// The wrongs the world holds against a subject and what has answered them,
|
||||
/// read off state and stored nowhere: whom the doer wronged (a grievance in the
|
||||
/// victim's regard), who saw the doer's acts (`Seen` knowledge), which forums
|
||||
/// cover the doer, who presses the doer, and who has sworn a reckoning with the
|
||||
/// doer as counterparty. A grievance nothing answers is named as unanswered:
|
||||
/// the table's own judgement sends the watch, so what it needs is to see that
|
||||
/// no one has been sent.
|
||||
fn render_open_grievances(snapshot: &WorldSnapshot) -> String {
|
||||
use crate::attitude::AttitudeCause;
|
||||
use crate::patch::KnowledgeSource;
|
||||
let name = |id: SubjectId| {
|
||||
label_for_any_id(snapshot, &id_text(id)).map_or_else(
|
||||
|| format!("[{}]", id_text(id)),
|
||||
|label| format!("{label} [{}]", id_text(id)),
|
||||
)
|
||||
};
|
||||
let mut out = String::from("\n Open grievances (derived: who was wronged, who saw it, what answers it):");
|
||||
let mut any = false;
|
||||
for doer in &snapshot.subjects {
|
||||
let wronged: Vec<String> = snapshot
|
||||
.subjects
|
||||
.iter()
|
||||
.flat_map(|holder| {
|
||||
holder
|
||||
.opinions
|
||||
.iter()
|
||||
.filter(|held| held.toward == doer.id)
|
||||
.filter(|held| {
|
||||
held.causes
|
||||
.iter()
|
||||
.any(|cause| matches!(cause.cause, AttitudeCause::Grievance { .. }) && cause.delta < 0)
|
||||
})
|
||||
.map(|held| format!("{} ({:+})", name(holder.id), held.total))
|
||||
})
|
||||
.collect();
|
||||
if wronged.is_empty() {
|
||||
continue;
|
||||
}
|
||||
any = true;
|
||||
let mut seen_by = Vec::new();
|
||||
let mut acts = std::collections::BTreeSet::new();
|
||||
for witness in snapshot.subjects.iter().filter(|witness| witness.id != doer.id) {
|
||||
for row in &witness.knowledge {
|
||||
if row.source == (KnowledgeSource::Seen { by: doer.id }) {
|
||||
seen_by.push(name(witness.id));
|
||||
acts.insert(format!("\"{}\"", row.statement.as_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
seen_by.sort();
|
||||
seen_by.dedup();
|
||||
let pressing: Vec<String> = doer
|
||||
.pressures
|
||||
.iter()
|
||||
.filter_map(|pressure| match pressure.source {
|
||||
PressureSource::Subject(id) => Some(format!("{} ({})", name(id), pressure.magnitude.0)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let reckonings: Vec<String> = snapshot
|
||||
.subjects
|
||||
.iter()
|
||||
.flat_map(|holder| {
|
||||
holder
|
||||
.commitments
|
||||
.iter()
|
||||
.filter(|commitment| commitment.counterparty == Some(doer.id))
|
||||
.map(move |commitment| format!("{}: \"{}\"", name(holder.id), commitment.statement.as_str()))
|
||||
})
|
||||
.collect();
|
||||
let answered = !pressing.is_empty() || !reckonings.is_empty();
|
||||
out.push_str(&format!(
|
||||
" {} wronged {}; acts seen by: {}{}; forums covering them: {}; pressed by: {}; reckonings sworn against them: {}; {}",
|
||||
name(doer.id),
|
||||
joined_sorted(wronged),
|
||||
if seen_by.is_empty() { "no one".to_owned() } else { joined_sorted(seen_by) },
|
||||
if acts.is_empty() { String::new() } else { format!(" ({})", joined_sorted(acts.into_iter().collect())) },
|
||||
if doer.redress.is_empty() {
|
||||
"none".to_owned()
|
||||
} else {
|
||||
joined_sorted(doer.redress.iter().map(|forum| render_forum(snapshot, forum)).collect())
|
||||
},
|
||||
if pressing.is_empty() { "no one".to_owned() } else { joined_sorted(pressing) },
|
||||
if reckonings.is_empty() { "none".to_owned() } else { joined_sorted(reckonings) },
|
||||
if answered {
|
||||
"answered so far."
|
||||
} else {
|
||||
"nothing has answered it yet: no office presses them and no kin or ally has sworn anything. The office, the kin and the witnesses answer through their own people: dispatch them, or rule it with advance_pressure and create_commitment."
|
||||
},
|
||||
));
|
||||
}
|
||||
if !any {
|
||||
out.push_str(" none");
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A pressure source, in the same shape `advance_pressure`/`reduce_pressure`'s
|
||||
/// `PressureSourceRef` composite takes: a commitment names the promisor
|
||||
/// subject id and the commitment key; a dependency names its target; a
|
||||
|
|
@ -1594,6 +1691,8 @@ pub fn table_view(snapshot: &WorldSnapshot) -> String {
|
|||
out.push_str(" none");
|
||||
}
|
||||
|
||||
out.push_str(&render_open_grievances(snapshot));
|
||||
|
||||
out.push_str("\n Persona material:");
|
||||
let mut any_material = false;
|
||||
for subject in &snapshot.subjects {
|
||||
|
|
|
|||
Loading…
Reference in a new issue