veloren_common/
character.rs1use crate::{comp, comp::inventory::Inventory};
4use serde::{Deserialize, Serialize};
5
6pub const MAX_CHARACTERS_PER_PLAYER: usize = 8;
8#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
9#[serde(transparent)]
10pub struct CharacterId(pub i64);
11
12pub const MAX_NAME_LENGTH: usize = 20;
13
14pub fn verify_character_name(name: &str) -> bool {
15 name.chars().take(MAX_NAME_LENGTH + 1).count() <= MAX_NAME_LENGTH
17}
18
19#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
21pub struct Character {
22 pub id: Option<CharacterId>,
23 pub alias: String,
24}
25
26#[derive(Clone, Debug, Serialize, Deserialize)]
29pub struct CharacterItem<Location> {
30 pub character: Character,
31 pub body: comp::Body,
32 pub hardcore: bool,
33 pub inventory: Inventory,
34 pub location: Option<Location>,
35}