From a9615860826c4f65febdaf2f0fa279cb21073cbe Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sat, 15 Nov 2025 16:09:32 +0100 Subject: [PATCH] Adds the barebone structure of the project --- .gitignore | 12 ++++++++ Cargo.toml | 26 +++++++++++++++++ LICENSE | 35 ++++++++++++++++++---- README.md | 67 +++++++++++++++++++++++++++++++++++++++++-- bin_efo/Cargo.toml | 8 ++++++ bin_efo/src/main.rs | 63 ++++++++++++++++++++++++++++++++++++++++ cli_common/Cargo.toml | 6 ++++ cli_common/src/lib.rs | 14 +++++++++ lib_efo/Cargo.toml | 6 ++++ lib_efo/src/lib.rs | 66 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 296 insertions(+), 7 deletions(-) create mode 100644 Cargo.toml create mode 100644 bin_efo/Cargo.toml create mode 100644 bin_efo/src/main.rs create mode 100644 cli_common/Cargo.toml create mode 100644 cli_common/src/lib.rs create mode 100644 lib_efo/Cargo.toml create mode 100644 lib_efo/src/lib.rs diff --git a/.gitignore b/.gitignore index 3ca43ae..e7180de 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,15 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + + +# Added by cargo + +/target + + +# Added by cargo +# +# already existing elements were commented out + +#/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..63180ca --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "epoch_forge" +version = "0.1.0" +edition = "2024" + +[dependencies] + +[[bin]] +name = "efo" +path = "bin_efo/src/main.rs" + +[workspace] +resolver = "3" +members = ["bin_efo", "cli_common", "lib_efo"] + +# [workspace.package] +# version = "1.2.3" +# authors = ["Nice Folks"] +# description = "A short description of my package" +# documentation = "https://example.com/bar" + +# [workspace.dependencies] +# cc = "1.0.73" +# rand = "0.8.5" +# regex = { version = "1.6.0", default-features = false, features = ["std"] } + diff --git a/LICENSE b/LICENSE index d805c3a..c17e26f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,34 @@ -MIT License +Copyright (c) 2025 Dandaedre -Copyright (c) 2025 MadGobblins +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to +treat the Software as is, without restriction, subject to the following +condition: -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + • The Software may not be used, directly or indirectly, for training, + fine‑tuning, or otherwise feeding into any artificial‑intelligence + model or system. This includes, but is not limited to, usage as a + training dataset for machine‑learning or deep‑learning models, + model‑optimization, reinforcement‑learning, or any AI‑based analytics + pipeline. -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + • The Software may not be “scraped,” extracted, or otherwise harvested + in bulk for the purpose of feeding an AI model, whether the result is + an intermediate model, a vector embedding, or any other representation + used for AI training. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + • The foregoing restriction applies to the Software in its original + form as well as to any derivatives, modifications, or adaptations + thereof, unless the derivative is explicitly released under a + license that expressly waives this restriction. + +All other rights granted under the MIT license remain in force, namely: + + • The Software may be used for any non‑AI purpose, including commercial + or non‑commercial use, modification, distribution, private or public + deployment, and so on. + + • The Software is provided “as is,” without warranty of any kind, + express or implied. The authors or copyright holders shall not be + liable for any claim, damages, or other liability arising from the + use or misuse of the Software. diff --git a/README.md b/README.md index 7aee2fd..5c75f6e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,66 @@ -# epoch_forge +# 📦 Epoch Forge (`epoch_forge`) -“time‑evolution + fantasy org‑management” \ No newline at end of file +> **A Rust‑powered CLI for managing fantasy organisations across time.** +> *Think of it as a living, breathing world‑state engine that lets you “rewind”, “fast‑forward”, and **alter** the history of guilds, towns, wars, and characters.* + +> 🚀 *Fast, type‑safe, and fully testable.* + +--- + +## ✨ Quick start + +```bash +# clone the repo +git clone https://github.com/yourname/epoch_forge.git +cd epoch_forge + +# build the binary +cargo build --release + +# initialise an empty world (epoch 0) +./target/release/efo epoch --init + +# add a guild +./target/release/efo org add --name "The Iron Horde" --leader "Gorun" + +# add a town +./target/release/efo town add --name "Durn" --population 350 + +# create an alliance +./target/release/efo link add --type alliance --org "Iron Horde" --town "Durn" + +# advance the timeline +./target/release/efo epoch --advance 3 + +# inspect the world +cat world.json +``` + +## 🏆 Project Highlights + +| Feature | What it gives you | Where it lives | +|---------|------------------|----------------| +| **Epoch management** | Switch, advance, or rewind the timeline | `core::epoch` | +| **Event handling** | Add/remove world‑shaping events (storms, festivals, wars) | `core::event` | +| **Organisation CRUD** | Guilds, factions, corporations | `core::org` | +| **Character CRUD** | Heroes, villains, NPCs | `core::character` | +| **Town CRUD** | Villages, cities, trade hubs | `core::town` | +| **Link network** | Alliances, wars, roads, trade routes | `core::link` | +| **Persistence** | JSON/YAML stores, pluggable back‑ends | `core::storage` | +| **CLI** | `efo` binary with sub‑commands | `efo` crate | +| **Tests** | Unit & integration coverage | `tests/` | + +--- + +### 📃 Quick reference table + +| Sub‑command | Usage | What it changes | +|-------------|-------|-----------------| +| `epoch` | `efo epoch --init`
`efo epoch --advance N`
`efo epoch --target ID` | Creates a world; moves time forward or back. | +| `event` | `efo event add ...`
`efo event remove ...` | Adds or removes an event. | +| `org` | `efo org add ...`
`efo org remove ...` | Manages guilds/factions. | +| `chr` | `efo chr add ...`
`efo chr remove ...` | Handles characters. | +| `town` | `efo town add ...`
`efo town remove ...` | Town CRUD. | +| `link` | `efo link add ...`
`efo link remove ...` | Relations: alliances, wars, roads, trade. | + +Happy forging! 🔨✨ diff --git a/bin_efo/Cargo.toml b/bin_efo/Cargo.toml new file mode 100644 index 0000000..0ec51f8 --- /dev/null +++ b/bin_efo/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "bin_efo" +version = "0.1.0" +edition = "2024" + +[dependencies] +cli_common = { path = "../cli_common" } +lib_efo = { path = "../lib_efo" } diff --git a/bin_efo/src/main.rs b/bin_efo/src/main.rs new file mode 100644 index 0000000..eca8049 --- /dev/null +++ b/bin_efo/src/main.rs @@ -0,0 +1,63 @@ +//! # `efo` +//! +//! The **command‑line interface** for `epoch_forge`. It exposes a single +//! binary `efo` that supports the following sub‑commands: +//! +//! - `epoch` – switch / advance time +//! - `event` – add / remove events +//! - `org` – add / remove organisations +//! - `chr` – add / remove characters +//! - `town` – add / remove towns +//! - `link` – add / remove links (alliances, wars, roads, etc.) +//! +//! Each sub‑command is implemented in its own module under `commands/`. +//! The `main.rs` file simply parses arguments with `clap` and dispatches +//! to the appropriate handler. The handlers share a common `World` +//! instance that they load from / persist to disk. +//! +//! ## Usage +//! ```sh +//! efo org add --name "The Iron Horde" --leader "Gorun" +//! efo epoch --advance 5 +//! efo link add --type alliance --org "Iron Horde" --town "Durn" +//! ``` +// use clap::{Parser, Subcommand}; + +// mod cli; +// mod commands; + +// use commands::*; + +// #[derive(Parser)] +// #[command(name = "efo")] +// #[command(about = "Epoch Forge – manage organisations over time")] +// struct Opts { +// #[command(subcommand)] +// cmd: Subcommands, +// } + +// #[derive(Subcommand)] +// enum Subcommands { +// Epoch(commands::epoch::EpochCmd), +// Event(commands::event::EventCmd), +// Org(commands::org::OrgCmd), +// Chr(commands::chr::ChrCmd), +// Town(commands::town::TownCmd), +// Link(commands::link::LinkCmd), +// } + +// fn main() { +// let opts = Opts::parse(); +// match opts.cmd { +// Subcommands::Epoch(c) => c.handle(), +// Subcommands::Event(c) => c.handle(), +// Subcommands::Org(c) => c.handle(), +// Subcommands::Chr(c) => c.handle(), +// Subcommands::Town(c) => c.handle(), +// Subcommands::Link(c) => c.handle(), +// } +// } + +fn main() { + println!("Hello, world!"); +} diff --git a/cli_common/Cargo.toml b/cli_common/Cargo.toml new file mode 100644 index 0000000..00feba1 --- /dev/null +++ b/cli_common/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "cli_common" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/cli_common/src/lib.rs b/cli_common/src/lib.rs new file mode 100644 index 0000000..b93cf3f --- /dev/null +++ b/cli_common/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/lib_efo/Cargo.toml b/lib_efo/Cargo.toml new file mode 100644 index 0000000..e79ecc2 --- /dev/null +++ b/lib_efo/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "lib_efo" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/lib_efo/src/lib.rs b/lib_efo/src/lib.rs new file mode 100644 index 0000000..9cf4fae --- /dev/null +++ b/lib_efo/src/lib.rs @@ -0,0 +1,66 @@ +//! # `lib_efo` +//! +//! The **engine** that drives *Epoch Forge*. It contains a pure, dependency‑free +//! representation of a fantasy world and all the logic needed to manipulate it. +//! +//! The crate is split into the following domains, each exposed as a public module: +//! - `world` – holds the global state (`World`) and a lightweight snapshot (`Context`). +//! - `epoch` – manages the passage of time and epoch switching. +//! - `event` – CRUD and evaluation of events that affect the world. +//! - `org` – organisations, guilds, factions and their history. +//! - `character` – individual characters, traits and lineage. +//! - `town` – towns, cities, trade hubs and their populations. +//! - `link` – relations such as wars, alliances, roads, commerce. +//! - `storage` – generic persistence layer (`Store`) with JSON/YAML back‑ends. +//! - `util` – small helpers, ID generation, error types, etc. +//! +//! All public types implement `serde::Serialize / Deserialize` so that they can +//! be persisted easily. The `World` struct also offers a convenient +//! `World::load()` / `World::save()` API that uses the default JSON file +//! (`world.json` in the current directory). +//! ## Example +//! +//! ```rust +//! use core::{World, OrgManager, Org}; +//! +//! // create a new world and add an organisation +//! let mut world = World::new(); +//! let org = Org::new("The Iron Horde", "Gorun"); +//! world.orgs().add(org); +//! +//! // persist it +//! world.save().expect("save world"); +//! ```// +// pub mod character; +// pub mod epoch; +// pub mod event; +// pub mod link; +// pub mod org; +// pub mod storage; +// pub mod town; +// pub mod util; +// pub mod world; + +// pub use character::{Character, CharacterManager}; +// pub use epoch::{Epoch, EpochManager}; +// pub use event::{Event, EventManager}; +// pub use link::{Link, LinkKind, LinkManager}; +// pub use org::{Org, OrgManager}; +// pub use storage::{JsonStore, Store, YamlStore}; +// pub use town::{Town, TownManager}; +// pub use world::{Context, World}; + +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +}