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