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  #[builder(start_fn)]
19  pub world: WorldId,
20}
21
22#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
23#[serde(rename_all = "camelCase")]
24#[cfg_attr(feature = "typescript", derive(TS))]
25#[cfg_attr(feature = "typescript", ts(export))]
26pub struct GetPlayerCoordsRequest {
27  #[builder(start_fn)]
28  pub world: WorldId,
29  #[builder(into)]
30  pub id: PlayerId,
31}
32
33#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
34#[serde(rename_all = "camelCase")]
35#[cfg_attr(feature = "typescript", derive(TS))]
36#[cfg_attr(feature = "typescript", ts(export))]
37pub struct GetPlayerIdsRequest {
38  #[builder(start_fn, into)]
39  pub world: WorldId,
40}
41
42#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
43#[serde(rename_all = "camelCase")]
44#[cfg_attr(feature = "typescript", derive(TS))]
45#[cfg_attr(feature = "typescript", ts(export))]
46pub struct GetPlayerMaintenanceRequest {
47  #[builder(start_fn, into)]
48  pub world: WorldId,
49}
50
51#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
52#[serde(rename_all = "camelCase")]
53#[cfg_attr(feature = "typescript", derive(TS))]
54#[cfg_attr(feature = "typescript", ts(export))]
55pub struct GetPlayerMilitaryRequest {
56  #[builder(start_fn, into)]
57  pub world: WorldId,
58}
59
60#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
61#[serde(rename_all = "camelCase")]
62#[cfg_attr(feature = "typescript", derive(TS))]
63#[cfg_attr(feature = "typescript", ts(export))]
64pub struct GetPlayerReportsRequest {
65  #[builder(start_fn, into)]
66  pub world: WorldId,
67}
68
69#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
70#[serde(rename_all = "camelCase")]
71#[cfg_attr(feature = "typescript", derive(TS))]
72#[cfg_attr(feature = "typescript", ts(export))]
73pub struct GetPlayerStatusRequest {
74  #[builder(start_fn, into)]
75  pub world: WorldId,
76  #[builder(into)]
77  pub id: PlayerId,
78}
79
80#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
81#[serde(rename_all = "camelCase")]
82#[cfg_attr(feature = "typescript", derive(TS))]
83#[cfg_attr(feature = "typescript", ts(export))]
84pub struct GetPlayerStorageCapacityRequest {
85  #[builder(start_fn, into)]
86  pub world: WorldId,
87}
88
89#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
90#[serde(rename_all = "camelCase")]
91#[cfg_attr(feature = "typescript", derive(TS))]
92#[cfg_attr(feature = "typescript", ts(export))]
93pub struct GetPlayerWorldsRequest {
94  #[builder(into)]
95  pub id: PlayerId,
96}
97
98#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
99#[serde(rename_all = "camelCase")]
100#[cfg_attr(feature = "typescript", derive(TS))]
101#[cfg_attr(feature = "typescript", ts(export))]
102pub struct GetPublicPlayerRequest {
103  #[builder(start_fn, into)]
104  pub world: WorldId,
105  #[builder(into)]
106  pub id: PlayerId,
107}
108
109#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
110#[serde(rename_all = "camelCase")]
111#[cfg_attr(feature = "typescript", derive(TS))]
112#[cfg_attr(feature = "typescript", ts(export))]
113pub struct GetPublicPlayersRequest {
114  #[builder(start_fn, into)]
115  pub world: WorldId,
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 PlayerExistsRequest {
123  #[builder(start_fn, into)]
124  pub world: WorldId,
125  #[builder(into)]
126  pub id: PlayerId,
127}
128
129#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
130#[serde(rename_all = "camelCase")]
131#[cfg_attr(feature = "typescript", derive(TS))]
132#[cfg_attr(feature = "typescript", ts(export))]
133pub struct SetPlayerStatusRequest {
134  #[builder(start_fn, into)]
135  pub world: WorldId,
136  pub status: PlayerStatus,
137}
138
139#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
140#[serde(rename_all = "camelCase")]
141#[cfg_attr(feature = "typescript", derive(TS))]
142#[cfg_attr(feature = "typescript", ts(export, optional_fields = nullable))]
143pub struct SpawnPlayerRequest {
144  #[builder(start_fn, into)]
145  pub world: WorldId,
146  #[serde(default)]
147  #[builder(into)]
148  pub world_password: Option<Password>,
149  pub options: PlayerOptions,
150}