essences/
pvp.rs

1use crate::characters::Character;
2use crate::flip::FlipState;
3use crate::opponents::{OpponentPreview, OpponentState};
4use crate::users::User;
5use crate::vassals::Vassal;
6
7use crate::prelude::*;
8
9#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, JsonSchema, Tsify)]
10#[tsify(into_wasm_abi, from_wasm_abi)]
11pub struct Opponent {
12    pub user: User,
13    pub character: Character,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, JsonSchema, Tsify)]
17#[tsify(into_wasm_abi, from_wasm_abi)]
18pub struct VassalPvpOpponent {
19    pub opponent: Opponent,
20    pub suzerain: Option<Opponent>,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, JsonSchema, Tsify)]
24#[tsify(into_wasm_abi, from_wasm_abi)]
25pub struct VassalPvpPlayersFindRequest {
26    pub character_id: uuid::Uuid,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, JsonSchema, Tsify)]
30#[tsify(into_wasm_abi, from_wasm_abi)]
31pub enum VassalPvpPlayersFindResponse {
32    Ok { opponents: Vec<VassalPvpOpponent> },
33    Error { code: String, message: String },
34}
35
36#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, Tsify)]
37pub struct RatingChange {
38    pub winner_rating_increase: i64,
39    pub loser_rating_decrease: i64,
40}
41
42#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, Tsify)]
43pub struct PVPState {
44    pub opponent_state: Box<OpponentState>,
45    /// Durable side snapshot used to initialize the opponent's fight-local
46    /// flip gauge. The viewer's simulation never persists changes to it.
47    #[serde(default)]
48    pub opponent_flip_state: FlipState,
49    pub vassal: Option<Vassal>,
50    pub rating_change: Option<RatingChange>,
51}
52
53#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, Tsify, Default)]
54pub struct MatchmakingOpponent {
55    pub opponent: OpponentPreview,
56    pub win_rating_increase: i64,
57    pub lose_rating_decrease: i64,
58}
59
60#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, Tsify, Default)]
61pub struct MatchmakingData {
62    pub opponents: Vec<MatchmakingOpponent>,
63    pub is_free_refresh_available: bool,
64}