Skip to main content

nil_payload/response/
player.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use derive_more::{Deref, DerefMut, Display, From, Into};
5use nil_core::continent::coord::Coord;
6use nil_core::infrastructure::storage::OverallStorageCapacity;
7use nil_core::military::Military;
8use nil_core::player::{Player, PlayerId, PlayerStatus, PublicPlayer};
9use nil_core::resources::maintenance::Maintenance;
10use nil_core::world::config::WorldId;
11use serde::{Deserialize, Serialize};
12
13#[cfg(feature = "axum")]
14use nil_payload_macros::IntoJsonResponse;
15
16#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
17#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
18#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
19#[cfg_attr(feature = "typescript", ts(export))]
20pub struct GetPlayerCoordsResponse(pub Vec<Coord>);
21
22#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
23#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
24#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
25#[cfg_attr(feature = "typescript", ts(export))]
26pub struct GetPlayerIdsResponse(pub Vec<PlayerId>);
27
28#[derive(Clone, Copy, Debug, Deref, DerefMut, Display, From, Into, Deserialize, Serialize)]
29#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
30#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
31#[cfg_attr(feature = "typescript", ts(export))]
32pub struct GetPlayerMaintenanceResponse(pub Maintenance);
33
34#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
35#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
36#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
37#[cfg_attr(feature = "typescript", ts(export))]
38pub struct GetPlayerMilitaryResponse(pub Military);
39
40#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
41#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
42#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
43#[cfg_attr(feature = "typescript", ts(export))]
44pub struct GetPlayerResponse(pub Player);
45
46#[derive(Clone, Copy, Debug, Deref, DerefMut, Display, From, Into, Deserialize, Serialize)]
47#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
48#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
49#[cfg_attr(feature = "typescript", ts(export))]
50pub struct GetPlayerStatusResponse(pub PlayerStatus);
51
52#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
53#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
54#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
55#[cfg_attr(feature = "typescript", ts(export))]
56pub struct GetPlayerStorageCapacityResponse(pub OverallStorageCapacity);
57
58#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
59#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
60#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
61#[cfg_attr(feature = "typescript", ts(export))]
62pub struct GetPlayerWorldsResponse(pub Vec<WorldId>);
63
64#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
65#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
66#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
67#[cfg_attr(feature = "typescript", ts(export))]
68pub struct GetPublicPlayerResponse(pub PublicPlayer);
69
70#[derive(Clone, Debug, Deref, DerefMut, From, Into, Deserialize, Serialize)]
71#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
72#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
73#[cfg_attr(feature = "typescript", ts(export))]
74pub struct GetPublicPlayersResponse(pub Vec<PublicPlayer>);
75
76#[derive(Clone, Copy, Debug, Deref, DerefMut, Display, From, Into, Deserialize, Serialize)]
77#[cfg_attr(feature = "axum", derive(IntoJsonResponse))]
78#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
79#[cfg_attr(feature = "typescript", ts(export))]
80pub struct PlayerExistsResponse(pub bool);