Adds the barebone structure of the project

This commit is contained in:
Dandaedre 2025-11-15 16:09:32 +01:00
parent f23753060e
commit a961586082
10 changed files with 296 additions and 7 deletions

12
.gitignore vendored
View File

@ -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

26
Cargo.toml Normal file
View File

@ -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"] }

35
LICENSE
View File

@ -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.

View File

@ -1,3 +1,66 @@
# epoch_forge
# 📦 Epoch Forge (`epoch_forge`)
“time‑evolution + fantasy org‑management”
> **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`<br>`efo epoch --advance N`<br>`efo epoch --target ID` | Creates a world; moves time forward or back. |
| `event` | `efo event add ...`<br>`efo event remove ...` | Adds or removes an event. |
| `org` | `efo org add ...`<br>`efo org remove ...` | Manages guilds/factions. |
| `chr` | `efo chr add ...`<br>`efo chr remove ...` | Handles characters. |
| `town` | `efo town add ...`<br>`efo town remove ...` | Town CRUD. |
| `link` | `efo link add ...`<br>`efo link remove ...` | Relations: alliances, wars, roads, trade. |
Happy forging! 🔨✨

8
bin_efo/Cargo.toml Normal file
View File

@ -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" }

63
bin_efo/src/main.rs Normal file
View File

@ -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!");
}

6
cli_common/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "cli_common"
version = "0.1.0"
edition = "2024"
[dependencies]

14
cli_common/src/lib.rs Normal file
View File

@ -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);
}
}

6
lib_efo/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "lib_efo"
version = "0.1.0"
edition = "2024"
[dependencies]

66
lib_efo/src/lib.rs Normal file
View File

@ -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<T>`) 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);
}
}