@dchighs/dc-config-mapper 0.1.4 → 0.2.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/enums/reward-acronym.enum.d.ts +29 -0
- package/dist/enums/reward-acronym.enum.js +33 -0
- package/dist/enums/reward-type.enum.d.ts +10 -0
- package/dist/enums/reward-type.enum.js +14 -0
- package/dist/mappers/chest.mapper.d.ts +7 -7
- package/dist/mappers/heroic-races.mapper.d.ts +9 -9
- package/dist/mappers/index.d.ts +1 -0
- package/dist/mappers/index.js +1 -0
- package/dist/mappers/maze-islands.mapper.d.ts +10 -16
- package/dist/mappers/tower-islands.mapper.d.ts +102 -0
- package/dist/mappers/tower-islands.mapper.js +33 -0
- package/dist/schemas/chests/chest.schema.d.ts +21 -21
- package/dist/schemas/chests/reward.schema.d.ts +7 -8
- package/dist/schemas/chests/reward.schema.js +2 -48
- package/dist/schemas/islands/heroic-races/reward.schema.d.ts +9 -10
- package/dist/schemas/islands/heroic-races/reward.schema.js +2 -17
- package/dist/schemas/islands/maze-islands/island.schema.d.ts +1 -0
- package/dist/schemas/islands/maze-islands/island.schema.js +1 -0
- package/dist/schemas/islands/maze-islands/node.schema.d.ts +9 -17
- package/dist/schemas/islands/maze-islands/node.schema.js +2 -29
- package/dist/schemas/islands/tower-islands/floor.schema.d.ts +29 -0
- package/dist/schemas/islands/tower-islands/floor.schema.js +25 -0
- package/dist/schemas/islands/tower-islands/island.schema.d.ts +98 -0
- package/dist/schemas/islands/tower-islands/island.schema.js +71 -0
- package/dist/schemas/islands/tower-islands/reward.schema.d.ts +25 -0
- package/dist/schemas/islands/tower-islands/reward.schema.js +23 -0
- package/dist/schemas/islands/tower-islands/square.schema.d.ts +51 -0
- package/dist/schemas/islands/tower-islands/square.schema.js +34 -0
- package/dist/schemas/items/building.schema.js +2 -24
- package/dist/schemas/items/deco.schema.js +2 -24
- package/dist/schemas/items/dragon.schema.js +6 -28
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/process-price.util.d.ts +4 -0
- package/dist/utils/process-price.util.js +25 -0
- package/dist/utils/process-rewards.util.d.ts +17 -0
- package/dist/utils/process-rewards.util.js +67 -0
- package/package.json +2 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const towerIslandsFloorSchema: z.ZodPipe<z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
y: z.ZodNumber;
|
|
5
|
+
x_flip: z.ZodNumber;
|
|
6
|
+
floor_image: z.ZodString;
|
|
7
|
+
area: z.ZodNumber;
|
|
8
|
+
roll_die_price: z.ZodObject<{
|
|
9
|
+
ep: z.ZodNumber;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
island_id: z.ZodNumber;
|
|
12
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
13
|
+
id: number;
|
|
14
|
+
y: number;
|
|
15
|
+
x_flip: boolean;
|
|
16
|
+
floor_image: string;
|
|
17
|
+
area: number;
|
|
18
|
+
roll_die_price: number;
|
|
19
|
+
}, {
|
|
20
|
+
id: number;
|
|
21
|
+
y: number;
|
|
22
|
+
x_flip: number;
|
|
23
|
+
floor_image: string;
|
|
24
|
+
area: number;
|
|
25
|
+
roll_die_price: {
|
|
26
|
+
ep: number;
|
|
27
|
+
};
|
|
28
|
+
island_id: number;
|
|
29
|
+
}>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.towerIslandsFloorSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
exports.towerIslandsFloorSchema = zod_1.z.object({
|
|
7
|
+
id: zod_1.z.number(),
|
|
8
|
+
y: zod_1.z.number(),
|
|
9
|
+
x_flip: zod_1.z.number(),
|
|
10
|
+
floor_image: zod_1.z.string(),
|
|
11
|
+
area: zod_1.z.number(),
|
|
12
|
+
roll_die_price: zod_1.z.object({
|
|
13
|
+
ep: zod_1.z.number(),
|
|
14
|
+
}),
|
|
15
|
+
island_id: zod_1.z.number(),
|
|
16
|
+
}).strict().transform(data => {
|
|
17
|
+
return {
|
|
18
|
+
id: data.id,
|
|
19
|
+
y: data.y,
|
|
20
|
+
x_flip: (0, utils_1.numberToBoolean)(data.x_flip),
|
|
21
|
+
floor_image: data.floor_image,
|
|
22
|
+
area: data.area,
|
|
23
|
+
roll_die_price: data.roll_die_price.ep,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const towerIslandSchema: z.ZodPipe<z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
analytics_id: z.ZodString;
|
|
5
|
+
tid_name: z.ZodString;
|
|
6
|
+
start_ts: z.ZodNumber;
|
|
7
|
+
end_ts: z.ZodNumber;
|
|
8
|
+
initial_square_id: z.ZodNumber;
|
|
9
|
+
tutorial_id: z.ZodNumber;
|
|
10
|
+
tutorial_die_result: z.ZodNumber;
|
|
11
|
+
pool_size: z.ZodNumber;
|
|
12
|
+
pool_time: z.ZodNumber;
|
|
13
|
+
initial_points: z.ZodNumber;
|
|
14
|
+
currency_id: z.ZodNumber;
|
|
15
|
+
min_level: z.ZodNumber;
|
|
16
|
+
building_id: z.ZodNumber;
|
|
17
|
+
building_position: z.ZodArray<z.ZodNumber>;
|
|
18
|
+
tower_size: z.ZodArray<z.ZodNumber>;
|
|
19
|
+
zip_file: z.ZodString;
|
|
20
|
+
sound_tag: z.ZodString;
|
|
21
|
+
canvas_assets_url: z.ZodString;
|
|
22
|
+
mobile_first_floor_position: z.ZodArray<z.ZodNumber>;
|
|
23
|
+
mobile_floor_height: z.ZodNumber;
|
|
24
|
+
mobile_interior_wall_margin: z.ZodNumber;
|
|
25
|
+
mobile_final_dragon_scale: z.ZodArray<z.ZodNumber>;
|
|
26
|
+
mobile_final_dragon_position: z.ZodArray<z.ZodNumber>;
|
|
27
|
+
mobile_final_dragon_info_position: z.ZodArray<z.ZodNumber>;
|
|
28
|
+
max_die_roll: z.ZodNumber;
|
|
29
|
+
help_view_id: z.ZodNumber;
|
|
30
|
+
active_platforms: z.ZodObject<{
|
|
31
|
+
ios: z.ZodArray<z.ZodNumber>;
|
|
32
|
+
canvas: z.ZodArray<z.ZodNumber>;
|
|
33
|
+
android: z.ZodArray<z.ZodNumber>;
|
|
34
|
+
amazon: z.ZodArray<z.ZodNumber>;
|
|
35
|
+
windows: z.ZodArray<z.ZodNumber>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
square_ids: z.ZodArray<z.ZodNumber>;
|
|
38
|
+
floor_ids: z.ZodArray<z.ZodNumber>;
|
|
39
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
40
|
+
id: number;
|
|
41
|
+
name_key: string;
|
|
42
|
+
availability: {
|
|
43
|
+
from: string;
|
|
44
|
+
to: string;
|
|
45
|
+
};
|
|
46
|
+
initial_square_id: number;
|
|
47
|
+
pool: {
|
|
48
|
+
size: number;
|
|
49
|
+
time: number;
|
|
50
|
+
};
|
|
51
|
+
initial_points: number;
|
|
52
|
+
currency_id: number;
|
|
53
|
+
min_level: number;
|
|
54
|
+
tower_size: number[];
|
|
55
|
+
zip_file_name: string;
|
|
56
|
+
sound_tag: string;
|
|
57
|
+
max_die_roll: number;
|
|
58
|
+
help_view_id: number;
|
|
59
|
+
square_ids: number[];
|
|
60
|
+
floor_ids: number[];
|
|
61
|
+
}, {
|
|
62
|
+
id: number;
|
|
63
|
+
analytics_id: string;
|
|
64
|
+
tid_name: string;
|
|
65
|
+
start_ts: number;
|
|
66
|
+
end_ts: number;
|
|
67
|
+
initial_square_id: number;
|
|
68
|
+
tutorial_id: number;
|
|
69
|
+
tutorial_die_result: number;
|
|
70
|
+
pool_size: number;
|
|
71
|
+
pool_time: number;
|
|
72
|
+
initial_points: number;
|
|
73
|
+
currency_id: number;
|
|
74
|
+
min_level: number;
|
|
75
|
+
building_id: number;
|
|
76
|
+
building_position: number[];
|
|
77
|
+
tower_size: number[];
|
|
78
|
+
zip_file: string;
|
|
79
|
+
sound_tag: string;
|
|
80
|
+
canvas_assets_url: string;
|
|
81
|
+
mobile_first_floor_position: number[];
|
|
82
|
+
mobile_floor_height: number;
|
|
83
|
+
mobile_interior_wall_margin: number;
|
|
84
|
+
mobile_final_dragon_scale: number[];
|
|
85
|
+
mobile_final_dragon_position: number[];
|
|
86
|
+
mobile_final_dragon_info_position: number[];
|
|
87
|
+
max_die_roll: number;
|
|
88
|
+
help_view_id: number;
|
|
89
|
+
active_platforms: {
|
|
90
|
+
ios: number[];
|
|
91
|
+
canvas: number[];
|
|
92
|
+
android: number[];
|
|
93
|
+
amazon: number[];
|
|
94
|
+
windows: number[];
|
|
95
|
+
};
|
|
96
|
+
square_ids: number[];
|
|
97
|
+
floor_ids: number[];
|
|
98
|
+
}>>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.towerIslandSchema = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
exports.towerIslandSchema = zod_1.z.object({
|
|
10
|
+
id: zod_1.z.number(),
|
|
11
|
+
analytics_id: zod_1.z.string(),
|
|
12
|
+
tid_name: zod_1.z.string(),
|
|
13
|
+
start_ts: zod_1.z.number(),
|
|
14
|
+
end_ts: zod_1.z.number(),
|
|
15
|
+
initial_square_id: zod_1.z.number(),
|
|
16
|
+
tutorial_id: zod_1.z.number(),
|
|
17
|
+
tutorial_die_result: zod_1.z.number(),
|
|
18
|
+
pool_size: zod_1.z.number(),
|
|
19
|
+
pool_time: zod_1.z.number(),
|
|
20
|
+
initial_points: zod_1.z.number(),
|
|
21
|
+
currency_id: zod_1.z.number(),
|
|
22
|
+
min_level: zod_1.z.number(),
|
|
23
|
+
building_id: zod_1.z.number(),
|
|
24
|
+
building_position: zod_1.z.array(zod_1.z.number()),
|
|
25
|
+
tower_size: zod_1.z.array(zod_1.z.number()),
|
|
26
|
+
zip_file: zod_1.z.string(),
|
|
27
|
+
sound_tag: zod_1.z.string(),
|
|
28
|
+
canvas_assets_url: zod_1.z.string(),
|
|
29
|
+
mobile_first_floor_position: zod_1.z.array(zod_1.z.number()),
|
|
30
|
+
mobile_floor_height: zod_1.z.number(),
|
|
31
|
+
mobile_interior_wall_margin: zod_1.z.number(),
|
|
32
|
+
mobile_final_dragon_scale: zod_1.z.array(zod_1.z.number()),
|
|
33
|
+
mobile_final_dragon_position: zod_1.z.array(zod_1.z.number()),
|
|
34
|
+
mobile_final_dragon_info_position: zod_1.z.array(zod_1.z.number()),
|
|
35
|
+
max_die_roll: zod_1.z.number(),
|
|
36
|
+
help_view_id: zod_1.z.number(),
|
|
37
|
+
active_platforms: zod_1.z.object({
|
|
38
|
+
ios: zod_1.z.array(zod_1.z.number()),
|
|
39
|
+
canvas: zod_1.z.array(zod_1.z.number()),
|
|
40
|
+
android: zod_1.z.array(zod_1.z.number()),
|
|
41
|
+
amazon: zod_1.z.array(zod_1.z.number()),
|
|
42
|
+
windows: zod_1.z.array(zod_1.z.number()),
|
|
43
|
+
}),
|
|
44
|
+
// injected properties
|
|
45
|
+
square_ids: zod_1.z.array(zod_1.z.number()),
|
|
46
|
+
floor_ids: zod_1.z.array(zod_1.z.number()),
|
|
47
|
+
}).strict().transform(data => {
|
|
48
|
+
return {
|
|
49
|
+
id: data.id,
|
|
50
|
+
name_key: data.tid_name,
|
|
51
|
+
availability: {
|
|
52
|
+
from: new Date(data.start_ts * 1000).toISOString(),
|
|
53
|
+
to: new Date(data.end_ts * 1000).toISOString(),
|
|
54
|
+
},
|
|
55
|
+
initial_square_id: data.initial_square_id,
|
|
56
|
+
pool: {
|
|
57
|
+
size: data.pool_size,
|
|
58
|
+
time: data.pool_time,
|
|
59
|
+
},
|
|
60
|
+
initial_points: data.initial_points,
|
|
61
|
+
currency_id: data.currency_id,
|
|
62
|
+
min_level: data.min_level,
|
|
63
|
+
tower_size: data.tower_size,
|
|
64
|
+
zip_file_name: node_path_1.default.basename(data.zip_file),
|
|
65
|
+
sound_tag: data.sound_tag,
|
|
66
|
+
max_die_roll: data.max_die_roll,
|
|
67
|
+
help_view_id: data.help_view_id,
|
|
68
|
+
square_ids: data.square_ids,
|
|
69
|
+
floor_ids: data.floor_ids,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const towerIslandsRewardSchema: z.ZodPipe<z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
dragon_reward_id: z.ZodNumber;
|
|
5
|
+
last_piece_cost: z.ZodNumber;
|
|
6
|
+
num_pieces: z.ZodNumber;
|
|
7
|
+
show_new_badge: z.ZodNumber;
|
|
8
|
+
area: z.ZodNumber;
|
|
9
|
+
island_id: z.ZodNumber;
|
|
10
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
11
|
+
id: number;
|
|
12
|
+
dragon_id: number;
|
|
13
|
+
last_piece_cost: number;
|
|
14
|
+
pieces_count: number;
|
|
15
|
+
show_new_badge: boolean;
|
|
16
|
+
area: number;
|
|
17
|
+
}, {
|
|
18
|
+
id: number;
|
|
19
|
+
dragon_reward_id: number;
|
|
20
|
+
last_piece_cost: number;
|
|
21
|
+
num_pieces: number;
|
|
22
|
+
show_new_badge: number;
|
|
23
|
+
area: number;
|
|
24
|
+
island_id: number;
|
|
25
|
+
}>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.towerIslandsRewardSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
exports.towerIslandsRewardSchema = zod_1.z.object({
|
|
7
|
+
id: zod_1.z.number(),
|
|
8
|
+
dragon_reward_id: zod_1.z.number(),
|
|
9
|
+
last_piece_cost: zod_1.z.number(),
|
|
10
|
+
num_pieces: zod_1.z.number(),
|
|
11
|
+
show_new_badge: zod_1.z.number(),
|
|
12
|
+
area: zod_1.z.number(),
|
|
13
|
+
island_id: zod_1.z.number(),
|
|
14
|
+
}).strict().transform(data => {
|
|
15
|
+
return {
|
|
16
|
+
id: data.id,
|
|
17
|
+
dragon_id: data.dragon_reward_id,
|
|
18
|
+
last_piece_cost: data.last_piece_cost,
|
|
19
|
+
pieces_count: data.num_pieces,
|
|
20
|
+
show_new_badge: (0, utils_1.numberToBoolean)(data.show_new_badge),
|
|
21
|
+
area: data.area,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const towerIslandsSquareSchema: z.ZodPipe<z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
type: z.ZodString;
|
|
5
|
+
highlight: z.ZodNumber;
|
|
6
|
+
x: z.ZodNumber;
|
|
7
|
+
y: z.ZodNumber;
|
|
8
|
+
island_id: z.ZodNumber;
|
|
9
|
+
ixy: z.ZodString;
|
|
10
|
+
rewards_array: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
|
+
chest: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
egg: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>>>;
|
|
14
|
+
wall: z.ZodOptional<z.ZodString>;
|
|
15
|
+
catapult_destination_square_id: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
piece_reward_id: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
18
|
+
id: number;
|
|
19
|
+
type: string;
|
|
20
|
+
is_highlight: boolean;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
ixy: string;
|
|
24
|
+
rewards: {
|
|
25
|
+
type: import("../../../enums/reward-type.enum").RewardType;
|
|
26
|
+
element?: import("@dchighs/dc-core").DragonElement;
|
|
27
|
+
amount?: number;
|
|
28
|
+
chest_id?: number;
|
|
29
|
+
dragon_id?: number;
|
|
30
|
+
dragon_ids?: number[];
|
|
31
|
+
building_id?: number;
|
|
32
|
+
}[] | null;
|
|
33
|
+
wall: string | undefined;
|
|
34
|
+
catapult_destination_square_id: number | undefined;
|
|
35
|
+
piece_reward_id: number | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
id: number;
|
|
38
|
+
type: string;
|
|
39
|
+
highlight: number;
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
island_id: number;
|
|
43
|
+
ixy: string;
|
|
44
|
+
rewards_array?: {
|
|
45
|
+
chest?: number | undefined;
|
|
46
|
+
egg?: number | undefined;
|
|
47
|
+
}[] | undefined;
|
|
48
|
+
wall?: string | undefined;
|
|
49
|
+
catapult_destination_square_id?: number | undefined;
|
|
50
|
+
piece_reward_id?: number | undefined;
|
|
51
|
+
}>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.towerIslandsSquareSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
exports.towerIslandsSquareSchema = zod_1.z.object({
|
|
7
|
+
id: zod_1.z.number(),
|
|
8
|
+
type: zod_1.z.string(),
|
|
9
|
+
highlight: zod_1.z.number(),
|
|
10
|
+
x: zod_1.z.number(),
|
|
11
|
+
y: zod_1.z.number(),
|
|
12
|
+
island_id: zod_1.z.number(),
|
|
13
|
+
ixy: zod_1.z.string(),
|
|
14
|
+
rewards_array: zod_1.z.array(zod_1.z.object({
|
|
15
|
+
chest: zod_1.z.number().optional(),
|
|
16
|
+
egg: zod_1.z.number().optional(),
|
|
17
|
+
})).optional(),
|
|
18
|
+
wall: zod_1.z.string().optional(),
|
|
19
|
+
catapult_destination_square_id: zod_1.z.number().optional(),
|
|
20
|
+
piece_reward_id: zod_1.z.number().optional(),
|
|
21
|
+
}).strict().transform(data => {
|
|
22
|
+
return {
|
|
23
|
+
id: data.id,
|
|
24
|
+
type: data.type,
|
|
25
|
+
is_highlight: (0, utils_1.numberToBoolean)(data.highlight),
|
|
26
|
+
x: data.x,
|
|
27
|
+
y: data.y,
|
|
28
|
+
ixy: data.ixy,
|
|
29
|
+
rewards: data.rewards_array ? (0, utils_1.processRewards)(data.rewards_array) : null,
|
|
30
|
+
wall: data.wall,
|
|
31
|
+
catapult_destination_square_id: data.catapult_destination_square_id,
|
|
32
|
+
piece_reward_id: data.piece_reward_id,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
@@ -3,28 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildingSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
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
6
|
exports.buildingSchema = zod_1.z.object({
|
|
29
7
|
id: zod_1.z.number(),
|
|
30
8
|
name: zod_1.z.string(),
|
|
@@ -99,7 +77,7 @@ exports.buildingSchema = zod_1.z.object({
|
|
|
99
77
|
element_type: data.element_type,
|
|
100
78
|
xp_on_build: data.xp,
|
|
101
79
|
min_level: data.min_level,
|
|
102
|
-
buy_price: processPrice(data.costs),
|
|
80
|
+
buy_price: (0, utils_1.processPrice)(data.costs),
|
|
103
81
|
display_order: data.display_order,
|
|
104
82
|
boost_modifier: data.boost_modifier,
|
|
105
83
|
cost_unit_cash: data.cost_unit_cash,
|
|
@@ -124,7 +102,7 @@ exports.buildingSchema = zod_1.z.object({
|
|
|
124
102
|
description: data.description,
|
|
125
103
|
properties: data.properties,
|
|
126
104
|
building_ownership_id: data.building_ownership_id,
|
|
127
|
-
sell_price: data.sell_price ? processPrice(data.sell_price) : null,
|
|
105
|
+
sell_price: data.sell_price ? (0, utils_1.processPrice)(data.sell_price) : null,
|
|
128
106
|
inventory_ids: data.inventory_ids,
|
|
129
107
|
};
|
|
130
108
|
});
|
|
@@ -3,28 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.decoSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
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
6
|
exports.decoSchema = zod_1.z.object({
|
|
29
7
|
id: zod_1.z.number(),
|
|
30
8
|
name: zod_1.z.string(),
|
|
@@ -98,8 +76,8 @@ exports.decoSchema = zod_1.z.object({
|
|
|
98
76
|
element_type: data.element_type,
|
|
99
77
|
xp_on_build: data.xp,
|
|
100
78
|
min_level: data.min_level,
|
|
101
|
-
buy_price: processPrice(data.costs),
|
|
102
|
-
sell_price: data.sell_price ? processPrice(data.sell_price) : null,
|
|
79
|
+
buy_price: (0, utils_1.processPrice)(data.costs),
|
|
80
|
+
sell_price: data.sell_price ? (0, utils_1.processPrice)(data.sell_price) : null,
|
|
103
81
|
display_order: data.display_order,
|
|
104
82
|
boost_modifier: data.boost_modifier,
|
|
105
83
|
cost_unit_cash: data.cost_unit_cash,
|
|
@@ -2,30 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dragonSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
6
|
const element_map_util_1 = require("../../utils/element-map.util");
|
|
7
|
-
const enums_1 = require("../../enums");
|
|
8
|
-
const processPrice = (priceObj) => {
|
|
9
|
-
const keys = Object.keys(priceObj);
|
|
10
|
-
if (keys.length === 0)
|
|
11
|
-
return null;
|
|
12
|
-
if (keys.length > 1) {
|
|
13
|
-
throw new Error(`Unexpected multiple price keys: ${JSON.stringify(priceObj)}`);
|
|
14
|
-
}
|
|
15
|
-
const key = keys[0];
|
|
16
|
-
const amount = priceObj[key];
|
|
17
|
-
const typeMap = {
|
|
18
|
-
[enums_1.CostType.Gold]: "gold",
|
|
19
|
-
[enums_1.CostType.Gem]: "gem",
|
|
20
|
-
};
|
|
21
|
-
if (!typeMap[key]) {
|
|
22
|
-
throw new Error(`Unexpected price key: ${key}`);
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
type: typeMap[key],
|
|
26
|
-
amount: amount,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
7
|
exports.dragonSchema = zod_1.z.object({
|
|
30
8
|
id: zod_1.z.number(),
|
|
31
9
|
name: zod_1.z.string(),
|
|
@@ -108,11 +86,11 @@ exports.dragonSchema = zod_1.z.object({
|
|
|
108
86
|
elements: data.attributes.map((element) => element_map_util_1.elementMap[element]),
|
|
109
87
|
description: data.description,
|
|
110
88
|
description_key: `tid_unit_${data.id}_description`,
|
|
111
|
-
buy_price: processPrice(data.costs),
|
|
112
|
-
sell_price: processPrice(data.sell_price),
|
|
113
|
-
is_breedable: (0,
|
|
114
|
-
can_breed: (0,
|
|
115
|
-
is_in_store: (0,
|
|
89
|
+
buy_price: (0, utils_1.processPrice)(data.costs),
|
|
90
|
+
sell_price: (0, utils_1.processPrice)(data.sell_price),
|
|
91
|
+
is_breedable: (0, utils_1.numberToBoolean)(data.breedable),
|
|
92
|
+
can_breed: (0, utils_1.numberToBoolean)(data.can_breed),
|
|
93
|
+
is_in_store: (0, utils_1.numberToBoolean)(data.in_store),
|
|
116
94
|
min_store_level: data.in_store_min_level,
|
|
117
95
|
basic_attack_ids: data.attacks,
|
|
118
96
|
trainable_attack_ids: data.trainable_attacks,
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./number-to-boolean.util"), exports);
|
|
18
18
|
__exportStar(require("./record-keys-conversor.util"), exports);
|
|
19
19
|
__exportStar(require("./element-map.util"), exports);
|
|
20
|
+
__exportStar(require("./process-rewards.util"), exports);
|
|
21
|
+
__exportStar(require("./process-price.util"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processPrice = processPrice;
|
|
4
|
+
const enums_1 = require("../enums");
|
|
5
|
+
function processPrice(price) {
|
|
6
|
+
const keys = Object.keys(price);
|
|
7
|
+
if (keys.length === 0)
|
|
8
|
+
return null;
|
|
9
|
+
if (keys.length > 1) {
|
|
10
|
+
throw new Error(`Unexpected multiple price keys: ${JSON.stringify(price)}`);
|
|
11
|
+
}
|
|
12
|
+
const key = keys[0];
|
|
13
|
+
const amount = price[key];
|
|
14
|
+
const typeMap = {
|
|
15
|
+
[enums_1.CostType.Gold]: "gold",
|
|
16
|
+
[enums_1.CostType.Gem]: "gem",
|
|
17
|
+
};
|
|
18
|
+
if (!typeMap[key]) {
|
|
19
|
+
throw new Error(`Unexpected price key: ${key}`);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
type: typeMap[key],
|
|
23
|
+
amount: amount,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DragonElement } from "@dchighs/dc-core";
|
|
2
|
+
import { RewardAcronym } from "../enums/reward-acronym.enum";
|
|
3
|
+
import { RewardType } from "../enums/reward-type.enum";
|
|
4
|
+
type Reward = {
|
|
5
|
+
egg?: number | number[];
|
|
6
|
+
} & Omit<Partial<Record<RewardAcronym, number>>, "egg">;
|
|
7
|
+
type ProcessedReward = {
|
|
8
|
+
type: RewardType;
|
|
9
|
+
element?: DragonElement;
|
|
10
|
+
amount?: number;
|
|
11
|
+
chest_id?: number;
|
|
12
|
+
dragon_id?: number;
|
|
13
|
+
dragon_ids?: number[];
|
|
14
|
+
building_id?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare function processRewards(rewards: Reward[]): ProcessedReward[];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processRewards = processRewards;
|
|
4
|
+
const reward_type_enum_1 = require("../enums/reward-type.enum");
|
|
5
|
+
const element_map_util_1 = require("./element-map.util");
|
|
6
|
+
function processRewards(rewards) {
|
|
7
|
+
const processedRewards = [];
|
|
8
|
+
for (const reward of rewards) {
|
|
9
|
+
if (reward.chest) {
|
|
10
|
+
processedRewards.push({
|
|
11
|
+
type: reward_type_enum_1.RewardType.Chest,
|
|
12
|
+
chest_id: reward.chest,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (reward.egg) {
|
|
16
|
+
if (Array.isArray(reward.egg)) {
|
|
17
|
+
processedRewards.push({
|
|
18
|
+
type: reward_type_enum_1.RewardType.Dragon,
|
|
19
|
+
dragon_ids: reward.egg,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
processedRewards.push({
|
|
24
|
+
type: reward_type_enum_1.RewardType.Dragon,
|
|
25
|
+
dragon_id: reward.egg,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (reward.g) {
|
|
30
|
+
processedRewards.push({
|
|
31
|
+
type: reward_type_enum_1.RewardType.Gold,
|
|
32
|
+
amount: reward.g,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (reward.c) {
|
|
36
|
+
processedRewards.push({
|
|
37
|
+
type: reward_type_enum_1.RewardType.Gem,
|
|
38
|
+
amount: reward.c,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (reward.f) {
|
|
42
|
+
processedRewards.push({
|
|
43
|
+
type: reward_type_enum_1.RewardType.Gem,
|
|
44
|
+
amount: reward.c,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (reward.b) {
|
|
48
|
+
processedRewards.push({
|
|
49
|
+
type: reward_type_enum_1.RewardType.Building,
|
|
50
|
+
building_id: reward.b,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (Object.keys(reward).some(key => key.endsWith("_token"))) {
|
|
54
|
+
const key = Object.keys(reward).find(key => key.endsWith("_token"));
|
|
55
|
+
const elementAcronym = key === null || key === void 0 ? void 0 : key.split("_")[0];
|
|
56
|
+
if (!elementAcronym) {
|
|
57
|
+
throw new Error("Invalid reward");
|
|
58
|
+
}
|
|
59
|
+
processedRewards.push({
|
|
60
|
+
type: reward_type_enum_1.RewardType.HabitatToken,
|
|
61
|
+
element: element_map_util_1.elementMap[elementAcronym],
|
|
62
|
+
amount: reward[key],
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return processedRewards;
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dchighs/dc-config-mapper",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A opined library to restructure and populate configuration for Dragon City.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@dchighs/dc-config": "^0.0.1",
|
|
40
|
+
"@dchighs/dc-core": "^0.1.0",
|
|
40
41
|
"@dchighs/dc-localization": "^0.0.4"
|
|
41
42
|
}
|
|
42
43
|
}
|