@dchighs/dc-assets 0.2.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.
@@ -6,6 +6,7 @@ export type ChestSpriteDownloaderOptions = {
6
6
  };
7
7
  export declare class ChestSpriteDownloader extends StaticFileDownloader {
8
8
  readonly url: string;
9
+ readonly basicUrl: string;
9
10
  readonly imageQuality: ChestSpriteQuality;
10
11
  readonly imageName: string;
11
12
  constructor({ imageQuality, imageName }: ChestSpriteDownloaderOptions);
@@ -8,10 +8,16 @@ class ChestSpriteDownloader extends static_file_downloader_1.StaticFileDownloade
8
8
  super();
9
9
  this.imageQuality = imageQuality || dc_core_1.ChestSpriteQuality.Default;
10
10
  this.imageName = imageName;
11
+ this.basicUrl = `https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/chests/ui_basic_${imageName}${imageQuality}.png`;
11
12
  this.url = `https://dci-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/chests/ui_${imageName}${imageQuality}.png`;
12
13
  }
13
14
  async download(filePath) {
14
- return await super.download(this.url, filePath);
15
+ try {
16
+ return await super.download(this.url, filePath);
17
+ }
18
+ catch (error) {
19
+ return await super.download(this.basicUrl, filePath);
20
+ }
15
21
  }
16
22
  }
17
23
  exports.ChestSpriteDownloader = ChestSpriteDownloader;
@@ -1,14 +1,14 @@
1
- import { BuildingSpriteQuality, StaticFileUrlPlatformPrefix } from "@dchighs/dc-core";
1
+ import { DecorationSpriteQuality, StaticFileUrlPlatformPrefix } from "@dchighs/dc-core";
2
2
  import { StaticFileDownloader } from "./static-file-downloader";
3
3
  export type DecorationSpriteDownloaderOptions = {
4
4
  imageName: string;
5
5
  platformPrefix?: StaticFileUrlPlatformPrefix;
6
- imageQuality?: BuildingSpriteQuality;
6
+ imageQuality?: DecorationSpriteQuality;
7
7
  };
8
8
  export declare class DecorationSpriteDownloader extends StaticFileDownloader {
9
9
  readonly url: string;
10
10
  readonly imageName: string;
11
- readonly imageQuality: BuildingSpriteQuality;
11
+ readonly imageQuality: DecorationSpriteQuality;
12
12
  readonly platformPrefix: StaticFileUrlPlatformPrefix;
13
13
  constructor({ imageName, platformPrefix, imageQuality }: DecorationSpriteDownloaderOptions);
14
14
  download(filePath: string): Promise<string>;
@@ -7,7 +7,7 @@ class DecorationSpriteDownloader extends static_file_downloader_1.StaticFileDown
7
7
  constructor({ imageName, platformPrefix, imageQuality }) {
8
8
  super();
9
9
  this.imageName = imageName;
10
- this.imageQuality = imageQuality || dc_core_1.BuildingSpriteQuality.Default;
10
+ this.imageQuality = imageQuality || dc_core_1.DecorationSpriteQuality.Default;
11
11
  this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
12
12
  this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/decorations/ui_${imageName}${this.imageQuality}.png`;
13
13
  }
@@ -0,0 +1,15 @@
1
+ import { HabitatSpriteQuality, StaticFileUrlPlatformPrefix } from "@dchighs/dc-core";
2
+ import { StaticFileDownloader } from "./static-file-downloader";
3
+ export type HabitatSpriteDownloaderOptions = {
4
+ imageName: string;
5
+ platformPrefix?: StaticFileUrlPlatformPrefix;
6
+ imageQuality?: HabitatSpriteQuality;
7
+ };
8
+ export declare class HabitatSpriteDownloader extends StaticFileDownloader {
9
+ readonly url: string;
10
+ readonly imageName: string;
11
+ readonly imageQuality: HabitatSpriteQuality;
12
+ readonly platformPrefix: StaticFileUrlPlatformPrefix;
13
+ constructor({ imageName, platformPrefix, imageQuality }: HabitatSpriteDownloaderOptions);
14
+ download(filePath: string): Promise<string>;
15
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HabitatSpriteDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class HabitatSpriteDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ imageName, platformPrefix, imageQuality }) {
8
+ super();
9
+ this.imageName = imageName;
10
+ this.imageQuality = imageQuality || dc_core_1.HabitatSpriteQuality.Default;
11
+ this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
12
+ this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/habitats/ui_${imageName}${this.imageQuality}.png`;
13
+ }
14
+ async download(filePath) {
15
+ return await super.download(this.url, filePath);
16
+ }
17
+ }
18
+ exports.HabitatSpriteDownloader = HabitatSpriteDownloader;
@@ -0,0 +1,13 @@
1
+ import { StaticFileUrlPlatformPrefix } from "@dchighs/dc-core";
2
+ import { StaticFileDownloader } from "./static-file-downloader";
3
+ export type HabitatThumbnailDownloaderOptions = {
4
+ imageName: string;
5
+ platformPrefix?: StaticFileUrlPlatformPrefix;
6
+ };
7
+ export declare class HabitatThumbnailDownloader extends StaticFileDownloader {
8
+ readonly url: string;
9
+ readonly imageName: string;
10
+ readonly platformPrefix: StaticFileUrlPlatformPrefix;
11
+ constructor({ imageName, platformPrefix }: HabitatThumbnailDownloaderOptions);
12
+ download(filePath: string): Promise<string>;
13
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HabitatThumbnailDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class HabitatThumbnailDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ imageName, platformPrefix }) {
8
+ super();
9
+ this.imageName = imageName;
10
+ this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
11
+ this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/assets/thumbs/${imageName}.jpg`;
12
+ }
13
+ async download(filePath) {
14
+ return await super.download(this.url, filePath);
15
+ }
16
+ }
17
+ exports.HabitatThumbnailDownloader = HabitatThumbnailDownloader;
package/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@ import { BuildingSpriteDownloader, BuildingSpriteDownloaderOptions } from "./bui
9
9
  import { BuildingThumbnailDownloader, BuildingThumbnailDownloaderOptions } from "./building-thumbnail-downloader";
10
10
  import { DecorationSpriteDownloader, DecorationSpriteDownloaderOptions } from "./decoration-sprite-downloader";
11
11
  import { DecorationThumbnailDownloader, DecorationThumbnailDownloaderOptions } from "./decoration-thumbnail-downloader";
12
+ import { HabitatThumbnailDownloader, HabitatThumbnailDownloaderOptions } from "./habitat-thumbnail-downloader";
13
+ import { HabitatSpriteDownloader, HabitatSpriteDownloaderOptions } from "./habitat-sprite-downloader";
12
14
  declare const dcAssets: {
13
15
  dragons: {
14
16
  animations: {
@@ -36,7 +38,8 @@ declare const dcAssets: {
36
38
  thumbnail: (options: DecorationThumbnailDownloaderOptions) => DecorationThumbnailDownloader;
37
39
  };
38
40
  habitats: {
39
- sprite: null;
41
+ sprite: (options: HabitatSpriteDownloaderOptions) => HabitatSpriteDownloader;
42
+ thumbnail: (options: HabitatThumbnailDownloaderOptions) => HabitatThumbnailDownloader;
40
43
  };
41
44
  };
42
45
  export * from "./dragon-flash-animation-downloader";
@@ -50,4 +53,7 @@ export * from "./building-sprite-downloader";
50
53
  export * from "./building-thumbnail-downloader";
51
54
  export * from "./decoration-sprite-downloader";
52
55
  export * from "./decoration-thumbnail-downloader";
56
+ export * from "./dragon-thumbnail-downloader";
57
+ export * from "./habitat-thumbnail-downloader";
58
+ export * from "./habitat-sprite-downloader";
53
59
  export default dcAssets;
package/dist/index.js CHANGED
@@ -25,6 +25,8 @@ const building_sprite_downloader_1 = require("./building-sprite-downloader");
25
25
  const building_thumbnail_downloader_1 = require("./building-thumbnail-downloader");
26
26
  const decoration_sprite_downloader_1 = require("./decoration-sprite-downloader");
27
27
  const decoration_thumbnail_downloader_1 = require("./decoration-thumbnail-downloader");
28
+ const habitat_thumbnail_downloader_1 = require("./habitat-thumbnail-downloader");
29
+ const habitat_sprite_downloader_1 = require("./habitat-sprite-downloader");
28
30
  const dcAssets = {
29
31
  dragons: {
30
32
  animations: {
@@ -41,7 +43,7 @@ const dcAssets = {
41
43
  music: (options) => new music_downloader_1.MusicDownloader(options)
42
44
  },
43
45
  chests: {
44
- sprite: (options) => new chest_sprite_downloader_1.ChestSpriteDownloader(options)
46
+ sprite: (options) => new chest_sprite_downloader_1.ChestSpriteDownloader(options),
45
47
  },
46
48
  buildings: {
47
49
  sprite: (options) => new building_sprite_downloader_1.BuildingSpriteDownloader(options),
@@ -52,7 +54,8 @@ const dcAssets = {
52
54
  thumbnail: (options) => new decoration_thumbnail_downloader_1.DecorationThumbnailDownloader(options)
53
55
  },
54
56
  habitats: {
55
- sprite: null
57
+ sprite: (options) => new habitat_sprite_downloader_1.HabitatSpriteDownloader(options),
58
+ thumbnail: (options) => new habitat_thumbnail_downloader_1.HabitatThumbnailDownloader(options)
56
59
  }
57
60
  };
58
61
  __exportStar(require("./dragon-flash-animation-downloader"), exports);
@@ -66,4 +69,7 @@ __exportStar(require("./building-sprite-downloader"), exports);
66
69
  __exportStar(require("./building-thumbnail-downloader"), exports);
67
70
  __exportStar(require("./decoration-sprite-downloader"), exports);
68
71
  __exportStar(require("./decoration-thumbnail-downloader"), exports);
72
+ __exportStar(require("./dragon-thumbnail-downloader"), exports);
73
+ __exportStar(require("./habitat-thumbnail-downloader"), exports);
74
+ __exportStar(require("./habitat-sprite-downloader"), exports);
69
75
  exports.default = dcAssets;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dchighs/dc-assets",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Library focused on downloading static files from the Dragon City server.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -11,7 +11,8 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "test": "jest",
14
- "build": "tsc"
14
+ "build": "tsc",
15
+ "playground": "ts-node ./playground/index.ts"
15
16
  },
16
17
  "keywords": [
17
18
  "dragon city",
@@ -33,7 +34,7 @@
33
34
  "axios": "^1.13.2"
34
35
  },
35
36
  "peerDependencies": {
36
- "@dchighs/dc-core": "^0.1.0"
37
+ "@dchighs/dc-core": "^0.2.0"
37
38
  },
38
39
  "repository": {
39
40
  "type": "git",