@dchighs/dc-config-mapper 0.3.1 → 0.4.0

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.
@@ -0,0 +1,101 @@
1
+ import { Localization } from "@dchighs/dc-localization";
2
+ import { GameConfigDto } from "@dchighs/dc-config";
3
+ type FogIslandDto = GameConfigDto["game_data"]["config"]["fog_island"];
4
+ export declare class FogIslandsMapper {
5
+ readonly localiztion: Localization;
6
+ constructor(localiztion: Localization);
7
+ map(fogIslands: FogIslandDto): {
8
+ islands: import("@dchighs/dc-localization/dist/types").Translated<{
9
+ id: number;
10
+ availability: {
11
+ from: string;
12
+ to: string;
13
+ };
14
+ name_key: string;
15
+ board_size: {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ cell_size: {
20
+ width: number;
21
+ height: number;
22
+ };
23
+ initial_square_id: number;
24
+ pool: {
25
+ points: number;
26
+ time: number;
27
+ };
28
+ initial_points: number;
29
+ currency_id: number;
30
+ min_level: number;
31
+ zip_file_name: string;
32
+ sound_tag: string;
33
+ square_ids: number[];
34
+ }>[];
35
+ squares: {
36
+ id: number;
37
+ type: string;
38
+ reward: {
39
+ chest_id: number | undefined;
40
+ type: string;
41
+ } | {
42
+ piece_dragon_id: number | undefined;
43
+ type: string;
44
+ } | null;
45
+ is_highlight: boolean;
46
+ x: number;
47
+ y: number;
48
+ cost: number;
49
+ come_back_cost: number;
50
+ reward_id: number | undefined;
51
+ }[];
52
+ currencies: {
53
+ id: number;
54
+ tid_name: string;
55
+ actions: Array<number>;
56
+ }[];
57
+ rewards: {
58
+ id: number;
59
+ type: string;
60
+ dragon_id: number;
61
+ last_piece_cost: number;
62
+ num_pieces: number;
63
+ show_new_badge: boolean;
64
+ }[];
65
+ actions: {
66
+ id: number;
67
+ type: string;
68
+ tid_name: string;
69
+ image: string;
70
+ pool_percent: number;
71
+ max_points: number;
72
+ extra_parameters?: {
73
+ max_time?: number;
74
+ cooldown?: number;
75
+ max_control_level?: number;
76
+ max_production?: number;
77
+ max_level?: number;
78
+ };
79
+ }[];
80
+ hints: {
81
+ id: number;
82
+ type: string;
83
+ tid_name: string;
84
+ icon: string;
85
+ price: {
86
+ ep: number;
87
+ };
88
+ duration_time: number;
89
+ area: number;
90
+ square_selection: number;
91
+ increment_price: number;
92
+ tutorial_id: number;
93
+ }[];
94
+ parameters: {
95
+ id: number;
96
+ name: string;
97
+ value: any;
98
+ }[];
99
+ };
100
+ }
101
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FogIslandsMapper = void 0;
4
+ const island_schema_1 = require("../schemas/islands/fog-islands/island.schema");
5
+ const square_schema_1 = require("../schemas/islands/fog-islands/square.schema");
6
+ const reward_schema_1 = require("../schemas/islands/fog-islands/reward.schema");
7
+ class FogIslandsMapper {
8
+ constructor(localiztion) {
9
+ this.localiztion = localiztion;
10
+ }
11
+ map(fogIslands) {
12
+ return {
13
+ islands: fogIslands.islands.map(island => {
14
+ const squareIds = fogIslands.squares
15
+ .filter(square => square.island_id === island.id)
16
+ .map(square => square.id);
17
+ return this.localiztion.translate(island_schema_1.fogIslandSchema.parse({
18
+ ...island,
19
+ square_ids: squareIds,
20
+ }));
21
+ }),
22
+ squares: fogIslands.squares.map(square => square_schema_1.fogIslandsSquareSchema.parse(square)),
23
+ currencies: fogIslands.currencies,
24
+ rewards: fogIslands.rewards.map(reward => reward_schema_1.fogIslandsRewardSchema.parse(reward)),
25
+ actions: fogIslands.actions,
26
+ hints: fogIslands.hints,
27
+ parameters: fogIslands.parameters,
28
+ };
29
+ }
30
+ }
31
+ exports.FogIslandsMapper = FogIslandsMapper;
@@ -50,16 +50,16 @@ export declare class GridIslandsMapper {
50
50
  dragon_id: number | undefined;
51
51
  type: string;
52
52
  } | null;
53
- highlight: number;
53
+ is_highlight: boolean;
54
54
  x: number;
55
55
  y: number;
56
- claim_cost: number;
56
+ cost: number;
57
57
  wall: string | undefined;
58
58
  wall_suffix: string | undefined;
59
59
  }[];
60
60
  decorations: {
61
61
  id: number;
62
- filename: string;
62
+ file_name: string;
63
63
  x: number;
64
64
  y: number;
65
65
  }[];
@@ -5,3 +5,4 @@ export * from "./heroic-races.mapper";
5
5
  export * from "./maze-islands.mapper";
6
6
  export * from "./tower-islands.mapper";
7
7
  export * from "./grid-islands.mapper";
8
+ export * from "./fog-islands.mapper";
@@ -21,3 +21,4 @@ __exportStar(require("./heroic-races.mapper"), exports);
21
21
  __exportStar(require("./maze-islands.mapper"), exports);
22
22
  __exportStar(require("./tower-islands.mapper"), exports);
23
23
  __exportStar(require("./grid-islands.mapper"), exports);
24
+ __exportStar(require("./fog-islands.mapper"), exports);
@@ -0,0 +1,82 @@
1
+ import { z } from "zod";
2
+ export declare const fogIslandSchema: z.ZodPipe<z.ZodObject<{
3
+ id: z.ZodNumber;
4
+ analytics_id: z.ZodString;
5
+ tid_name: z.ZodString;
6
+ tutorial_id: z.ZodNumber;
7
+ tutorial_claimable_cell_id: z.ZodNumber;
8
+ board_size: z.ZodArray<z.ZodNumber>;
9
+ cell_size: z.ZodArray<z.ZodNumber>;
10
+ origin_offset: z.ZodArray<z.ZodNumber>;
11
+ initial_square_id: z.ZodNumber;
12
+ pool_points: z.ZodNumber;
13
+ pool_time: z.ZodNumber;
14
+ initial_points: z.ZodNumber;
15
+ start_ts: z.ZodNumber;
16
+ end_ts: z.ZodNumber;
17
+ currency_id: z.ZodNumber;
18
+ min_level: z.ZodNumber;
19
+ building_id: z.ZodNumber;
20
+ building_position: z.ZodArray<z.ZodNumber>;
21
+ zip_file: z.ZodString;
22
+ sound_tag: z.ZodString;
23
+ canvas_assets_url: z.ZodString;
24
+ background_plist: z.ZodString;
25
+ foregrounds_plists: z.ZodArray<z.ZodAny>;
26
+ particles_position: z.ZodArray<z.ZodNumber>;
27
+ tutorial_claim_cells: z.ZodArray<z.ZodNumber>;
28
+ square_ids: z.ZodArray<z.ZodNumber>;
29
+ }, z.core.$strict>, z.ZodTransform<{
30
+ id: number;
31
+ availability: {
32
+ from: string;
33
+ to: string;
34
+ };
35
+ name_key: string;
36
+ board_size: {
37
+ width: number;
38
+ height: number;
39
+ };
40
+ cell_size: {
41
+ width: number;
42
+ height: number;
43
+ };
44
+ initial_square_id: number;
45
+ pool: {
46
+ points: number;
47
+ time: number;
48
+ };
49
+ initial_points: number;
50
+ currency_id: number;
51
+ min_level: number;
52
+ zip_file_name: string;
53
+ sound_tag: string;
54
+ square_ids: number[];
55
+ }, {
56
+ id: number;
57
+ analytics_id: string;
58
+ tid_name: string;
59
+ tutorial_id: number;
60
+ tutorial_claimable_cell_id: number;
61
+ board_size: number[];
62
+ cell_size: number[];
63
+ origin_offset: number[];
64
+ initial_square_id: number;
65
+ pool_points: number;
66
+ pool_time: number;
67
+ initial_points: number;
68
+ start_ts: number;
69
+ end_ts: number;
70
+ currency_id: number;
71
+ min_level: number;
72
+ building_id: number;
73
+ building_position: number[];
74
+ zip_file: string;
75
+ sound_tag: string;
76
+ canvas_assets_url: string;
77
+ background_plist: string;
78
+ foregrounds_plists: any[];
79
+ particles_position: number[];
80
+ tutorial_claim_cells: number[];
81
+ square_ids: number[];
82
+ }>>;
@@ -0,0 +1,94 @@
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.fogIslandSchema = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const zod_1 = require("zod");
9
+ /*
10
+ {
11
+ id: number;
12
+ analytics_id: string;
13
+ tid_name: string;
14
+ tutorial_id: number;
15
+ tutorial_claimable_cell_id: number;
16
+ board_size: Array<number>;
17
+ cell_size: Array<number>;
18
+ origin_offset: Array<number>;
19
+ initial_square_id: number;
20
+ pool_points: number;
21
+ pool_time: number;
22
+ initial_points: number;
23
+ start_ts: number;
24
+ end_ts: number;
25
+ currency_id: number;
26
+ min_level: number;
27
+ building_id: number;
28
+ building_position: Array<number>;
29
+ zip_file: string;
30
+ sound_tag: string;
31
+ canvas_assets_url: string;
32
+ background_plist: string;
33
+ foregrounds_plists: Array<any>;
34
+ particles_position: Array<number>;
35
+ tutorial_claim_cells: Array<number>;
36
+ }
37
+ */
38
+ exports.fogIslandSchema = zod_1.z.object({
39
+ id: zod_1.z.number(),
40
+ analytics_id: zod_1.z.string(),
41
+ tid_name: zod_1.z.string(),
42
+ tutorial_id: zod_1.z.number(),
43
+ tutorial_claimable_cell_id: zod_1.z.number(),
44
+ board_size: zod_1.z.array(zod_1.z.number()),
45
+ cell_size: zod_1.z.array(zod_1.z.number()),
46
+ origin_offset: zod_1.z.array(zod_1.z.number()),
47
+ initial_square_id: zod_1.z.number(),
48
+ pool_points: zod_1.z.number(),
49
+ pool_time: zod_1.z.number(),
50
+ initial_points: zod_1.z.number(),
51
+ start_ts: zod_1.z.number(),
52
+ end_ts: zod_1.z.number(),
53
+ currency_id: zod_1.z.number(),
54
+ min_level: zod_1.z.number(),
55
+ building_id: zod_1.z.number(),
56
+ building_position: zod_1.z.array(zod_1.z.number()),
57
+ zip_file: zod_1.z.string(),
58
+ sound_tag: zod_1.z.string(),
59
+ canvas_assets_url: zod_1.z.string(),
60
+ background_plist: zod_1.z.string(),
61
+ foregrounds_plists: zod_1.z.array(zod_1.z.any()),
62
+ particles_position: zod_1.z.array(zod_1.z.number()),
63
+ tutorial_claim_cells: zod_1.z.array(zod_1.z.number()),
64
+ // injected props
65
+ square_ids: zod_1.z.array(zod_1.z.number()),
66
+ }).strict().transform(data => {
67
+ return {
68
+ id: data.id,
69
+ availability: {
70
+ from: new Date(data.start_ts * 1000).toISOString(),
71
+ to: new Date(data.end_ts * 1000).toISOString(),
72
+ },
73
+ name_key: data.tid_name,
74
+ board_size: {
75
+ width: data.board_size[0],
76
+ height: data.board_size[1],
77
+ },
78
+ cell_size: {
79
+ width: data.cell_size[0],
80
+ height: data.cell_size[1],
81
+ },
82
+ initial_square_id: data.initial_square_id,
83
+ pool: {
84
+ points: data.pool_points,
85
+ time: data.pool_time,
86
+ },
87
+ initial_points: data.initial_points,
88
+ currency_id: data.currency_id,
89
+ min_level: data.min_level,
90
+ zip_file_name: node_path_1.default.basename(data.zip_file),
91
+ sound_tag: data.sound_tag,
92
+ square_ids: data.square_ids,
93
+ };
94
+ });
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ export declare const fogIslandsRewardSchema: z.ZodPipe<z.ZodObject<{
3
+ id: z.ZodNumber;
4
+ type: z.ZodString;
5
+ island_id: z.ZodNumber;
6
+ reward_id: z.ZodNumber;
7
+ last_piece_cost: z.ZodNumber;
8
+ num_pieces: z.ZodNumber;
9
+ show_new_badge: z.ZodNumber;
10
+ }, z.core.$strict>, z.ZodTransform<{
11
+ id: number;
12
+ type: string;
13
+ dragon_id: number;
14
+ last_piece_cost: number;
15
+ num_pieces: number;
16
+ show_new_badge: boolean;
17
+ }, {
18
+ id: number;
19
+ type: string;
20
+ island_id: number;
21
+ reward_id: number;
22
+ last_piece_cost: number;
23
+ num_pieces: number;
24
+ show_new_badge: number;
25
+ }>>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fogIslandsRewardSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const utils_1 = require("../../../utils");
6
+ exports.fogIslandsRewardSchema = zod_1.z.object({
7
+ id: zod_1.z.number(),
8
+ type: zod_1.z.string(),
9
+ island_id: zod_1.z.number(),
10
+ reward_id: zod_1.z.number(),
11
+ last_piece_cost: zod_1.z.number(),
12
+ num_pieces: zod_1.z.number(),
13
+ show_new_badge: zod_1.z.number(),
14
+ }).strict().transform(data => {
15
+ return {
16
+ id: data.id,
17
+ type: data.type,
18
+ dragon_id: data.reward_id,
19
+ last_piece_cost: data.last_piece_cost,
20
+ num_pieces: data.num_pieces,
21
+ show_new_badge: (0, utils_1.numberToBoolean)(data.show_new_badge),
22
+ };
23
+ });
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ export declare const fogIslandsSquareSchema: z.ZodPipe<z.ZodObject<{
3
+ id: z.ZodNumber;
4
+ type: z.ZodString;
5
+ type_id: z.ZodOptional<z.ZodNumber>;
6
+ highlight: z.ZodNumber;
7
+ x: z.ZodNumber;
8
+ y: z.ZodNumber;
9
+ island_id: z.ZodNumber;
10
+ claim_cost: z.ZodNumber;
11
+ come_back_cost: z.ZodNumber;
12
+ reward_id: z.ZodOptional<z.ZodNumber>;
13
+ }, z.core.$strict>, z.ZodTransform<{
14
+ id: number;
15
+ type: string;
16
+ reward: {
17
+ chest_id: number | undefined;
18
+ type: string;
19
+ } | {
20
+ piece_dragon_id: number | undefined;
21
+ type: string;
22
+ } | null;
23
+ is_highlight: boolean;
24
+ x: number;
25
+ y: number;
26
+ cost: number;
27
+ come_back_cost: number;
28
+ reward_id: number | undefined;
29
+ }, {
30
+ id: number;
31
+ type: string;
32
+ highlight: number;
33
+ x: number;
34
+ y: number;
35
+ island_id: number;
36
+ claim_cost: number;
37
+ come_back_cost: number;
38
+ type_id?: number | undefined;
39
+ reward_id?: number | undefined;
40
+ }>>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fogIslandsSquareSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const utils_1 = require("../../../utils");
6
+ exports.fogIslandsSquareSchema = zod_1.z.object({
7
+ id: zod_1.z.number(),
8
+ type: zod_1.z.string(),
9
+ type_id: zod_1.z.number().optional(),
10
+ highlight: zod_1.z.number(),
11
+ x: zod_1.z.number(),
12
+ y: zod_1.z.number(),
13
+ island_id: zod_1.z.number(),
14
+ claim_cost: zod_1.z.number(),
15
+ come_back_cost: zod_1.z.number(),
16
+ reward_id: zod_1.z.number().optional(),
17
+ }).strict().transform(data => {
18
+ return {
19
+ id: data.id,
20
+ type: data.type,
21
+ reward: data.type === "NONE" || data.type === "STEP" ? null : {
22
+ type: data.type,
23
+ ...(data.type === "CHEST" ? {
24
+ chest_id: data.type_id,
25
+ } : {
26
+ piece_dragon_id: data.type_id,
27
+ })
28
+ },
29
+ is_highlight: (0, utils_1.numberToBoolean)(data.highlight),
30
+ x: data.x,
31
+ y: data.y,
32
+ cost: data.claim_cost,
33
+ come_back_cost: data.come_back_cost,
34
+ reward_id: data.reward_id,
35
+ };
36
+ });
@@ -8,7 +8,7 @@ export declare const gridIslandsDecorationSchema: z.ZodPipe<z.ZodObject<{
8
8
  episode_id: z.ZodNumber;
9
9
  }, z.core.$strict>, z.ZodTransform<{
10
10
  id: number;
11
- filename: string;
11
+ file_name: string;
12
12
  x: number;
13
13
  y: number;
14
14
  }, {
@@ -12,7 +12,7 @@ exports.gridIslandsDecorationSchema = zod_1.z.object({
12
12
  }).strict().transform(data => {
13
13
  return {
14
14
  id: data.id,
15
- filename: data.file,
15
+ file_name: `${data.file}.png`,
16
16
  x: data.x,
17
17
  y: data.y,
18
18
  };
@@ -21,10 +21,10 @@ export declare const gridIslandsSquareSchema: z.ZodPipe<z.ZodObject<{
21
21
  dragon_id: number | undefined;
22
22
  type: string;
23
23
  } | null;
24
- highlight: number;
24
+ is_highlight: boolean;
25
25
  x: number;
26
26
  y: number;
27
- claim_cost: number;
27
+ cost: number;
28
28
  wall: string | undefined;
29
29
  wall_suffix: string | undefined;
30
30
  }, {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gridIslandsSquareSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const utils_1 = require("../../../utils");
5
6
  exports.gridIslandsSquareSchema = zod_1.z.object({
6
7
  id: zod_1.z.number(),
7
8
  type: zod_1.z.string(),
@@ -26,10 +27,10 @@ exports.gridIslandsSquareSchema = zod_1.z.object({
26
27
  dragon_id: data.type_id,
27
28
  })
28
29
  },
29
- highlight: data.highlight,
30
+ is_highlight: (0, utils_1.numberToBoolean)(data.highlight),
30
31
  x: data.x,
31
32
  y: data.y,
32
- claim_cost: data.claim_cost,
33
+ cost: data.claim_cost,
33
34
  wall: data.wall,
34
35
  wall_suffix: data.wall_suffix,
35
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dchighs/dc-config-mapper",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
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",