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