veloren/common/src/character.rs

31 lines
1.0 KiB
Rust
Raw Normal View History

//! Structs representing a playable Character
use crate::{comp, comp::inventory::Inventory};
use serde::{Deserialize, Serialize};
/// The limit on how many characters that a player can have
pub const MAX_CHARACTERS_PER_PLAYER: usize = 8;
2023-04-10 16:59:43 +00:00
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
2023-04-06 19:07:50 +00:00
#[serde(transparent)]
2023-04-06 11:29:20 +00:00
pub struct CharacterId(pub i64);
2021-02-16 21:29:45 +00:00
pub const MAX_NAME_LENGTH: usize = 20;
/// The minimum character data we need to create a new character on the server.
2022-09-08 19:51:02 +00:00
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Character {
pub id: Option<CharacterId>,
pub alias: String,
}
/// Data needed to render a single character item in the character list
/// presented during character selection.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CharacterItem {
pub character: Character,
pub body: comp::Body,
pub inventory: Inventory,
// this string changes between database representation and human readable name in server.tick
pub location: Option<String>,
}