pub struct ArtifactCollection {
pub artifacts: Vec<Artifact>,
pub equipped: Option<ArtifactTemplateId>,
pub stones: Vec<ArtifactStone>,
}Expand description
Everything a character owns in the artifact system.
Fields§
§artifacts: Vec<Artifact>§equipped: Option<ArtifactTemplateId>The single worn artifact. None before the vertical opens — that player
plays exactly as before, because every artifact read starts here or at an
empty artifacts.
stones: Vec<ArtifactStone>Owned artifact stones, each carrying its own socket assignment. Not owned by any artifact: this is what makes the stones survive a swap.
Implementations§
Source§impl ArtifactCollection
impl ArtifactCollection
pub fn get(&self, template_id: ArtifactTemplateId) -> Option<&Artifact>
pub fn stone( &self, template_id: ArtifactStoneTemplateId, ) -> Option<&ArtifactStone>
Sourcepub fn socketed(&self, socket: ArtifactSocketSlot) -> Option<&ArtifactStone>
pub fn socketed(&self, socket: ArtifactSocketSlot) -> Option<&ArtifactStone>
The stone sitting in socket, if any.
Sourcepub fn grant_artifact(&mut self, template_id: ArtifactTemplateId)
pub fn grant_artifact(&mut self, template_id: ArtifactTemplateId)
Grants one artifact copy without performing an upgrade.
The first grant creates the level-1 instance. Every duplicate only increments its raw-copy bank, including when the artifact is already at the level cap.
The very first artifact a player owns is also WORN. Exactly one artifact
is worn at a time, so a collection that owns something and wears nothing
is not a state the player can produce — Self::equip has no “take off”
counterpart. Leaving the slot empty read as a bug on the artifact screen,
which then had no worn artifact to open on. This never overrides a
choice: it fires only while Self::equipped is None.
Sourcepub fn upgrade_artifact(
&mut self,
template_id: ArtifactTemplateId,
required: i64,
max_level: i64,
) -> Result<i64, ArtifactError>
pub fn upgrade_artifact( &mut self, template_id: ArtifactTemplateId, required: i64, max_level: i64, ) -> Result<i64, ArtifactError>
Spends exactly one configured rung and raises an artifact one level.
All refusal checks happen before either field changes, so an unknown artifact, a capped artifact or a short copy bank is atomic.
Sourcepub fn equip(
&mut self,
template_id: ArtifactTemplateId,
) -> Result<(), ArtifactError>
pub fn equip( &mut self, template_id: ArtifactTemplateId, ) -> Result<(), ArtifactError>
Wears template_id. Exactly one artifact is worn at a time, so this
replaces whatever was worn before; the previous one keeps paying its
ownership bonus and loses only its World Law.
Socketed stones are deliberately not read here — that is the whole of “stones transfer to the new artifact”.
Sourcepub fn grant_stone(&mut self, template_id: ArtifactStoneTemplateId)
pub fn grant_stone(&mut self, template_id: ArtifactStoneTemplateId)
Banks one raw copy of an artifact stone. The first copy becomes the
instance at level 1; later copies raise ArtifactStone::copies, which
the player spends through an explicit upgrade — same shape as
crate::stones::StoneInventory::grant.
Sourcepub fn insert_stone(
&mut self,
template_id: ArtifactStoneTemplateId,
socket: ArtifactSocketSlot,
expected: ArtifactSocketSlot,
unlocked: bool,
) -> Result<(), ArtifactError>
pub fn insert_stone( &mut self, template_id: ArtifactStoneTemplateId, socket: ArtifactSocketSlot, expected: ArtifactSocketSlot, unlocked: bool, ) -> Result<(), ArtifactError>
Puts the player’s instance of template_id into socket.
expected is the socket the stone’s catalog entry declares — a stone
fits one socket and no other, which is how the two columns are kept
apart. unlocked is the chapter gate; the schedule itself is config, so
this type stays free of chapter arithmetic.
Sourcepub fn set_law_target(
&mut self,
template_id: ArtifactStoneTemplateId,
law: Option<LawTemplateId>,
is_law_socket: bool,
slotted: bool,
) -> Result<(), ArtifactError>
pub fn set_law_target( &mut self, template_id: ArtifactStoneTemplateId, law: Option<LawTemplateId>, is_law_socket: bool, slotted: bool, ) -> Result<(), ArtifactError>
Points a right-column stone at one law, or clears its choice (None).
slotted is “this law is owned and currently sitting in a core slot”,
decided by the caller: the law lives in CoresState, which this type
deliberately knows nothing about. is_law_socket is the stone’s own
column, read from its catalog entry.
The one check that is NOT made here is a Real/Fantasy match against the socket. The three Law sockets are Visible / Hidden / Bridge, and “visible” is a phase, not a side: the same law is the visible one while its side is up and the hidden one while it is down (post-merge plan §8). So every slotted law is a legal target for every Law socket, and which half of the fight the stone speaks in is decided by the flip, not by validation.
Sourcepub fn forget_law_target(&mut self, law: LawTemplateId) -> bool
pub fn forget_law_target(&mut self, law: LawTemplateId) -> bool
Drops every stone’s choice of law. Called when the law leaves its slot,
so no stone is ever left pointing at a law that is not on a core.
Returns whether anything changed, so the caller can skip a write.
Sourcepub fn remove_stone(
&mut self,
template_id: ArtifactStoneTemplateId,
) -> Result<ArtifactSocketSlot, ArtifactError>
pub fn remove_stone( &mut self, template_id: ArtifactStoneTemplateId, ) -> Result<ArtifactSocketSlot, ArtifactError>
Clears a stone’s socket. The stone stays in the collection with its level and copies intact.
Sourcepub fn upgrade_stone(
&mut self,
template_id: ArtifactStoneTemplateId,
required: i64,
max_level: i64,
) -> Result<i64, ArtifactError>
pub fn upgrade_stone( &mut self, template_id: ArtifactStoneTemplateId, required: i64, max_level: i64, ) -> Result<i64, ArtifactError>
Spends required banked copies to take an artifact stone up one level.
An upgrade only scales the rule’s magnitude — the rule itself came whole
with the first copy (design §3), so nothing here touches the socket, the
template or anything a rule reads besides level.
Trait Implementations§
Source§impl Clone for ArtifactCollection
impl Clone for ArtifactCollection
Source§fn clone(&self) -> ArtifactCollection
fn clone(&self) -> ArtifactCollection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ArtifactCollection
impl Debug for ArtifactCollection
Source§impl Default for ArtifactCollection
impl Default for ArtifactCollection
Source§fn default() -> ArtifactCollection
fn default() -> ArtifactCollection
Source§impl<'de> Deserialize<'de> for ArtifactCollection
impl<'de> Deserialize<'de> for ArtifactCollection
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 From<ArtifactCollection> for JsValuewhere
ArtifactCollection: Serialize,
impl From<ArtifactCollection> for JsValuewhere
ArtifactCollection: Serialize,
Source§fn from(value: ArtifactCollection) -> Self
fn from(value: ArtifactCollection) -> Self
Source§impl FromWasmAbi for ArtifactCollectionwhere
Self: DeserializeOwned,
impl FromWasmAbi for ArtifactCollectionwhere
Self: DeserializeOwned,
Source§impl IntoWasmAbi for ArtifactCollectionwhere
ArtifactCollection: Serialize,
impl IntoWasmAbi for ArtifactCollectionwhere
ArtifactCollection: Serialize,
Source§impl JsonSchema for ArtifactCollection
impl JsonSchema for ArtifactCollection
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 ArtifactCollectionwhere
Self: DeserializeOwned,
impl OptionFromWasmAbi for ArtifactCollectionwhere
Self: DeserializeOwned,
Source§impl OptionIntoWasmAbi for ArtifactCollectionwhere
ArtifactCollection: Serialize,
impl OptionIntoWasmAbi for ArtifactCollectionwhere
ArtifactCollection: Serialize,
Source§impl PartialEq for ArtifactCollection
impl PartialEq for ArtifactCollection
Source§impl RefFromWasmAbi for ArtifactCollectionwhere
Self: DeserializeOwned,
impl RefFromWasmAbi for ArtifactCollectionwhere
Self: DeserializeOwned,
Source§type Abi = <JsType as RefFromWasmAbi>::Abi
type Abi = <JsType as RefFromWasmAbi>::Abi
Self are recovered from.Source§type Anchor = SelfOwner<ArtifactCollection>
type Anchor = SelfOwner<ArtifactCollection>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl Serialize for ArtifactCollection
impl Serialize for ArtifactCollection
Source§impl Tsify for ArtifactCollection
impl Tsify for ArtifactCollection
const DECL: &'static str = "/**\n * Everything a character owns in the artifact system.\n */\nexport interface ArtifactCollection {\n artifacts: Artifact[];\n /**\n * The single worn artifact. `None` before the vertical opens \u{2014} that player\n * plays exactly as before, because every artifact read starts here or at an\n * empty `artifacts`.\n */\n equipped: ArtifactTemplateId | null;\n /**\n * Owned artifact stones, each carrying its own socket assignment. Not owned\n * by any artifact: this is what makes the stones survive a swap.\n */\n stones: ArtifactStone[];\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 ArtifactCollectionwhere
Self: DeserializeOwned,
impl VectorFromWasmAbi for ArtifactCollectionwhere
Self: DeserializeOwned,
type Abi = <JsType as VectorFromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Self]>
Source§impl VectorIntoWasmAbi for ArtifactCollectionwhere
ArtifactCollection: Serialize,
impl VectorIntoWasmAbi for ArtifactCollectionwhere
ArtifactCollection: Serialize,
type Abi = <JsType as VectorIntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[Self]>) -> Self::Abi
Source§impl WasmDescribeVector for ArtifactCollection
impl WasmDescribeVector for ArtifactCollection
impl Eq for ArtifactCollection
impl StructuralPartialEq for ArtifactCollection
Auto Trait Implementations§
impl Freeze for ArtifactCollection
impl RefUnwindSafe for ArtifactCollection
impl Send for ArtifactCollection
impl Sync for ArtifactCollection
impl Unpin for ArtifactCollection
impl UnwindSafe for ArtifactCollection
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.