1use crate::bundles::BundleStepGeneric;
2use crate::characters::Character;
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, CustomType, 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)]
43pub enum StarsChange {
44 LimitExceeded,
45 StarsOnly {
46 final_stars_to_add: i64,
47 final_stars_count: i64,
48 },
49 StarsWithReward {
50 final_stars_to_add: i64,
51 final_stars_count: i64,
52 bundle_step_generic: BundleStepGeneric,
53 bundle_steps_count: i64,
54 new_daily_claims_count: i64,
55 },
56}
57
58#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, CustomType, JsonSchema, Tsify)]
59pub struct PVPState {
60 pub opponent_state: Box<OpponentState>,
61 pub vassal: Option<Vassal>,
62 pub rating_change: Option<RatingChange>,
63 pub stars_change: Option<StarsChange>,
64}
65
66#[derive(
67 Clone, Debug, Serialize, Deserialize, PartialEq, Eq, CustomType, JsonSchema, Tsify, Default,
68)]
69pub struct MatchmakingOpponent {
70 pub opponent: OpponentPreview,
71 pub win_rating_increase: i64,
72 pub lose_rating_decrease: i64,
73}
74
75#[derive(
76 Clone, Debug, Serialize, Deserialize, PartialEq, Eq, CustomType, JsonSchema, Tsify, Default,
77)]
78pub struct MatchmakingData {
79 pub opponents: Vec<MatchmakingOpponent>,
80 pub is_free_refresh_available: bool,
81}