Skip to main content

nil_payload/request/
player.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use bon::Builder;
5use nil_core::player::{PlayerId, PlayerOptions, PlayerStatus};
6use nil_core::world::config::WorldId;
7use nil_crypto::password::Password;
8use serde::{Deserialize, Serialize};
9
10#[cfg(feature = "typescript")]
11use ts_rs::TS;
12
13#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
14#[serde(rename_all = "camelCase")]
15#[cfg_attr(feature = "typescript", derive(TS))]
16#[cfg_attr(feature = "typescript", ts(export))]
17pub struct GetPlayerRequest {
18  pub world: WorldId,
19}
20
21#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
22#[serde(rename_all = "camelCase")]
23#[cfg_attr(feature = "typescript", derive(TS))]
24#[cfg_attr(feature = "typescript", ts(export))]
25pub struct GetPlayerCoordsRequest {
26  pub world: WorldId,
27  #[builder(into)]
28  pub id: PlayerId,
29}
30
31#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
32#[serde(rename_all = "camelCase")]
33#[cfg_attr(feature = "typescript", derive(TS))]
34#[cfg_attr(feature = "typescript", ts(export))]
35pub struct GetPlayerIdsRequest {
36  pub world: WorldId,
37}
38
39#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
40#[serde(rename_all = "camelCase")]
41#[cfg_attr(feature = "typescript", derive(TS))]
42#[cfg_attr(feature = "typescript", ts(export))]
43pub struct GetPlayerMaintenanceRequest {
44  pub world: WorldId,
45}
46
47#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
48#[serde(rename_all = "camelCase")]
49#[cfg_attr(feature = "typescript", derive(TS))]
50#[cfg_attr(feature = "typescript", ts(export))]
51pub struct GetPlayerMilitaryRequest {
52  pub world: WorldId,
53}
54
55#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
56#[serde(rename_all = "camelCase")]
57#[cfg_attr(feature = "typescript", derive(TS))]
58#[cfg_attr(feature = "typescript", ts(export))]
59pub struct GetPlayerReportsRequest {
60  pub world: WorldId,
61}
62
63#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
64#[serde(rename_all = "camelCase")]
65#[cfg_attr(feature = "typescript", derive(TS))]
66#[cfg_attr(feature = "typescript", ts(export))]
67pub struct GetPlayerStatusRequest {
68  pub world: WorldId,
69  #[builder(into)]
70  pub id: PlayerId,
71}
72
73#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
74#[serde(rename_all = "camelCase")]
75#[cfg_attr(feature = "typescript", derive(TS))]
76#[cfg_attr(feature = "typescript", ts(export))]
77pub struct GetPlayerStorageCapacityRequest {
78  pub world: WorldId,
79}
80
81#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
82#[serde(rename_all = "camelCase")]
83#[cfg_attr(feature = "typescript", derive(TS))]
84#[cfg_attr(feature = "typescript", ts(export))]
85pub struct GetPlayerWorldsRequest {
86  #[builder(into)]
87  pub id: PlayerId,
88}
89
90#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
91#[serde(rename_all = "camelCase")]
92#[cfg_attr(feature = "typescript", derive(TS))]
93#[cfg_attr(feature = "typescript", ts(export))]
94pub struct GetPublicPlayerRequest {
95  pub world: WorldId,
96  #[builder(into)]
97  pub id: PlayerId,
98}
99
100#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
101#[serde(rename_all = "camelCase")]
102#[cfg_attr(feature = "typescript", derive(TS))]
103#[cfg_attr(feature = "typescript", ts(export))]
104pub struct GetPublicPlayersRequest {
105  pub world: WorldId,
106}
107
108#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
109#[serde(rename_all = "camelCase")]
110#[cfg_attr(feature = "typescript", derive(TS))]
111#[cfg_attr(feature = "typescript", ts(export))]
112pub struct PlayerExistsRequest {
113  pub world: WorldId,
114  #[builder(into)]
115  pub id: PlayerId,
116}
117
118#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
119#[serde(rename_all = "camelCase")]
120#[cfg_attr(feature = "typescript", derive(TS))]
121#[cfg_attr(feature = "typescript", ts(export))]
122pub struct SetPlayerStatusRequest {
123  pub world: WorldId,
124  pub status: PlayerStatus,
125}
126
127#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
128#[serde(rename_all = "camelCase")]
129#[cfg_attr(feature = "typescript", derive(TS))]
130#[cfg_attr(feature = "typescript", ts(export, optional_fields = nullable))]
131pub struct SpawnPlayerRequest {
132  pub world: WorldId,
133  #[serde(default)]
134  #[builder(into)]
135  pub world_password: Option<Password>,
136  pub options: PlayerOptions,
137}