essences/
dungeons.rs

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)]
49pub struct DungeonTip {
50    #[schemars(title = "Уровень сложности")]
51    pub difficulty_level: u64,
52
53    #[schemars(title = "Текст подсказки")]
54    pub tip: i18n::I18nString,
55}
56
57#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
58pub struct DungeonTemplate {
59    #[schemars(schema_with = "id_schema")]
60    pub id: DungeonTemplateId,
61
62    #[schemars(title = "Название данжа")]
63    pub title: i18n::I18nString,
64
65    #[schemars(title = "Описание данжа")]
66    pub description: i18n::I18nString,
67
68    #[schemars(
69        title = "Id ключа для входа в подземелье",
70        schema_with = "currency_link_id_schema"
71    )]
72    pub key_currency_id: CurrencyId,
73
74    #[schemars(title = "Максимальный уровень сложности данжа")]
75    pub max_difficulty_level: i64,
76
77    #[schemars(
78        title = "Фон плашки данжа",
79        schema_with = "asset_ui_dungeon_banner_schema"
80    )]
81    pub ui_banner_path: String,
82
83    #[schemars(
84        title = "Фон окна данжа",
85        schema_with = "asset_ui_dungeon_background_schema"
86    )]
87    pub ui_background_path: String,
88
89    #[schemars(title = "Набор подсказок для прохождения данжа")]
90    pub tips: Vec<DungeonTip>,
91
92    #[schemars(
93        title = "Id битвы для каждой сложности",
94        schema_with = "fight_template_link_id_array_schema"
95    )]
96    pub fight_template_ids: Vec<FightTemplateId>,
97
98    #[schemars(title = "Награды, которые показываются в предпросмотре данжа")]
99    pub rewards_by_difficulty: Vec<DungeonRewards>,
100
101    #[schemars(title = "Главная награда за данж")]
102    pub main_reward: RewardType,
103
104    #[schemars(title = "Чаптер, на котором открывается данж")]
105    pub chapter_level_unlock: i64,
106}
107
108#[derive(Default, Clone, Debug, Eq, PartialEq, Deserialize, Serialize, JsonSchema, Tsify)]
109pub struct Dungeons {
110    pub completed_difficulties: HashMap<DungeonTemplateId, i64>,
111}