Corrected some bad things about naming and started diff
Build Successful The build was successful
Gitea/epoch_forge/pipeline/head This commit looks good
Details
Build Successful The build was successful
Gitea/epoch_forge/pipeline/head This commit looks good
Details
This commit is contained in:
parent
7c403729ad
commit
79b8330b7d
|
|
@ -10,4 +10,4 @@ serde_json = "1.0.145"
|
|||
miette = { version = "7.6.0", features = ["fancy"] }
|
||||
env_logger = "0.11.8"
|
||||
log = "0.4.28"
|
||||
derive_more = { version = "2.0.1", features = ["display"] }
|
||||
derive_more = { version = "2.0.1", features = ["display", "add"] }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! The show commands
|
||||
//! Used to display structures with various degree of verbosity
|
||||
|
||||
use clap::{Args, Subcommand};
|
||||
use clap::Subcommand;
|
||||
use lib_efo::{Displayable, entity::Entity, naming::NAMING};
|
||||
|
||||
use crate::error::AppError;
|
||||
|
|
|
|||
|
|
@ -421,6 +421,111 @@
|
|||
"Seer",
|
||||
"Master"
|
||||
],
|
||||
"exotic_prefixes": [
|
||||
"Ar",
|
||||
"Bel",
|
||||
"Zel",
|
||||
"Kyn",
|
||||
"Nai",
|
||||
"Vyr",
|
||||
"Sera",
|
||||
"Jor",
|
||||
"Lun",
|
||||
"Yara",
|
||||
"Esh",
|
||||
"Mor",
|
||||
"Kael",
|
||||
"Tar",
|
||||
"Lyr",
|
||||
"Dra",
|
||||
"Qin",
|
||||
"Thal",
|
||||
"Oryn",
|
||||
"Sil",
|
||||
"Vex",
|
||||
"Gor",
|
||||
"Rin",
|
||||
"Zan"
|
||||
],
|
||||
"exotic_infixes": [
|
||||
"en",
|
||||
"ae",
|
||||
"or",
|
||||
"is",
|
||||
"sen",
|
||||
"kar",
|
||||
"ju",
|
||||
"ja",
|
||||
"ur",
|
||||
"ai",
|
||||
"ir",
|
||||
"an",
|
||||
"el",
|
||||
"ël",
|
||||
"æl",
|
||||
"ær",
|
||||
"łu",
|
||||
"đj",
|
||||
"äl",
|
||||
"in",
|
||||
"eu",
|
||||
"ai",
|
||||
"aï",
|
||||
"io",
|
||||
"ea",
|
||||
"oa",
|
||||
"ui",
|
||||
"oi",
|
||||
"øl",
|
||||
"ou",
|
||||
"ea",
|
||||
"'",
|
||||
"au"
|
||||
],
|
||||
"exotic_suffixes": [
|
||||
"ion",
|
||||
"ara",
|
||||
"eth",
|
||||
"on",
|
||||
"yr",
|
||||
"ith",
|
||||
"dor",
|
||||
"zen",
|
||||
"mar",
|
||||
"fen",
|
||||
"is",
|
||||
"al",
|
||||
"or",
|
||||
"ex",
|
||||
"an",
|
||||
"ul",
|
||||
"ik",
|
||||
"en",
|
||||
"ar",
|
||||
"ur"
|
||||
],
|
||||
"exotic_syllables": [
|
||||
"ra",
|
||||
"el",
|
||||
"ka",
|
||||
"la",
|
||||
"ma",
|
||||
"za",
|
||||
"sha",
|
||||
"na",
|
||||
"ta",
|
||||
"li",
|
||||
"vi",
|
||||
"da",
|
||||
"shi",
|
||||
"ri",
|
||||
"lo",
|
||||
"xi",
|
||||
"po",
|
||||
"ke",
|
||||
"do",
|
||||
"zo"
|
||||
],
|
||||
"event_ideas": [
|
||||
{
|
||||
"name": "storm_flood",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
//! by a type-safe system. For the moment it provides a quick lookup for
|
||||
//! logic that distinguishes creatures, items, terrain, etc.
|
||||
//!
|
||||
use derive_more::{Add, Sub};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::stats::{EntityType, MetaStats, OverallStats};
|
||||
|
|
@ -70,12 +71,13 @@ pub struct Entity {
|
|||
/// been calculated to keep stats within a sane range.
|
||||
///
|
||||
/// `min` and `max` are inclusive.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, Add, Sub)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct EffectBounds {
|
||||
pub min: usize,
|
||||
pub max: usize,
|
||||
}
|
||||
|
||||
/// How the entity's effect is applied over time.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
pub enum EffectApplication {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ use colored::*; // [3] - colored-rs examples
|
|||
|
||||
use crate::Displayable;
|
||||
use crate::entity::Entity;
|
||||
use crate::stats::Symbols;
|
||||
use crate::epoch::epoch_traits::Diffable;
|
||||
use crate::stats::{MetaStats, Symbols};
|
||||
|
||||
// ---------- Implementation ----------
|
||||
impl Displayable for Entity {
|
||||
|
|
@ -126,3 +127,56 @@ impl Entity {
|
|||
out
|
||||
}
|
||||
}
|
||||
|
||||
/// Compare a field on `self` with the same field on `other`.
|
||||
/// If they are equal → `None`, otherwise → the value from `other`.
|
||||
macro_rules! diff_fields {
|
||||
// Two arguments: the two objects you want to compare
|
||||
($self:ident, $other:ident, $( $field:ident ),* $(,)?) => {
|
||||
$(
|
||||
let $field = if $self.$field == $other.$field {
|
||||
None
|
||||
} else {
|
||||
$other.$field.clone()
|
||||
};
|
||||
)*
|
||||
};
|
||||
}
|
||||
impl Diffable for Entity {
|
||||
fn delta(&self, other: &Self) -> Self {
|
||||
let name = if self.name == other.name {
|
||||
self.name.clone()
|
||||
} else {
|
||||
format!("{}->{}", self.name, other.name)
|
||||
};
|
||||
Self {
|
||||
name,
|
||||
stats: self.stats.clone() - other.stats.clone(),
|
||||
temp_stats: self.temp_stats.clone() - other.temp_stats.clone(),
|
||||
metadata: self.metadata.delta(&other.metadata),
|
||||
entity_type: self.entity_type.clone(),
|
||||
duration: self.duration.clone(),
|
||||
effect_nature: self.effect_nature.clone(),
|
||||
effect_bounds: self.effect_bounds.clone() - other.effect_bounds.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Diffable for MetaStats {
|
||||
fn delta(&self, other: &Self) -> Self {
|
||||
diff_fields!(self, other, capital, governor);
|
||||
Self {
|
||||
position: self.position.clone() - other.position.clone(),
|
||||
capital,
|
||||
governor,
|
||||
faction: self.faction.clone() - other.faction.clone(),
|
||||
links: self
|
||||
.links
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter(|t1| other.links.iter().any(|t2| t1 == t2))
|
||||
.collect(),
|
||||
prestige: self.prestige - other.prestige,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ use std::{fmt::Display, fs::File, io::Write};
|
|||
use crate::{epoch::SaveMode, error::EpochError};
|
||||
|
||||
/// Elements that can be compared with another instance to produce a diff.
|
||||
pub trait Diffable {}
|
||||
pub trait Diffable {
|
||||
/// Compare self with another struct of the same type and return a new instance containing the difference
|
||||
fn delta(&self, other: &Self) -> Self;
|
||||
}
|
||||
|
||||
/// Elements that can be applied to the current world state.
|
||||
pub trait Applyable {}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ use crate::thin_newtype;
|
|||
use cli_table::Color;
|
||||
use cli_table::Table;
|
||||
use colored::Colorize;
|
||||
use derive_more::Add;
|
||||
use derive_more::Display;
|
||||
use derive_more::Sub;
|
||||
use serde::{Deserialize, Serialize};
|
||||
mod implementations;
|
||||
|
||||
|
|
@ -26,8 +28,7 @@ mod implementations;
|
|||
/// by comment blocks that describe each thematic section.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
// Derive more
|
||||
#[derive(Table)]
|
||||
// #[derive(Add, Sub)]
|
||||
#[derive(Table, Add, Sub)]
|
||||
pub struct OverallStats {
|
||||
// ──────────────────────── Demographics ────────────────────────
|
||||
/// Total economic health of the entity.
|
||||
|
|
@ -324,7 +325,7 @@ pub struct StatPair {
|
|||
}
|
||||
|
||||
/// Structure used to indicate position, possess nice helper methods to use as is in the program
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone, Add, Sub)]
|
||||
pub struct Position(isize, isize);
|
||||
|
||||
impl Position {
|
||||
|
|
|
|||
|
|
@ -3,19 +3,11 @@
|
|||
use colored::Colorize;
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::entity::EffectApplication;
|
||||
use crate::entity::EffectBounds;
|
||||
use crate::entity::EntityDuration;
|
||||
use crate::entity::{EffectApplication, EffectBounds, EntityDuration};
|
||||
use crate::error::EpochError;
|
||||
use crate::stats;
|
||||
use crate::stats::EntityType;
|
||||
use crate::stats::GameStat;
|
||||
use crate::stats::GenericStat;
|
||||
use crate::stats::ListStats;
|
||||
use crate::stats::OverallStats;
|
||||
use crate::stats::Position;
|
||||
use crate::stats::StatPair;
|
||||
use crate::stats::Symbols;
|
||||
use crate::stats::{
|
||||
self, EntityType, GameStat, GenericStat, ListStats, OverallStats, Position, StatPair, Symbols,
|
||||
};
|
||||
|
||||
/// Creates a thin, deref-able wrapper around an inner type.
|
||||
#[macro_export]
|
||||
|
|
@ -36,6 +28,8 @@ macro_rules! thin_newtype {
|
|||
Serialize,
|
||||
Deserialize,
|
||||
Display,
|
||||
Add,
|
||||
Sub,
|
||||
)]
|
||||
pub struct $name(pub $inner);
|
||||
|
||||
|
|
|
|||
31
naming.json
31
naming.json
|
|
@ -421,7 +421,6 @@
|
|||
"Seer",
|
||||
"Master"
|
||||
],
|
||||
|
||||
"exotic_prefixes": [
|
||||
"Ar",
|
||||
"Bel",
|
||||
|
|
@ -505,28 +504,6 @@
|
|||
"ar",
|
||||
"ur"
|
||||
],
|
||||
"exotic_syllables": [
|
||||
"ra",
|
||||
"el",
|
||||
"ka",
|
||||
"la",
|
||||
"ma",
|
||||
"za",
|
||||
"sha",
|
||||
"na",
|
||||
"ta",
|
||||
"li",
|
||||
"vi",
|
||||
"da",
|
||||
"shi",
|
||||
"ri",
|
||||
"lo",
|
||||
"xi",
|
||||
"po",
|
||||
"ke",
|
||||
"do",
|
||||
"zo"
|
||||
],
|
||||
"event_ideas": [
|
||||
{
|
||||
"name": "storm_flood",
|
||||
|
|
@ -912,7 +889,7 @@
|
|||
},
|
||||
{
|
||||
"name": "city_corruption_scandal",
|
||||
"description": "A high‑ranking magistrate is discovered embezzling city funds, sparking public outrage and a demand for accountability.",
|
||||
"description": "A high-ranking magistrate is discovered embezzling city funds, sparking public outrage and a demand for accountability.",
|
||||
"stats": [
|
||||
{
|
||||
"stat": "Food",
|
||||
|
|
@ -1490,7 +1467,7 @@
|
|||
},
|
||||
{
|
||||
"name": "resource_piracy",
|
||||
"description": "Sea‑borne raiders seize a shipment of precious stones destined for the city, flooding the market with counterfeit goods.",
|
||||
"description": "Sea-borne raiders seize a shipment of precious stones destined for the city, flooding the market with counterfeit goods.",
|
||||
"stats": [
|
||||
{
|
||||
"stat": "Trade",
|
||||
|
|
@ -2304,7 +2281,7 @@
|
|||
},
|
||||
{
|
||||
"name": "plague_of_scorpion",
|
||||
"description": "A deadly disease spreads through the populace, turning citizens into venom‑infused monsters.",
|
||||
"description": "A deadly disease spreads through the populace, turning citizens into venom-infused monsters.",
|
||||
"stats": [
|
||||
{
|
||||
"stat": "Health",
|
||||
|
|
@ -2463,4 +2440,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue