@dchighs/dc-config-mapper 0.0.2 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-compiler.js +4 -3
- package/dist/dtos/items/building.dto.d.ts +64 -0
- package/dist/dtos/items/deco.dto.d.ts +65 -0
- package/dist/dtos/items/dragon.dto.js +2 -0
- package/dist/dtos/items/index.d.ts +2 -2
- package/dist/dtos/items/index.js +2 -2
- package/dist/dtos/items/{restructured-items.d.ts → restructured-items.dto.d.ts} +5 -130
- package/dist/dtos/items/restructured-items.dto.js +2 -0
- package/dist/enums/index.d.ts +2 -2
- package/dist/enums/index.js +2 -2
- package/dist/mappers/chest.mapper.d.ts +3 -3
- package/dist/mappers/heroic-races.mapper.d.ts +2 -2
- package/dist/mappers/items.mapper.d.ts +40 -107
- package/dist/mappers/items.mapper.js +2 -1
- package/dist/mappers/maze-islands.mapper.d.ts +4 -6
- package/dist/schemas/chests/chest.schema.d.ts +9 -9
- package/dist/schemas/chests/reward.schema.d.ts +2 -2
- package/dist/schemas/chests/reward.schema.js +10 -10
- package/dist/schemas/islands/heroic-races/reward.schema.d.ts +1 -1
- package/dist/schemas/islands/heroic-races/reward.schema.js +3 -3
- package/dist/schemas/islands/maze-islands/island.schema.d.ts +0 -1
- package/dist/schemas/islands/maze-islands/island.schema.js +0 -1
- package/dist/schemas/islands/maze-islands/node.schema.d.ts +2 -3
- package/dist/schemas/islands/maze-islands/node.schema.js +6 -7
- package/dist/schemas/items/building.schema.d.ts +188 -0
- package/dist/schemas/items/building.schema.js +130 -0
- package/dist/schemas/items/deco.schema.d.ts +182 -0
- package/dist/schemas/items/deco.schema.js +129 -0
- package/dist/schemas/items/dragon.schema.js +6 -6
- package/dist/schemas/skills/attack.schema.js +2 -2
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/package.json +1 -1
- package/dist/mapper.d.ts +0 -4
- package/dist/mapper.js +0 -9
- /package/dist/dtos/items/{dragon.js → building.dto.js} +0 -0
- /package/dist/dtos/items/{restructured-items.js → deco.dto.js} +0 -0
- /package/dist/dtos/items/{dragon.d.ts → dragon.dto.d.ts} +0 -0
- /package/dist/enums/{cost-type.d.ts → cost-type.enum.d.ts} +0 -0
- /package/dist/enums/{cost-type.js → cost-type.enum.js} +0 -0
- /package/dist/enums/{item-group-type.d.ts → item-group-type.enum.d.ts} +0 -0
- /package/dist/enums/{item-group-type.js → item-group-type.enum.js} +0 -0
- /package/dist/enums/{reward-resource-type.d.ts → reward-resource-type.enum.d.ts} +0 -0
- /package/dist/enums/{reward-resource-type.js → reward-resource-type.enum.js} +0 -0
- /package/dist/utils/{element-map.d.ts → element-map.util.d.ts} +0 -0
- /package/dist/utils/{element-map.js → element-map.util.js} +0 -0
- /package/dist/utils/{number-to-boolean.d.ts → number-to-boolean.util.d.ts} +0 -0
- /package/dist/utils/{number-to-boolean.js → number-to-boolean.util.js} +0 -0
- /package/dist/utils/{record-keys-conversor.d.ts → record-keys-conversor.util.d.ts} +0 -0
- /package/dist/utils/{record-keys-conversor.js → record-keys-conversor.util.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { RewardResourceType } from "../../enums/reward-resource-type";
|
|
2
|
+
import { RewardResourceType } from "../../enums/reward-resource-type.enum";
|
|
3
3
|
export declare const chestRewardSchema: z.ZodPipe<z.ZodObject<{
|
|
4
4
|
id: z.ZodNumber;
|
|
5
5
|
reward: z.ZodObject<{
|
|
@@ -55,7 +55,7 @@ export declare const chestRewardSchema: z.ZodPipe<z.ZodObject<{
|
|
|
55
55
|
element: import("@dchighs/dc-core").DragonElement;
|
|
56
56
|
amount: never;
|
|
57
57
|
} | undefined;
|
|
58
|
-
|
|
58
|
+
building_ids: number[] | undefined;
|
|
59
59
|
eggs_ids: number[] | undefined;
|
|
60
60
|
seeds: {
|
|
61
61
|
id: number;
|
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.chestRewardSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const reward_resource_type_enum_1 = require("../../enums/reward-resource-type.enum");
|
|
6
|
+
const element_map_util_1 = require("../../utils/element-map.util");
|
|
7
7
|
function processReward(rewardResource) {
|
|
8
8
|
if (!rewardResource) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
if (rewardResource === null || rewardResource === void 0 ? void 0 : rewardResource.c) {
|
|
12
12
|
return {
|
|
13
|
-
type:
|
|
13
|
+
type: reward_resource_type_enum_1.RewardResourceType.Gem,
|
|
14
14
|
amount: rewardResource.c,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
if (rewardResource === null || rewardResource === void 0 ? void 0 : rewardResource.f) {
|
|
18
18
|
return {
|
|
19
|
-
type:
|
|
19
|
+
type: reward_resource_type_enum_1.RewardResourceType.Food,
|
|
20
20
|
amount: rewardResource.f,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
if (rewardResource === null || rewardResource === void 0 ? void 0 : rewardResource.g) {
|
|
24
24
|
return {
|
|
25
|
-
type:
|
|
25
|
+
type: reward_resource_type_enum_1.RewardResourceType.Gold,
|
|
26
26
|
amount: rewardResource.g,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -30,20 +30,20 @@ function processReward(rewardResource) {
|
|
|
30
30
|
if (tokenKey) {
|
|
31
31
|
const elementAcronym = tokenKey.replace("_token", "");
|
|
32
32
|
return {
|
|
33
|
-
type:
|
|
34
|
-
element:
|
|
33
|
+
type: reward_resource_type_enum_1.RewardResourceType.HabitatToken,
|
|
34
|
+
element: element_map_util_1.elementMap[elementAcronym],
|
|
35
35
|
amount: rewardResource[tokenKey],
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
if (rewardResource === null || rewardResource === void 0 ? void 0 : rewardResource.ep) {
|
|
39
39
|
return {
|
|
40
|
-
type:
|
|
40
|
+
type: reward_resource_type_enum_1.RewardResourceType.IslandCoin,
|
|
41
41
|
amount: rewardResource.ep,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
if (rewardResource === null || rewardResource === void 0 ? void 0 : rewardResource.x) {
|
|
45
45
|
return {
|
|
46
|
-
type:
|
|
46
|
+
type: reward_resource_type_enum_1.RewardResourceType.Xp,
|
|
47
47
|
amount: rewardResource.x,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
@@ -95,7 +95,7 @@ exports.chestRewardSchema = zod_1.z.object({
|
|
|
95
95
|
}).strict().transform((data) => {
|
|
96
96
|
const reward = {
|
|
97
97
|
resource: data.reward.resource ? processReward(data.reward.resource) : undefined,
|
|
98
|
-
|
|
98
|
+
building_ids: data.reward.buildings,
|
|
99
99
|
eggs_ids: data.reward.eggs,
|
|
100
100
|
seeds: data.reward.seeds,
|
|
101
101
|
moves: data.reward.moves,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { RewardResourceType } from "../../../enums/reward-resource-type";
|
|
2
|
+
import { RewardResourceType } from "../../../enums/reward-resource-type.enum";
|
|
3
3
|
export declare const heroicRacesRewardSchema: z.ZodPipe<z.ZodObject<{
|
|
4
4
|
id: z.ZodNumber;
|
|
5
5
|
positions: z.ZodArray<z.ZodNumber>;
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.heroicRacesRewardSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const reward_resource_type_enum_1 = require("../../../enums/reward-resource-type.enum");
|
|
6
6
|
function processReward(reward) {
|
|
7
7
|
if (reward.c) {
|
|
8
8
|
return {
|
|
9
|
-
type:
|
|
9
|
+
type: reward_resource_type_enum_1.RewardResourceType.Gem,
|
|
10
10
|
amount: reward.c,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
if (reward.egg) {
|
|
14
14
|
return {
|
|
15
|
-
type:
|
|
15
|
+
type: reward_resource_type_enum_1.RewardResourceType.Dragon,
|
|
16
16
|
dragon_ids: reward.egg,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -57,7 +57,6 @@ exports.mazeIslandSchema = zod_1.z.object({
|
|
|
57
57
|
},
|
|
58
58
|
initial_points: data.initial_points,
|
|
59
59
|
min_level: data.min_level,
|
|
60
|
-
building_id: data.building_id,
|
|
61
60
|
mobile_tutorial_id: data.mobile_tutorial_id,
|
|
62
61
|
zip_file_name: node_path_1.default.basename(data.zip_file),
|
|
63
62
|
sound_tag: data.sound_tag,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { RewardResourceType } from "../../../enums/reward-resource-type";
|
|
2
|
+
import { RewardResourceType } from "../../../enums/reward-resource-type.enum";
|
|
3
3
|
export declare const mazeIslandsNodeSchema: z.ZodPipe<z.ZodObject<{
|
|
4
4
|
id: z.ZodNumber;
|
|
5
5
|
position: z.ZodArray<z.ZodNumber>;
|
|
@@ -22,8 +22,7 @@ export declare const mazeIslandsNodeSchema: z.ZodPipe<z.ZodObject<{
|
|
|
22
22
|
}, z.core.$strict>, z.ZodTransform<{
|
|
23
23
|
id: number;
|
|
24
24
|
cost: number;
|
|
25
|
-
|
|
26
|
-
reward: ({
|
|
25
|
+
rewards: ({
|
|
27
26
|
type: RewardResourceType;
|
|
28
27
|
amount: number;
|
|
29
28
|
chest_id?: undefined;
|
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mazeIslandsNodeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const reward_resource_type_enum_1 = require("../../../enums/reward-resource-type.enum");
|
|
6
6
|
function processReward(reward) {
|
|
7
7
|
if (reward === null || reward === void 0 ? void 0 : reward.f) {
|
|
8
8
|
return {
|
|
9
|
-
type:
|
|
9
|
+
type: reward_resource_type_enum_1.RewardResourceType.Food,
|
|
10
10
|
amount: reward.f,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
if (reward === null || reward === void 0 ? void 0 : reward.g) {
|
|
14
14
|
return {
|
|
15
|
-
type:
|
|
15
|
+
type: reward_resource_type_enum_1.RewardResourceType.Gold,
|
|
16
16
|
amount: reward.g,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
if (reward === null || reward === void 0 ? void 0 : reward.chest) {
|
|
20
20
|
return {
|
|
21
|
-
type:
|
|
21
|
+
type: reward_resource_type_enum_1.RewardResourceType.Chest,
|
|
22
22
|
chest_id: reward.chest,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
if (reward === null || reward === void 0 ? void 0 : reward.b) {
|
|
26
26
|
return {
|
|
27
|
-
type:
|
|
27
|
+
type: reward_resource_type_enum_1.RewardResourceType.Building,
|
|
28
28
|
building_id: reward.b,
|
|
29
29
|
};
|
|
30
30
|
}
|
|
@@ -54,8 +54,7 @@ exports.mazeIslandsNodeSchema = zod_1.z.object({
|
|
|
54
54
|
return {
|
|
55
55
|
id: data.id,
|
|
56
56
|
cost: (_b = (_a = data.cost) === null || _a === void 0 ? void 0 : _a.ep) !== null && _b !== void 0 ? _b : 0,
|
|
57
|
-
|
|
58
|
-
reward: data.reward ? data.reward.map(processReward) : undefined,
|
|
57
|
+
rewards: data.reward ? data.reward.map(processReward) : undefined,
|
|
59
58
|
is_highlighted: data.highlighted,
|
|
60
59
|
key_path_id: data.key,
|
|
61
60
|
encounter_id: data.encounter,
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const buildingSchema: z.ZodPipe<z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
group_type: z.ZodString;
|
|
6
|
+
name_key: z.ZodOptional<z.ZodString>;
|
|
7
|
+
animated: z.ZodNumber;
|
|
8
|
+
build_time: z.ZodNumber;
|
|
9
|
+
mobile_version: z.ZodNumber;
|
|
10
|
+
android_version: z.ZodNumber;
|
|
11
|
+
show_on_mobile: z.ZodNumber;
|
|
12
|
+
type: z.ZodString;
|
|
13
|
+
element_type: z.ZodOptional<z.ZodString>;
|
|
14
|
+
xp: z.ZodNumber;
|
|
15
|
+
min_level: z.ZodNumber;
|
|
16
|
+
costs: z.ZodObject<{
|
|
17
|
+
c: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
g: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
display_order: z.ZodNumber;
|
|
21
|
+
boost_modifier: z.ZodNumber;
|
|
22
|
+
gift_level: z.ZodNumber;
|
|
23
|
+
giftable: z.ZodNumber;
|
|
24
|
+
cost_unit_cash: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
collect: z.ZodNumber;
|
|
26
|
+
collect_xp: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
category_id: z.ZodNumber;
|
|
28
|
+
subcategory_id: z.ZodNumber;
|
|
29
|
+
building_limit_same_id: z.ZodNumber;
|
|
30
|
+
in_store: z.ZodNumber;
|
|
31
|
+
width: z.ZodNumber;
|
|
32
|
+
height: z.ZodNumber;
|
|
33
|
+
new_item: z.ZodNumber;
|
|
34
|
+
img_name: z.ZodString;
|
|
35
|
+
img_name_mobile: z.ZodString;
|
|
36
|
+
img_name_android: z.ZodString;
|
|
37
|
+
activation: z.ZodNumber;
|
|
38
|
+
upgrades_to: z.ZodNumber;
|
|
39
|
+
collect_type: z.ZodAny;
|
|
40
|
+
velocity: z.ZodNumber;
|
|
41
|
+
description: z.ZodOptional<z.ZodString>;
|
|
42
|
+
properties: z.ZodObject<{
|
|
43
|
+
capacity: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
incubator: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
bulldozable: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
max_dragon_level: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
required_items: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
48
|
+
workingBuilding: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
breeding: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
breeding_factor: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
max_gold: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
friend_assistable: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
upgrade_from: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
floating: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
fixed_position: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
56
|
+
is_fixed: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
crosspromotion: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
ft_flying: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
building_ownership_id: z.ZodNumber;
|
|
61
|
+
sell_price: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
g: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
inventory_ids: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
66
|
+
id: number;
|
|
67
|
+
name: string;
|
|
68
|
+
name_key: string | undefined;
|
|
69
|
+
animated: boolean;
|
|
70
|
+
build_time: number;
|
|
71
|
+
type: string;
|
|
72
|
+
element_type: string | undefined;
|
|
73
|
+
xp_on_build: number;
|
|
74
|
+
min_level: number;
|
|
75
|
+
buy_price: {
|
|
76
|
+
type: string;
|
|
77
|
+
amount: number;
|
|
78
|
+
} | null;
|
|
79
|
+
display_order: number;
|
|
80
|
+
boost_modifier: number;
|
|
81
|
+
cost_unit_cash: number | undefined;
|
|
82
|
+
collect: number;
|
|
83
|
+
collect_xp: number | undefined;
|
|
84
|
+
category_id: number;
|
|
85
|
+
subcategory_id: number;
|
|
86
|
+
building_limit_same_id: number;
|
|
87
|
+
in_store: boolean;
|
|
88
|
+
width: number;
|
|
89
|
+
height: number;
|
|
90
|
+
new_item: boolean;
|
|
91
|
+
imageNames: {
|
|
92
|
+
default: string;
|
|
93
|
+
mobile: string;
|
|
94
|
+
android: string;
|
|
95
|
+
};
|
|
96
|
+
activation: number;
|
|
97
|
+
upgrades_to: number;
|
|
98
|
+
collect_type: any;
|
|
99
|
+
velocity: number;
|
|
100
|
+
description: string | undefined;
|
|
101
|
+
properties: {
|
|
102
|
+
capacity?: number | undefined;
|
|
103
|
+
incubator?: number | undefined;
|
|
104
|
+
bulldozable?: number | undefined;
|
|
105
|
+
max_dragon_level?: number | undefined;
|
|
106
|
+
required_items?: number[] | undefined;
|
|
107
|
+
workingBuilding?: number | undefined;
|
|
108
|
+
breeding?: number | undefined;
|
|
109
|
+
breeding_factor?: number | undefined;
|
|
110
|
+
max_gold?: number | undefined;
|
|
111
|
+
friend_assistable?: number | undefined;
|
|
112
|
+
upgrade_from?: number | undefined;
|
|
113
|
+
floating?: number | undefined;
|
|
114
|
+
fixed_position?: number[] | undefined;
|
|
115
|
+
is_fixed?: number | undefined;
|
|
116
|
+
crosspromotion?: number | undefined;
|
|
117
|
+
ft_flying?: number | undefined;
|
|
118
|
+
};
|
|
119
|
+
building_ownership_id: number;
|
|
120
|
+
sell_price: {
|
|
121
|
+
type: string;
|
|
122
|
+
amount: number;
|
|
123
|
+
} | null;
|
|
124
|
+
inventory_ids: number | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
id: number;
|
|
127
|
+
name: string;
|
|
128
|
+
group_type: string;
|
|
129
|
+
animated: number;
|
|
130
|
+
build_time: number;
|
|
131
|
+
mobile_version: number;
|
|
132
|
+
android_version: number;
|
|
133
|
+
show_on_mobile: number;
|
|
134
|
+
type: string;
|
|
135
|
+
xp: number;
|
|
136
|
+
min_level: number;
|
|
137
|
+
costs: {
|
|
138
|
+
c?: number | undefined;
|
|
139
|
+
g?: number | undefined;
|
|
140
|
+
};
|
|
141
|
+
display_order: number;
|
|
142
|
+
boost_modifier: number;
|
|
143
|
+
gift_level: number;
|
|
144
|
+
giftable: number;
|
|
145
|
+
collect: number;
|
|
146
|
+
category_id: number;
|
|
147
|
+
subcategory_id: number;
|
|
148
|
+
building_limit_same_id: number;
|
|
149
|
+
in_store: number;
|
|
150
|
+
width: number;
|
|
151
|
+
height: number;
|
|
152
|
+
new_item: number;
|
|
153
|
+
img_name: string;
|
|
154
|
+
img_name_mobile: string;
|
|
155
|
+
img_name_android: string;
|
|
156
|
+
activation: number;
|
|
157
|
+
upgrades_to: number;
|
|
158
|
+
collect_type: any;
|
|
159
|
+
velocity: number;
|
|
160
|
+
properties: {
|
|
161
|
+
capacity?: number | undefined;
|
|
162
|
+
incubator?: number | undefined;
|
|
163
|
+
bulldozable?: number | undefined;
|
|
164
|
+
max_dragon_level?: number | undefined;
|
|
165
|
+
required_items?: number[] | undefined;
|
|
166
|
+
workingBuilding?: number | undefined;
|
|
167
|
+
breeding?: number | undefined;
|
|
168
|
+
breeding_factor?: number | undefined;
|
|
169
|
+
max_gold?: number | undefined;
|
|
170
|
+
friend_assistable?: number | undefined;
|
|
171
|
+
upgrade_from?: number | undefined;
|
|
172
|
+
floating?: number | undefined;
|
|
173
|
+
fixed_position?: number[] | undefined;
|
|
174
|
+
is_fixed?: number | undefined;
|
|
175
|
+
crosspromotion?: number | undefined;
|
|
176
|
+
ft_flying?: number | undefined;
|
|
177
|
+
};
|
|
178
|
+
building_ownership_id: number;
|
|
179
|
+
name_key?: string | undefined;
|
|
180
|
+
element_type?: string | undefined;
|
|
181
|
+
cost_unit_cash?: number | undefined;
|
|
182
|
+
collect_xp?: number | undefined;
|
|
183
|
+
description?: string | undefined;
|
|
184
|
+
sell_price?: {
|
|
185
|
+
g?: number | undefined;
|
|
186
|
+
} | undefined;
|
|
187
|
+
inventory_ids?: number | undefined;
|
|
188
|
+
}>>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildingSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const enums_1 = require("../../enums");
|
|
7
|
+
const processPrice = (priceObj) => {
|
|
8
|
+
const keys = Object.keys(priceObj);
|
|
9
|
+
if (keys.length === 0)
|
|
10
|
+
return null;
|
|
11
|
+
if (keys.length > 1) {
|
|
12
|
+
throw new Error(`Unexpected multiple price keys: ${JSON.stringify(priceObj)}`);
|
|
13
|
+
}
|
|
14
|
+
const key = keys[0];
|
|
15
|
+
const amount = priceObj[key];
|
|
16
|
+
const typeMap = {
|
|
17
|
+
[enums_1.CostType.Gold]: "gold",
|
|
18
|
+
[enums_1.CostType.Gem]: "gem",
|
|
19
|
+
};
|
|
20
|
+
if (!typeMap[key]) {
|
|
21
|
+
throw new Error(`Unexpected price key: ${key}`);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
type: typeMap[key],
|
|
25
|
+
amount: amount,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.buildingSchema = zod_1.z.object({
|
|
29
|
+
id: zod_1.z.number(),
|
|
30
|
+
name: zod_1.z.string(),
|
|
31
|
+
group_type: zod_1.z.string(),
|
|
32
|
+
name_key: zod_1.z.string().optional(),
|
|
33
|
+
animated: zod_1.z.number(),
|
|
34
|
+
build_time: zod_1.z.number(),
|
|
35
|
+
mobile_version: zod_1.z.number(),
|
|
36
|
+
android_version: zod_1.z.number(),
|
|
37
|
+
show_on_mobile: zod_1.z.number(),
|
|
38
|
+
type: zod_1.z.string(),
|
|
39
|
+
element_type: zod_1.z.string().optional(),
|
|
40
|
+
xp: zod_1.z.number(),
|
|
41
|
+
min_level: zod_1.z.number(),
|
|
42
|
+
costs: zod_1.z.object({
|
|
43
|
+
c: zod_1.z.number().optional(),
|
|
44
|
+
g: zod_1.z.number().optional(),
|
|
45
|
+
}),
|
|
46
|
+
display_order: zod_1.z.number(),
|
|
47
|
+
boost_modifier: zod_1.z.number(),
|
|
48
|
+
gift_level: zod_1.z.number(),
|
|
49
|
+
giftable: zod_1.z.number(),
|
|
50
|
+
cost_unit_cash: zod_1.z.number().optional(),
|
|
51
|
+
collect: zod_1.z.number(),
|
|
52
|
+
collect_xp: zod_1.z.number().optional(),
|
|
53
|
+
category_id: zod_1.z.number(),
|
|
54
|
+
subcategory_id: zod_1.z.number(),
|
|
55
|
+
building_limit_same_id: zod_1.z.number(),
|
|
56
|
+
in_store: zod_1.z.number(),
|
|
57
|
+
width: zod_1.z.number(),
|
|
58
|
+
height: zod_1.z.number(),
|
|
59
|
+
new_item: zod_1.z.number(),
|
|
60
|
+
img_name: zod_1.z.string(),
|
|
61
|
+
img_name_mobile: zod_1.z.string(),
|
|
62
|
+
img_name_android: zod_1.z.string(),
|
|
63
|
+
activation: zod_1.z.number(),
|
|
64
|
+
upgrades_to: zod_1.z.number(),
|
|
65
|
+
collect_type: zod_1.z.any(),
|
|
66
|
+
velocity: zod_1.z.number(),
|
|
67
|
+
description: zod_1.z.string().optional(),
|
|
68
|
+
properties: zod_1.z.object({
|
|
69
|
+
capacity: zod_1.z.number().optional(),
|
|
70
|
+
incubator: zod_1.z.number().optional(),
|
|
71
|
+
bulldozable: zod_1.z.number().optional(),
|
|
72
|
+
max_dragon_level: zod_1.z.number().optional(),
|
|
73
|
+
required_items: zod_1.z.array(zod_1.z.number()).optional(),
|
|
74
|
+
workingBuilding: zod_1.z.number().optional(),
|
|
75
|
+
breeding: zod_1.z.number().optional(),
|
|
76
|
+
breeding_factor: zod_1.z.number().optional(),
|
|
77
|
+
max_gold: zod_1.z.number().optional(),
|
|
78
|
+
friend_assistable: zod_1.z.number().optional(),
|
|
79
|
+
upgrade_from: zod_1.z.number().optional(),
|
|
80
|
+
floating: zod_1.z.number().optional(),
|
|
81
|
+
fixed_position: zod_1.z.array(zod_1.z.number()).optional(),
|
|
82
|
+
is_fixed: zod_1.z.number().optional(),
|
|
83
|
+
crosspromotion: zod_1.z.number().optional(),
|
|
84
|
+
ft_flying: zod_1.z.number().optional(),
|
|
85
|
+
}),
|
|
86
|
+
building_ownership_id: zod_1.z.number(),
|
|
87
|
+
sell_price: zod_1.z.object({
|
|
88
|
+
g: zod_1.z.number().optional(),
|
|
89
|
+
}).optional(),
|
|
90
|
+
inventory_ids: zod_1.z.number().optional(),
|
|
91
|
+
}).strict().transform((data) => {
|
|
92
|
+
return {
|
|
93
|
+
id: data.id,
|
|
94
|
+
name: data.name,
|
|
95
|
+
name_key: data.name_key,
|
|
96
|
+
animated: (0, utils_1.numberToBoolean)(data.animated),
|
|
97
|
+
build_time: data.build_time,
|
|
98
|
+
type: data.type,
|
|
99
|
+
element_type: data.element_type,
|
|
100
|
+
xp_on_build: data.xp,
|
|
101
|
+
min_level: data.min_level,
|
|
102
|
+
buy_price: processPrice(data.costs),
|
|
103
|
+
display_order: data.display_order,
|
|
104
|
+
boost_modifier: data.boost_modifier,
|
|
105
|
+
cost_unit_cash: data.cost_unit_cash,
|
|
106
|
+
collect: data.collect,
|
|
107
|
+
collect_xp: data.collect_xp,
|
|
108
|
+
category_id: data.category_id,
|
|
109
|
+
subcategory_id: data.subcategory_id,
|
|
110
|
+
building_limit_same_id: data.building_limit_same_id,
|
|
111
|
+
in_store: (0, utils_1.numberToBoolean)(data.in_store),
|
|
112
|
+
width: data.width,
|
|
113
|
+
height: data.height,
|
|
114
|
+
new_item: (0, utils_1.numberToBoolean)(data.new_item),
|
|
115
|
+
imageNames: {
|
|
116
|
+
default: data.img_name,
|
|
117
|
+
mobile: data.img_name_mobile,
|
|
118
|
+
android: data.img_name_android,
|
|
119
|
+
},
|
|
120
|
+
activation: data.activation,
|
|
121
|
+
upgrades_to: data.upgrades_to,
|
|
122
|
+
collect_type: data.collect_type,
|
|
123
|
+
velocity: data.velocity,
|
|
124
|
+
description: data.description,
|
|
125
|
+
properties: data.properties,
|
|
126
|
+
building_ownership_id: data.building_ownership_id,
|
|
127
|
+
sell_price: data.sell_price ? processPrice(data.sell_price) : null,
|
|
128
|
+
inventory_ids: data.inventory_ids,
|
|
129
|
+
};
|
|
130
|
+
});
|