From e2afd478309fcbe2f7889776f2a2861e693be6a8 Mon Sep 17 00:00:00 2001 From: Llywelwyn Date: Fri, 21 Jul 2023 21:43:24 +0100 Subject: [PATCH] attribute component - functionality NYI --- src/components.rs | 17 +++++++++++++++++ src/main.rs | 1 + src/saveload_system.rs | 2 ++ src/spawner.rs | 17 +++++++++++++---- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/components.rs b/src/components.rs index 898785f..6acf7a4 100644 --- a/src/components.rs +++ b/src/components.rs @@ -88,6 +88,23 @@ pub struct CombatStats { pub power: i32, } +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct Attribute { + pub base: i32, + pub modifiers: i32, + pub bonus: i32, +} + +#[derive(Component, Debug, Serialize, Deserialize, Clone)] +pub struct Attributes { + pub strength: Attribute, + pub dexterity: Attribute, + pub constitution: Attribute, + pub intelligence: Attribute, + pub wisdom: Attribute, + pub charisma: Attribute, +} + #[derive(Component, Debug, ConvertSaveload, Clone)] pub struct WantsToMelee { pub target: Entity, diff --git a/src/main.rs b/src/main.rs index 21af86c..22fd2f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -513,6 +513,7 @@ fn main() -> rltk::BError { gs.ecs.register::(); gs.ecs.register::(); gs.ecs.register::(); + gs.ecs.register::(); gs.ecs.register::(); gs.ecs.register::(); gs.ecs.register::(); diff --git a/src/saveload_system.rs b/src/saveload_system.rs index ac2a1d7..29f5278 100644 --- a/src/saveload_system.rs +++ b/src/saveload_system.rs @@ -48,6 +48,7 @@ pub fn save_game(ecs: &mut World) { serializer, data, AOE, + Attributes, BlocksTile, CombatStats, Confusion, @@ -140,6 +141,7 @@ pub fn load_game(ecs: &mut World) { de, d, AOE, + Attributes, BlocksTile, CombatStats, Confusion, diff --git a/src/spawner.rs b/src/spawner.rs index ab75ef9..f7ea8a0 100644 --- a/src/spawner.rs +++ b/src/spawner.rs @@ -1,8 +1,9 @@ use super::{ - random_table::RandomTable, BlocksTile, CombatStats, Confusion, Consumable, Cursed, DefenceBonus, Destructible, - EntryTrigger, EquipmentSlot, Equippable, Hidden, HungerClock, HungerState, InflictsDamage, Item, MagicMapper, Map, - MeleePowerBonus, Mind, Monster, Name, Player, Position, ProvidesHealing, ProvidesNutrition, Ranged, Rect, - Renderable, SerializeMe, SingleActivation, TileType, Viewshed, Wand, AOE, MAPWIDTH, + random_table::RandomTable, Attribute, Attributes, BlocksTile, CombatStats, Confusion, Consumable, Cursed, + DefenceBonus, Destructible, EntryTrigger, EquipmentSlot, Equippable, Hidden, HungerClock, HungerState, + InflictsDamage, Item, MagicMapper, Map, MeleePowerBonus, Mind, Monster, Name, Player, Position, ProvidesHealing, + ProvidesNutrition, Ranged, Rect, Renderable, SerializeMe, SingleActivation, TileType, Viewshed, Wand, AOE, + MAPWIDTH, }; use rltk::{console, RandomNumberGenerator, RGB}; use specs::prelude::*; @@ -25,6 +26,14 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { .with(Name { name: "wanderer".to_string() }) .with(CombatStats { max_hp: 8, hp: 8, defence: 0, power: 4 }) .with(HungerClock { state: HungerState::Satiated, duration: 50 }) + .with(Attributes { + strength: Attribute { base: 10, modifiers: 0, bonus: 0 }, + dexterity: Attribute { base: 10, modifiers: 0, bonus: 0 }, + constitution: Attribute { base: 10, modifiers: 0, bonus: 0 }, + intelligence: Attribute { base: 10, modifiers: 0, bonus: 0 }, + wisdom: Attribute { base: 10, modifiers: 0, bonus: 0 }, + charisma: Attribute { base: 10, modifiers: 0, bonus: 0 }, + }) .marked::>() .build() }