veloren_common/
character.rs

1//! Structs representing a playable Character
2
3use crate::{comp, comp::inventory::Inventory};
4use serde::{Deserialize, Serialize};
5
6/// The limit on how many characters that a player can have
7pub 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
14/// The minimum character data we need to create a new character on the server.
15#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
16pub struct Character {
17    pub id: Option<CharacterId>,
18    pub alias: String,
19}
20
21/// Data needed to render a single character item in the character list
22/// presented during character selection.
23#[derive(Clone, Debug, Serialize, Deserialize)]
24pub struct CharacterItem {
25    pub character: Character,
26    pub body: comp::Body,
27    pub hardcore: bool,
28    pub inventory: Inventory,
29    // this string changes between database representation and human readable name in server.tick
30    pub location: Option<String>,
31}