Adds boc/user doc
Build Successful The build was successful
Gitea/epoch_forge/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2025-12-13 20:21:47 +01:00
parent ec4c930bfc
commit 7263d3ab72
9 changed files with 62 additions and 18 deletions

View File

@ -1 +1,2 @@
snapshots
*.svg

View File

@ -1,8 +1,8 @@
[last_run_clean]
run_status = "Success"
lines_parsed = 83
coverage = 51.17
coverage = 50.17
[last_run_clean.run_duration]
secs = 24
nanos = 975426411
secs = 25
nanos = 72743368

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 51%"><title>test-coverage: 51%</title><linearGradient id="bms-4635e915b4180cf4" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-4635e915b4180cf4"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-4635e915b4180cf4)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#97ca00"/><rect width="122" height="18" fill="url(#bms-4635e915b4180cf4)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">51%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">51%</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 50%"><title>test-coverage: 50%</title><linearGradient id="bms-8fc2dc264327201c" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-8fc2dc264327201c"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-8fc2dc264327201c)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#97ca00"/><rect width="122" height="18" fill="url(#bms-8fc2dc264327201c)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">50%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">50%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -193,6 +193,13 @@ fn handle_create_entity(
main_epoch: &mut EpochConfig,
) -> Result<(), EpochError> {
let epoch_info = main_epoch.try_load_current_as_mut()?;
if find_entity(entity_args, e_type, epoch_info).is_ok() {
Err(EpochError::EntityAlreadyExist(
entity_args.identifier.clone(),
))?;
};
let vec_entities: &mut Vec<Entity> = vec_entities_mut(e_type, epoch_info);
let mut entity = Entity::create_rng(e_type, &entity_args.rng)?;
@ -409,8 +416,8 @@ fn vec_entities<'a>(
EntityType::Character => &epoch_info.characters,
EntityType::Player => todo!(),
EntityType::Town => &epoch_info.towns,
EntityType::Monster => todo!(),
EntityType::Blocker => todo!(),
EntityType::Monster => &epoch_info.calamities,
EntityType::Blocker => &epoch_info.blockers,
EntityType::Event => &epoch_info.events,
}
}
@ -437,8 +444,8 @@ fn vec_entities_mut<'a>(
EntityType::Character => &mut epoch_info.characters,
EntityType::Player => todo!(),
EntityType::Town => &mut epoch_info.towns,
EntityType::Monster => todo!(),
EntityType::Blocker => todo!(),
EntityType::Monster => &mut epoch_info.calamities,
EntityType::Blocker => &mut epoch_info.blockers,
EntityType::Event => &mut epoch_info.events,
}
}

View File

@ -7,7 +7,6 @@
//!
//! * [`epoch`](crate::commands::epoch) - switch / advance time
//! * [`event`](crate::commands::entity_generic) - add / remove events
//! * [`org`](crate::commands::entity_generic) - add / remove organisations
//! * [`chr`](crate::commands::entity_generic) - add / remove characters
//! * [`town`](crate::commands::entity_generic) - add / remove towns
//! * [`blocker`](crate::commands::entity_generic) - add / remove blockers
@ -26,7 +25,7 @@
use std::fmt::Debug;
use clap::{ArgAction, Parser, Subcommand};
use clap::{Parser, Subcommand};
use crate::{
commands::{
@ -47,10 +46,9 @@ mod success;
#[command(name = "efo")]
#[command(about = "Epoch Forge - manage organisations over time")]
struct Cli {
/// The level of verbosity
#[arg(short, long, action = ArgAction::Count, global = true)]
verbose: u8,
// /// The level of verbosity
// #[arg(short, long, action = ArgAction::Count, global = true)]
// verbose: u8,
#[command(subcommand)]
/// The top level command to be executed
command: TopLevelCmd,
@ -78,8 +76,15 @@ enum TopLevelCmd {
Event(EntitySubCommands),
// #[command(subcommand)]
// Org(commands::org::OrgCmd),
// #[command(subcommand)]
// Town(commands::town::TownCmd),
/// Handle Towns
#[command(subcommand)]
Town(EntitySubCommands),
/// Handle Calamities
#[command(subcommand)]
Calamity(EntitySubCommands),
/// Handle Blocker
#[command(subcommand)]
Blocker(EntitySubCommands),
// Link(commands::link::LinkCmd),
/// Generate random structures and display them
#[command(subcommand)]
@ -130,5 +135,17 @@ fn exec_dispatch(cli: Cli) -> Result<(), AppError> {
&cmd,
&lib_efo::stats::EntityType::Event,
),
TopLevelCmd::Town(cmd) => commands::entity_generic::handle_entity_commands(
&cmd,
&lib_efo::stats::EntityType::Town,
),
TopLevelCmd::Calamity(cmd) => commands::entity_generic::handle_entity_commands(
&cmd,
&lib_efo::stats::EntityType::Monster,
),
TopLevelCmd::Blocker(cmd) => commands::entity_generic::handle_entity_commands(
&cmd,
&lib_efo::stats::EntityType::Blocker,
),
}
}

View File

@ -391,6 +391,8 @@ impl EpochConfig {
/// * `Err(EpochError::EntityNotFoundById(id))` - No entity with the
/// supplied UUID exists in the epoch.
///
#[allow(dead_code)]
// TODO: Add to a generic show
unsafe fn find_entity(&self, id: Uuid) -> Result<&Entity, EpochError> {
let epoch_info = unsafe { self.try_load_id(self.epoch_id) }?;
let predicate = |entity: &&Entity| entity.id == id;
@ -400,6 +402,8 @@ impl EpochConfig {
.find(predicate)
.or(epoch_info.characters.iter().find(predicate))
.or(epoch_info.towns.iter().find(predicate))
.or(epoch_info.blockers.iter().find(predicate))
.or(epoch_info.calamities.iter().find(predicate))
.ok_or(EpochError::EntityNotFoundById(id))
}
}

View File

@ -63,6 +63,12 @@ pub struct EpochInfo {
#[table(skip)]
/// The list of towns currently present
pub towns: Vec<Entity>,
#[table(skip)]
/// The list of calamities currently present
pub calamities: Vec<Entity>,
#[table(skip)]
/// The list of blockers currently present
pub blockers: Vec<Entity>,
}
impl Prettiable for EpochInfo {}
@ -77,6 +83,8 @@ impl Default for EpochInfo {
events: Vec::new(),
characters: Vec::new(),
towns: Vec::new(),
calamities: Vec::new(),
blockers: Vec::new(),
}
}
}

View File

@ -311,6 +311,15 @@ pub enum EpochError {
#[diagnostic(code(EntityIdentifierError::InvalidIdentifier))]
#[help("Verify that the UUID after `@` is a valid id.")]
EmptyIdentifier,
/// The entity already exists.
#[error("Failed to create entity: {0:?} already exists")]
#[diagnostic(code(EntityError::EntityAlreadyExist))]
#[help(
"Ensure that the entity name or ID is unique before creating a new one. \
You may need to delete or rename the existing entity."
)]
EntityAlreadyExist(Option<EntityIdentifier>),
}
/// A small enum of explicit user-facing error messages.

View File

@ -1,9 +1,7 @@
#![allow(clippy::unwrap_used)]
use insta::assert_debug_snapshot;
use insta::assert_snapshot;
use super::*;
use crate::entity::Entity;
use crate::stats::GameStat;
use crate::stats::GenericStat;
use crate::stats::StatPair;