Skip to main content

CharacterSheet

Struct CharacterSheet 

Source
pub struct CharacterSheet {
Show 17 fields pub name: String, pub player_name: Option<String>, pub race: String, pub background: String, pub alignment: String, pub classes: Vec<ClassLevel>, pub experience_points: u32, pub ability_scores: AbilityScores, pub hit_points: HitPoints, pub armor_class: u8, pub speed: u16, pub saving_throw_proficiencies: Vec<Ability>, pub skill_proficiencies: Vec<Skill>, pub inventory: Vec<Item>, pub spellcasting: Spellcasting, pub resources: Vec<Resource>, pub notes: String,
}
Expand description

The editable contents of a character sheet. This is the request body for both creating and replacing a character.

Fields§

§name: String§player_name: Option<String>§race: String§background: String§alignment: String§classes: Vec<ClassLevel>§experience_points: u32§ability_scores: AbilityScores§hit_points: HitPoints§armor_class: u8§speed: u16§saving_throw_proficiencies: Vec<Ability>§skill_proficiencies: Vec<Skill>§inventory: Vec<Item>§spellcasting: Spellcasting§resources: Vec<Resource>

Limited-use class features and abilities (Action Surge, Rage, Ki…).

§notes: String

Implementations§

Source§

impl CharacterSheet

Source

pub fn apply(&mut self, action: &CharacterAction) -> Result<(), ActionError>

Applies an action. On error the sheet is left unchanged.

Source

pub fn rest(&mut self, kind: RestKind)

Takes a rest: restores what recovers on it (and, on a long rest, all hit points).

Source§

impl CharacterSheet

Source

pub const MAX_LEVEL: u8 = 20

The highest total character level.

Source

pub fn total_level(&self) -> u8

Sum of all class levels (at least 1 for display purposes when empty).

Source

pub fn proficiency_bonus(&self) -> i8

The proficiency bonus for the character’s total level.

Source

pub fn saving_throw(&self, ability: Ability) -> i8

The bonus to a saving throw: the ability’s modifier, plus proficiency if proficient.

Source

pub fn skill_bonus(&self, skill: Skill) -> i8

The bonus to a skill check: its ability’s modifier, plus proficiency if proficient.

Source

pub fn spell_save_dc(&self, ability: Ability) -> i8

The spell save DC when casting with ability: 8 + proficiency + modifier.

Source

pub fn spell_attack_bonus(&self, ability: Ability) -> i8

The spell attack bonus when casting with ability: proficiency + modifier.

Source

pub fn validate(&self) -> Result<(), ValidationError>

Validates rules that serde can’t express. Shared by server and clients so frontends can give immediate feedback.

Source§

impl CharacterSheet

Source

pub fn derive_slots(&mut self, edition: Edition)

Sets the spell slots (and Pact Magic) the classes give, under the campaign’s edition. Slots already spent stay spent, up to the new number.

Trait Implementations§

Source§

impl Clone for CharacterSheet

Source§

fn clone(&self) -> CharacterSheet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComposeSchema for CharacterSheet

Source§

fn compose(generics: Vec<RefOr<Schema>>) -> RefOr<Schema>

Source§

impl Debug for CharacterSheet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CharacterSheet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CharacterSheet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CharacterSheet

Source§

fn eq(&self, other: &CharacterSheet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CharacterSheet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToSchema for CharacterSheet

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference [utoipa::openapi::schema::Schema]s for this type. Read more
Source§

impl StructuralPartialEq for CharacterSheet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PartialSchema for T
where T: ComposeSchema + ?Sized,

§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,