Skip to main content

nil_payload/request/
city.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use bon::Builder;
5use nil_core::city::CitySearch;
6use nil_core::continent::Coord;
7use nil_core::world::config::WorldId;
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 GetCityRequest {
18  pub world: WorldId,
19  #[builder(into)]
20  pub coord: Coord,
21}
22
23#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
24#[serde(rename_all = "camelCase")]
25#[cfg_attr(feature = "typescript", derive(TS))]
26#[cfg_attr(feature = "typescript", ts(export))]
27pub struct GetCityScoreRequest {
28  pub world: WorldId,
29  #[builder(into)]
30  pub coord: Coord,
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 GetPublicCitiesRequest {
38  pub world: WorldId,
39  #[serde(default)]
40  #[builder(default, with = FromIterator::from_iter)]
41  pub coords: Vec<Coord>,
42  #[serde(default)]
43  #[builder(default)]
44  pub score: bool,
45  #[serde(default)]
46  #[builder(default)]
47  pub all: bool,
48}
49
50#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
51#[serde(rename_all = "camelCase")]
52#[cfg_attr(feature = "typescript", derive(TS))]
53#[cfg_attr(feature = "typescript", ts(export))]
54pub struct GetPublicCityRequest {
55  pub world: WorldId,
56  #[builder(into)]
57  pub coord: Coord,
58  #[serde(default)]
59  #[builder(default)]
60  pub score: bool,
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 RenameCityRequest {
68  pub world: WorldId,
69  #[builder(into)]
70  pub coord: Coord,
71  pub name: String,
72}
73
74#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
75#[serde(rename_all = "camelCase")]
76#[cfg_attr(feature = "typescript", derive(TS))]
77#[cfg_attr(feature = "typescript", ts(export))]
78pub struct SearchCityRequest {
79  pub world: WorldId,
80  pub search: CitySearch,
81}
82
83#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
84#[serde(rename_all = "camelCase")]
85#[cfg_attr(feature = "typescript", derive(TS))]
86#[cfg_attr(feature = "typescript", ts(export))]
87pub struct SearchPublicCityRequest {
88  pub world: WorldId,
89  pub search: CitySearch,
90}