pub struct Stone {
pub template_id: StoneTemplateId,
pub tier: StoneTier,
pub level: i64,
pub copies: i64,
pub socket: Option<StoneSocketKey>,
}Expand description
The one instance a player owns of a catalog entry, plus its stock of raw copies.
template_id is the identity: at most one Stone per template per
collection, so there is no separate instance id. The database key is
(character_id, template_id) for the same reason.
level is the upgrade level and copies is the currency that buys it. The
first copy becomes the instance at level 1 with zero copies banked; every
later copy increments copies. The ladder in
configs::stones::StonesSettings::upgrade_ladder says what each level costs.
The first copy already carries the full mechanic — an upgrade only scales the
number it applies.
Fields§
§template_id: StoneTemplateIdThe catalog entry this is the player’s instance of, and its identity.
tier: StoneTier§level: i64§copies: i64Raw copies banked against this stone, spendable on the next level. Never negative: a refused upgrade spends nothing.
socket: Option<StoneSocketKey>Some while socketed. The stone stays in its collection either way —
this is the whole of “inserted” and “removed”. One instance means one
socket: the same template cannot sit in two slots.
Implementations§
Source§impl Stone
impl Stone
Sourcepub fn new(template_id: StoneTemplateId, tier: StoneTier) -> Self
pub fn new(template_id: StoneTemplateId, tier: StoneTier) -> Self
The player’s first copy of template_id: level 1, nothing banked.
pub const fn is_socketed(&self) -> bool
Sourcepub const fn quality(&self) -> (StoneTier, i64)
pub const fn quality(&self) -> (StoneTier, i64)
Ranking key for “the best stone I own”: tier first, then level.
The two axes are not comparable on their own — a level-3 Common against a level-1 Legendary has no arithmetic answer — so the design picks one. Tier wins because it decides the stone’s gauge contribution and the shape of what it does; level only scales a magnitude inside that shape.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Stone
impl<'de> Deserialize<'de> for Stone
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromWasmAbi for Stonewhere
Self: DeserializeOwned,
impl FromWasmAbi for Stonewhere
Self: DeserializeOwned,
Source§impl IntoWasmAbi for Stone
impl IntoWasmAbi for Stone
Source§impl JsonSchema for Stone
impl JsonSchema for Stone
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl OptionFromWasmAbi for Stonewhere
Self: DeserializeOwned,
impl OptionFromWasmAbi for Stonewhere
Self: DeserializeOwned,
Source§impl OptionIntoWasmAbi for Stone
impl OptionIntoWasmAbi for Stone
Source§impl RefFromWasmAbi for Stonewhere
Self: DeserializeOwned,
impl RefFromWasmAbi for Stonewhere
Self: DeserializeOwned,
Source§type Abi = <JsType as RefFromWasmAbi>::Abi
type Abi = <JsType as RefFromWasmAbi>::Abi
Self are recovered from.Source§impl Tsify for Stone
impl Tsify for Stone
const DECL: &'static str = "/**\n * The one instance a player owns of a catalog entry, plus its stock of raw\n * copies.\n *\n * `template_id` is the identity: at most one `Stone` per template per\n * collection, so there is no separate instance id. The database key is\n * `(character_id, template_id)` for the same reason.\n *\n * `level` is the upgrade level and `copies` is the currency that buys it. The\n * first copy becomes the instance at level 1 with zero copies banked; every\n * later copy increments `copies`. The ladder in\n * `configs::stones::StonesSettings::upgrade_ladder` says what each level costs.\n * The first copy already carries the full mechanic \u{2014} an upgrade only scales the\n * number it applies.\n */\nexport interface Stone {\n /**\n * The catalog entry this is the player\\\'s instance of, and its identity.\n */\n template_id: StoneTemplateId;\n tier: StoneTier;\n level: number;\n /**\n * Raw copies banked against this stone, spendable on the next level. Never\n * negative: a refused upgrade spends nothing.\n */\n copies: number;\n /**\n * `Some` while socketed. The stone stays in its collection either way \u{2014}\n * this is the whole of \\\"inserted\\\" and \\\"removed\\\". One instance means one\n * socket: the same template cannot sit in two slots.\n */\n socket: StoneSocketKey | null;\n}"
const SERIALIZATION_CONFIG: SerializationConfig
type JsType = JsType
fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
Source§impl VectorFromWasmAbi for Stonewhere
Self: DeserializeOwned,
impl VectorFromWasmAbi for Stonewhere
Self: DeserializeOwned,
type Abi = <JsType as VectorFromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Self]>
Source§impl VectorIntoWasmAbi for Stone
impl VectorIntoWasmAbi for Stone
type Abi = <JsType as VectorIntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[Self]>) -> Self::Abi
impl Eq for Stone
impl StructuralPartialEq for Stone
Auto Trait Implementations§
impl Freeze for Stone
impl RefUnwindSafe for Stone
impl Send for Stone
impl Sync for Stone
impl Unpin for Stone
impl UnwindSafe for Stone
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.