1use std::collections::HashMap;
2
3use crate::{fighting::FightTemplateId, prelude::*};
4use schema_loader::{
5 ability_link_id_schema, asset_ui_dungeon_background_schema, asset_ui_dungeon_banner_schema,
6 currency_link_id_schema, item_link_id_schema,
7};
8use schemars::JsonSchema;
9
10use serde::{Deserialize, Serialize};
11use tsify_next::Tsify;
12
13use crate::{abilities::AbilityId, currency::CurrencyId, items::ItemTemplateId};
14
15#[declare]
16pub type DungeonTemplateId = uuid::Uuid;
17
18#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
19pub enum RewardType {
20 #[schemars(title = "Валюта", schema_with = "currency_link_id_schema")]
21 Currency(CurrencyId),
22
23 #[schemars(title = "Способность", schema_with = "ability_link_id_schema")]
24 Ability(AbilityId),
25
26 #[schemars(title = "Предмет", schema_with = "item_link_id_schema")]
27 Item(ItemTemplateId),
28}
29
30#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
31pub struct GuaranteedReward {
32 #[schemars(title = "Тип награды")]
33 pub reward_type: RewardType,
34
35 #[schemars(title = "Количество награды")]
36 pub count: i64,
37}
38
39#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
40pub struct DungeonRewards {
41 #[schemars(title = "Уровень сложности")]
42 pub difficulty_level: u64,
43
44 #[schemars(title = "Гарантированные награды")]
45 pub guaranteed_rewards: Vec<GuaranteedReward>,
46}
47
48#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify, i18n::Translate)]
49pub struct DungeonTip {
50 #[schemars(title = "Уровень сложности")]
51 pub difficulty_level: u64,
52
53 #[schemars(title = "Текст подсказки")]
54 #[translate]
55 pub tip: i18n::I18nString,
56}
57
58#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify, i18n::Translate)]
59pub struct DungeonTemplate {
60 #[schemars(schema_with = "id_schema")]
61 pub id: DungeonTemplateId,
62
63 #[schemars(title = "Название данжа")]
64 #[translate]
65 pub title: i18n::I18nString,
66
67 #[schemars(title = "Описание данжа")]
68 #[translate]
69 pub description: i18n::I18nString,
70
71 #[schemars(
72 title = "Id ключа для входа в подземелье",
73 schema_with = "currency_link_id_schema"
74 )]
75 pub key_currency_id: CurrencyId,
76
77 #[schemars(title = "Максимальный уровень сложности данжа")]
78 pub max_difficulty_level: i64,
79
80 #[schemars(
81 title = "Фон плашки данжа",
82 schema_with = "asset_ui_dungeon_banner_schema"
83 )]
84 pub ui_banner_path: String,
85
86 #[schemars(
87 title = "Фон окна данжа",
88 schema_with = "asset_ui_dungeon_background_schema"
89 )]
90 pub ui_background_path: String,
91
92 #[schemars(title = "Набор подсказок для прохождения данжа")]
93 #[translate]
94 pub tips: Vec<DungeonTip>,
95
96 #[schemars(
97 title = "Id битвы для каждой сложности",
98 schema_with = "fight_template_link_id_array_schema"
99 )]
100 pub fight_template_ids: Vec<FightTemplateId>,
101
102 #[schemars(title = "Награды, которые показываются в предпросмотре данжа")]
103 pub rewards_by_difficulty: Vec<DungeonRewards>,
104
105 #[schemars(title = "Главная награда за данж")]
106 pub main_reward: RewardType,
107
108 #[schemars(title = "Чаптер, на котором открывается данж")]
109 pub chapter_level_unlock: i64,
110
111 #[schemars(
115 title = "Задержка появления следующей волны, мс",
116 description = "Необязательная задержка между зачисткой волны и запуском следующей волны вместе с движением союзной формации. Если не задана, используется 500 мс."
117 )]
118 pub between_wave_spawn_delay_ticks: Option<u64>,
119
120 #[schemars(
124 title = "Продвигать формацию между волнами",
125 description = "Необязательный флаг движения союзной формации между обычными волнами. Если не задан, движение включено."
126 )]
127 pub advance_formation_between_waves: Option<bool>,
128}
129
130#[derive(Default, Clone, Debug, Eq, PartialEq, Deserialize, Serialize, JsonSchema, Tsify)]
131pub struct Dungeons {
132 pub completed_difficulties: HashMap<DungeonTemplateId, i64>,
133}