Skip to main content

Affinity

Struct Affinity 

Source
pub struct Affinity {
Show 18 fields pub id: Uuid, pub session_id: Uuid, pub user_id: Uuid, pub instance_id: Uuid, pub warmth: f64, pub trust: f64, pub intrigue: f64, pub intimacy: f64, pub patience: f64, pub tension: f64, pub warmth_grade: i16, pub patience_grade: i16, pub ghost_streak: i32, pub last_ghost_at: Option<DateTime<Utc>>, pub total_ghosts: i32, pub relationship_label: Option<RelationshipLabel>, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>,
}

Fields§

§id: Uuid§session_id: Uuid§user_id: Uuid§instance_id: Uuid§warmth: f64§trust: f64§intrigue: f64§intimacy: f64§patience: f64§tension: f64§warmth_grade: i16

Judge’s last absolute warmth level (1..=3). Authoritative; warmth is a materialized cache of endpoint_value over it.

§patience_grade: i16

Judge’s last absolute patience level (1..=3).

§ghost_streak: i32§last_ghost_at: Option<DateTime<Utc>>§total_ghosts: i32§relationship_label: Option<RelationshipLabel>§created_at: DateTime<Utc>§updated_at: DateTime<Utc>

Implementations§

Source§

impl Affinity

Source

pub fn apply_deltas(&mut self, d: &AffinityDeltas)

Apply committed deltas directly, clamping each axis to its range. Damping lives in grade_turn’s tier decay, so a committed delta means exactly what it says.

Source

pub fn apply_time_decay(&mut self)

Per-day drift on the line axes only (intrigue cools, tension softens). The old patience up-drift is retired: absence handling for the two endpoints lives in refresh_endpoints’ multiplicative decay, which cools rather than heals — an old friend’s resilience comes from B(bond), not from a drift patch.

Source

pub fn refresh_endpoints(&mut self, t: &AffinityTuning)

Recompute the two derived endpoints from the authoritative facts (judge levels + line scores + time since last update). Runs wherever apply_time_decay runs: the row-locked persist and the in-memory read paths. Line scores no longer contain warmth, so there is no circularity.

Source

pub fn legacy_relationship_label(&self) -> RelationshipLabel

Legacy 5-name relationship label (back-compat), derived purely from the two line scores — replaces the old multi-axis infer_label heuristic. New consumers should read bond_label/chemistry_label. frenemy is retired from emission (kept in the enum for parse compat).

Source§

impl Affinity

Source

pub fn bond_score(&self) -> f64

0..1 friendship composite. Mirrors the bond generated column in migration 0048.

Source

pub fn chemistry_score(&self) -> f64

0..1 romance composite. Mirrors the chemistry generated column in migration 0048.

Source

pub fn bond_label(&self) -> BondLabel

Friendship-line tier label.

Source

pub fn chemistry_label(&self) -> ChemistryLabel

Romance-line tier label.

Source

pub fn intimacy_rung(&self) -> u8

Coarse 1..=3 intimacy rung for the PDE image gate, taken over whichever line is further along. Rung 1 = both lines still tier 1; rung 3 = at or above INTIMACY_RUNG3_LO; rung 2 = everything between. max rather than a sum so a purely romantic track and a purely companionable one can each unlock on their own.

The bottom cut folds TIER1_HI and so cannot drift away from the Acquaintance / Spark labels the rest of the system shows. The top cut is deliberately its own constant, set below the tier-5 apex — see INTIMACY_RUNG3_LO.

Source

pub fn patience_band(&self) -> PatienceBand

Patience band. Reads the raw axis, not a composite — patience is rule-owned and stays outside both folds.

Trait Implementations§

Source§

impl Clone for Affinity

Source§

fn clone(&self) -> Affinity

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 Debug for Affinity

Source§

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

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

impl<'de> Deserialize<'de> for Affinity

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 Affinity

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Affinity

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 StructuralPartialEq for Affinity

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.

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.