Skip to main content

vitium_api/game/components/
char.rs

1use super::Pos;
2use crate::game::{level::Level, Attr, Mart, Prof, Race, Skill, Spell};
3use bevy_ecs::component::Component;
4use fe3o4::Id;
5use serde::{Deserialize, Serialize};
6use std::collections::{HashMap, HashSet};
7
8/// Defines a character.
9#[derive(Clone, Serialize, Deserialize, Component)]
10#[cfg_attr(target_family = "wasm", derive(tsify_next::Tsify))]
11#[cfg_attr(
12    target_family = "wasm",
13    tsify(into_wasm_abi, from_wasm_abi, large_number_types_as_bigints)
14)]
15pub struct Char {
16    /// Displayed name of the character.
17    pub name: String,
18    /// Additional description for the character.
19    pub descr: String,
20    /// Current position.
21    pub pos: Pos,
22    /// Race.
23    pub race: Id<Race>,
24    /// Profession.
25    pub prof: Id<Prof>,
26    /// Current attributes.
27    pub attr: HashMap<Id<Attr>, Level>,
28    /// Current skill levels.
29    pub skill: HashMap<Id<Skill>, Level>,
30    /// Current martial art levels.
31    pub mart: HashMap<Id<Mart>, Level>,
32    /// Current spell levels.
33    pub spell: HashMap<Id<Spell>, Level>,
34    // pub invt: Vec<bevy_ecs>,
35    // pub equip: Vec<Ox<Armor>>,
36    /// Current money.
37    pub money: i32,
38}
39
40/// Denotes a player character.
41#[derive(Clone, Serialize, Deserialize, Component)]
42#[cfg_attr(target_family = "wasm", derive(tsify_next::Tsify))]
43#[cfg_attr(
44    target_family = "wasm",
45    tsify(into_wasm_abi, from_wasm_abi, large_number_types_as_bigints)
46)]
47pub struct PlayerChar {
48    /// User the character belongs to.
49    pub user: String,
50    /// Background story for the character.
51    pub bg_story: String,
52    /// Mods to use with.
53    pub mods: HashSet<String>,
54}