diff --git a/src/components.rs b/src/components.rs index 9bf44de..38a1ac4 100644 --- a/src/components.rs +++ b/src/components.rs @@ -1,4 +1,5 @@ -use crate::gamesystem::attr_bonus; +use std::collections::HashMap; + use ::rltk::{Point, RGB}; use ::serde::{Deserialize, Serialize}; use ::specs::error::NoError; @@ -6,6 +7,8 @@ use ::specs::prelude::*; use ::specs::saveload::{ConvertSaveload, Marker}; use ::specs_derive::*; +use crate::gamesystem::attr_bonus; + #[derive(Component, ConvertSaveload, Default, Copy, Clone)] pub struct Position { pub x: i32, @@ -274,6 +277,18 @@ pub struct Attributes { pub intelligence: Attribute, } +#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] +pub enum Skill { + Melee, + Defense, + Magic, +} + +#[derive(Component, Debug, Serialize, Deserialize, Clone)] +pub struct Skills { + pub skills: HashMap, +} + // Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an // Entity. diff --git a/src/main.rs b/src/main.rs index cc79b95..4dcdb38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -543,6 +543,7 @@ fn main() -> ::rltk::BError { Vendor, Quips, Attributes, + Skills, ); gs.ecs.insert(SimpleMarkerAllocator::::new()); diff --git a/src/saveload_system.rs b/src/saveload_system.rs index 303b341..366f6ae 100644 --- a/src/saveload_system.rs +++ b/src/saveload_system.rs @@ -93,6 +93,7 @@ pub fn save_game(ecs: &mut World) { Vendor, Quips, Attributes, + Skills, ); } @@ -188,6 +189,7 @@ pub fn load_game(ecs: &mut World) { Vendor, Quips, Attributes, + Skills, ); }