attribute component - functionality NYI

This commit is contained in:
Llywelwyn 2023-07-21 21:43:24 +01:00
parent c39f2cb013
commit e2afd47830
4 changed files with 33 additions and 4 deletions

View file

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

View file

@ -513,6 +513,7 @@ fn main() -> rltk::BError {
gs.ecs.register::<Name>();
gs.ecs.register::<BlocksTile>();
gs.ecs.register::<CombatStats>();
gs.ecs.register::<Attributes>();
gs.ecs.register::<HungerClock>();
gs.ecs.register::<WantsToMelee>();
gs.ecs.register::<SufferDamage>();

View file

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

View file

@ -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::<SimpleMarker<SerializeMe>>()
.build()
}