pub struct EpochInfo {
pub epoch_id: EpochId,
pub rng_seed: u64,
pub tags: TagList,
pub summary: String,
pub events: Vec<Entity>,
pub characters: Vec<Entity>,
pub towns: Vec<Entity>,
pub calamities: Vec<Entity>,
pub blockers: Vec<Entity>,
}Expand description
The metadata file stored inside each epoch directory
(epoch/<epoch_id>/.epochinfo).
It contains only the information that is needed for the engine to
reconstruct the state of that particular epoch (seed, selected
events, parent link, etc.). The full world data will be kept in
separate storage (e.g. world.json) but is for stored here.
Fields§
§epoch_id: EpochIdThe ID of this epoch - should match the directory name.
rng_seed: u64RNG seed that was used to generate randomised data for this epoch. Keeping it in the file guarantees repeatable behaviour when replaying the same epoch.
Optional tags that help identify the epoch (e.g. "Winter-B").
summary: StringHuman-readable description or summary, useful for the log command.
events: Vec<Entity>The list of events currently in progress
characters: Vec<Entity>The list of characters currently present
towns: Vec<Entity>The list of towns currently present
calamities: Vec<Entity>The list of calamities currently present
blockers: Vec<Entity>The list of blockers currently present
Implementations§
Source§impl EpochInfo
impl EpochInfo
Sourcepub fn create_subfolders(&self) -> Result<(), EpochError>
pub fn create_subfolders(&self) -> Result<(), EpochError>
Create all subfolders as needed
This command can be safely used even if the folder already exists
Source§impl EpochInfo
impl EpochInfo
Sourcepub fn find_entity_of_type(
&self,
entity_to_find: &Option<EntityIdentifier>,
e_type: &EntityType,
) -> Result<&Entity, EpochError>
pub fn find_entity_of_type( &self, entity_to_find: &Option<EntityIdentifier>, e_type: &EntityType, ) -> Result<&Entity, EpochError>
Looks up an entity inside the given epoch_info according to the
supplied arguments.
The function returns a reference to the matching entity or an
EpochError::EntityNotFound if no entity matches.
§Arguments
entity_args- The arguments that identify the entity.e_type- The type of entity to look for.epoch_info- The epoch that contains all entities.
§Returns
Ok(&Entity)- The entity that matches the arguments.Err(EpochError::EntityNotFound)- No matching entity was found.
Sourcepub fn add_to_links(
&mut self,
target_id: Uuid,
target_t: &EntityType,
link_back: TypedLink,
) -> Result<(), EpochError>
pub fn add_to_links( &mut self, target_id: Uuid, target_t: &EntityType, link_back: TypedLink, ) -> Result<(), EpochError>
Adds a link between two entities inside the epoch.
The link is added to the entity identified by id_to_add_to. If the
target entity is not found, an EntityNotFoundById error is returned.
Sourcepub fn del_from_links(
&mut self,
target_id: Uuid,
target_t: &EntityType,
link_back: TypedLink,
) -> Result<(), EpochError>
pub fn del_from_links( &mut self, target_id: Uuid, target_t: &EntityType, link_back: TypedLink, ) -> Result<(), EpochError>
Removes a link from an entity inside the epoch.
The removal is performed on the target entity (id_to_add_to). If the
target entity cannot be found, an EpochError::EntityNotFoundById error
is returned. The removal itself is delegated to the entity’s
del_from_links method, which silently ignores missing links.
Sourcepub fn find_any_entity(
&self,
id: EntityIdentifier,
) -> Result<&Entity, EpochError>
pub fn find_any_entity( &self, id: EntityIdentifier, ) -> Result<&Entity, EpochError>
Find an entity by its UUID.
This function searches the currently loaded epoch for an entity whose
id matches the supplied Uuid. It looks in both the events, towns
and characters collections of the epoch.
§Arguments
id- TheUuidof the entity to locate.
§Returns
Ok(&Entity)- Reference to the entity if it is present in the current epoch.Err(EpochError::EntityNotFoundById(id))- No entity with the supplied UUID exists in the epoch.
Sourcepub fn find_entity_strict(
&self,
id: Uuid,
strict: Option<EntityType>,
) -> Result<&Entity, EpochError>
pub fn find_entity_strict( &self, id: Uuid, strict: Option<EntityType>, ) -> Result<&Entity, EpochError>
Find an entity from an Uuid
Sourcepub fn find_entity_strict_as_mut(
&mut self,
id: Uuid,
strict: Option<EntityType>,
) -> Result<&mut Entity, EpochError>
pub fn find_entity_strict_as_mut( &mut self, id: Uuid, strict: Option<EntityType>, ) -> Result<&mut Entity, EpochError>
Find an entity from an Uuid
Sourcepub fn vec_entities(&self, e_type: &EntityType) -> &Vec<Entity>
pub fn vec_entities(&self, e_type: &EntityType) -> &Vec<Entity>
Returns a slice over the entities of the requested type from the given EpochInfo.
The function matches the supplied e_type to the appropriate collection
inside epoch_info. For unimplemented entity types the call will panic
because of the todo!() placeholder.
Sourcepub fn remove_entity(
&mut self,
entity_identifier: &Option<EntityIdentifier>,
e_type: &EntityType,
) -> Result<Entity, EpochError>
pub fn remove_entity( &mut self, entity_identifier: &Option<EntityIdentifier>, e_type: &EntityType, ) -> Result<Entity, EpochError>
Removes an entity from the epoch’s collection and returns it.
The function looks up the entity that matches the supplied entity_identifier
in the collection corresponding to e_type. If the entity is found, it
is removed using swap_remove and returned. When the entity cannot be
located, an EpochError::EntityNotFound is returned.
Sourcepub fn vec_entities_mut(&mut self, e_type: &EntityType) -> &mut Vec<Entity>
pub fn vec_entities_mut(&mut self, e_type: &EntityType) -> &mut Vec<Entity>
Returns a mutable slice over the entities of the requested type from the given
EpochInfo.
Like vec_entities, this function selects the appropriate collection
based on e_type. Unimplemented variants will panic due to the todo!().
Sourcepub fn iter_all_entities_mut(&mut self) -> impl Iterator<Item = &mut Entity>
pub fn iter_all_entities_mut(&mut self) -> impl Iterator<Item = &mut Entity>
Returns an iterator over mutable references to all entities that are currently
stored in the EpochInfo container.
Sourcepub fn resolve_position(
&self,
position: &PositionIdentifier,
) -> Result<Position, EpochError>
pub fn resolve_position( &self, position: &PositionIdentifier, ) -> Result<Position, EpochError>
Get the position of an entity either directly or cloning one from an epoch
Sourcepub fn swap_entity(&mut self, entity: Entity) -> Result<Entity, EpochError>
pub fn swap_entity(&mut self, entity: Entity) -> Result<Entity, EpochError>
Swap an entity with an updated one
Trait Implementations§
Source§impl ConfigWritable for EpochInfo
impl ConfigWritable for EpochInfo
Source§fn save_folder(&self) -> String
fn save_folder(&self) -> String
Source§fn as_json(&self, action: String) -> Result<String, EpochError>
fn as_json(&self, action: String) -> Result<String, EpochError>
Source§fn save_with_context(
&self,
action_description: &str,
do_not_erase: &SaveMode,
) -> Result<(), EpochError>
fn save_with_context( &self, action_description: &str, do_not_erase: &SaveMode, ) -> Result<(), EpochError>
Source§impl<'de> Deserialize<'de> for EpochInfo
impl<'de> Deserialize<'de> for EpochInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Prettiable for EpochInfo
impl Prettiable for EpochInfo
Source§fn as_table(list: Vec<&Self>) -> Result<TableDisplay, EpochError>
fn as_table(list: Vec<&Self>) -> Result<TableDisplay, EpochError>
Source§fn show_as_log(&self)
fn show_as_log(&self)
as_log() to stdout.Auto Trait Implementations§
impl Freeze for EpochInfo
impl RefUnwindSafe for EpochInfo
impl Send for EpochInfo
impl Sync for EpochInfo
impl Unpin for EpochInfo
impl UnwindSafe for EpochInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Cell for Twhere
T: Display,
impl<T> Cell for Twhere
T: Display,
Source§fn cell(self) -> CellStruct
fn cell(self) -> CellStruct
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more