@wwawing/loader 0.0.0-exe-chousa.based-on.3.12.21

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.
Files changed (55) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +34 -0
  3. package/lib/core/decompressor/index.d.ts +6 -0
  4. package/lib/core/decompressor/index.js +31 -0
  5. package/lib/core/extractor/checksum.d.ts +1 -0
  6. package/lib/core/extractor/checksum.js +30 -0
  7. package/lib/core/extractor/constants.d.ts +27 -0
  8. package/lib/core/extractor/constants.js +31 -0
  9. package/lib/core/extractor/index.d.ts +19 -0
  10. package/lib/core/extractor/index.js +186 -0
  11. package/lib/core/index.d.ts +8 -0
  12. package/lib/core/index.js +50 -0
  13. package/lib/core/map-data-client/BaseMapDataClient.d.ts +4 -0
  14. package/lib/core/map-data-client/BaseMapDataClient.js +7 -0
  15. package/lib/core/map-data-client/BrowserMapDataClient.d.ts +8 -0
  16. package/lib/core/map-data-client/BrowserMapDataClient.js +45 -0
  17. package/lib/core/map-data-client/NodeLocalMapDataClient.d.ts +6 -0
  18. package/lib/core/map-data-client/NodeLocalMapDataClient.js +26 -0
  19. package/lib/core/map-data-client/index.d.ts +4 -0
  20. package/lib/core/map-data-client/index.js +9 -0
  21. package/lib/core/text-loader/index.d.ts +13 -0
  22. package/lib/core/text-loader/index.js +147 -0
  23. package/lib/index.d.ts +2 -0
  24. package/lib/index.js +20 -0
  25. package/lib/infra/index.d.ts +98 -0
  26. package/lib/infra/index.js +174 -0
  27. package/lib/infra/util.d.ts +2 -0
  28. package/lib/infra/util.js +16 -0
  29. package/module/core/decompressor/index.d.ts +6 -0
  30. package/module/core/decompressor/index.js +28 -0
  31. package/module/core/extractor/checksum.d.ts +1 -0
  32. package/module/core/extractor/checksum.js +27 -0
  33. package/module/core/extractor/constants.d.ts +27 -0
  34. package/module/core/extractor/constants.js +28 -0
  35. package/module/core/extractor/index.d.ts +19 -0
  36. package/module/core/extractor/index.js +182 -0
  37. package/module/core/index.d.ts +8 -0
  38. package/module/core/index.js +46 -0
  39. package/module/core/map-data-client/BaseMapDataClient.d.ts +4 -0
  40. package/module/core/map-data-client/BaseMapDataClient.js +3 -0
  41. package/module/core/map-data-client/BrowserMapDataClient.d.ts +8 -0
  42. package/module/core/map-data-client/BrowserMapDataClient.js +41 -0
  43. package/module/core/map-data-client/NodeLocalMapDataClient.d.ts +6 -0
  44. package/module/core/map-data-client/NodeLocalMapDataClient.js +19 -0
  45. package/module/core/map-data-client/index.d.ts +4 -0
  46. package/module/core/map-data-client/index.js +4 -0
  47. package/module/core/text-loader/index.d.ts +13 -0
  48. package/module/core/text-loader/index.js +143 -0
  49. package/module/index.d.ts +2 -0
  50. package/module/index.js +2 -0
  51. package/module/infra/index.d.ts +98 -0
  52. package/module/infra/index.js +167 -0
  53. package/module/infra/util.d.ts +2 -0
  54. package/module/infra/util.js +11 -0
  55. package/package.json +73 -0
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextLoader = void 0;
4
+ const infra_1 = require("../../infra");
5
+ class TextLoader {
6
+ constructor(wwaData, compressedMapData, startPosition, eventEmitter) {
7
+ this.wwaData = wwaData;
8
+ this.compressedMapData = compressedMapData;
9
+ this.startPosition = startPosition;
10
+ this.eventEmitter = eventEmitter;
11
+ this.OLDVER_MESSAGE_MAX = 400;
12
+ }
13
+ load() {
14
+ const wwaData = this.wwaData;
15
+ this.currentPos = this.startPosition;
16
+ if (wwaData.version >= 30) {
17
+ wwaData.worldPassword = this.getMessageFromData();
18
+ }
19
+ if (wwaData.version <= 29) {
20
+ wwaData.messageNum = this.OLDVER_MESSAGE_MAX;
21
+ }
22
+ wwaData.message = new Array(wwaData.messageNum);
23
+ for (let i = 0; i < wwaData.message.length; i++) {
24
+ wwaData.message[i] = this.getMessageFromData();
25
+ if (i % 200 === 0) {
26
+ this.eventEmitter.dispatch("progress", {
27
+ current: i,
28
+ total: wwaData.message.length,
29
+ stage: infra_1.LoadStage.MESSAGE
30
+ });
31
+ }
32
+ }
33
+ while (wwaData.messageNum < 10) {
34
+ wwaData.message.push("");
35
+ wwaData.messageNum++;
36
+ }
37
+ this.eventEmitter.dispatch("progress", {
38
+ current: wwaData.message.length,
39
+ total: wwaData.message.length,
40
+ stage: infra_1.LoadStage.MESSAGE
41
+ });
42
+ wwaData.worldName = this.getMessageFromData();
43
+ if (wwaData.version <= 29) {
44
+ wwaData.worldPassword = this.getMessageFromData();
45
+ }
46
+ else {
47
+ this.getMessageFromData();
48
+ }
49
+ if (wwaData.worldPassword === "") {
50
+ wwaData.worldPassNumber = 0;
51
+ }
52
+ else {
53
+ if (wwaData.version >= 29) {
54
+ wwaData.worldPassNumber =
55
+ (parseInt(wwaData.worldPassword) / 10 - 1197) / 17 - 2357;
56
+ }
57
+ else {
58
+ wwaData.worldPassNumber = parseInt(wwaData.worldPassword);
59
+ }
60
+ }
61
+ wwaData.charCGName = this.getMessageFromData();
62
+ wwaData.mapCGName = this.getMessageFromData();
63
+ wwaData.systemMessage = new Array(infra_1.WWAConsts.SYSTEM_MESSAGE_NUM);
64
+ for (let i = 0; i < infra_1.WWAConsts.SYSTEM_MESSAGE_NUM; i++) {
65
+ if (wwaData.version >= 30) {
66
+ wwaData.systemMessage[i] = this.getMessageFromData();
67
+ }
68
+ else {
69
+ wwaData.systemMessage[i] = "";
70
+ }
71
+ }
72
+ wwaData.yesnoImgPosX = infra_1.WWAConsts.IMGPOS_DEFAULT_YESNO_X;
73
+ wwaData.yesnoImgPosY = infra_1.WWAConsts.IMGPOS_DEFAULT_YESNO_Y;
74
+ wwaData.playerImgPosX = infra_1.WWAConsts.IMGPOS_DEFAULT_PLAYER_X;
75
+ wwaData.playerImgPosY = infra_1.WWAConsts.IMGPOS_DEFAULT_PLAYER_Y;
76
+ wwaData.clickableItemSignImgPosX = infra_1.WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_X;
77
+ wwaData.clickableItemSignImgPosY = infra_1.WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_Y;
78
+ wwaData.disableSaveFlag = infra_1.WWAConsts.DEFAULT_DISABLE_SAVE;
79
+ wwaData.isOldMap = infra_1.WWAConsts.DEFAULT_OLDMAP;
80
+ wwaData.isOldMove = wwaData.version < 31;
81
+ wwaData.objectNoCollapseDefaultFlag = infra_1.WWAConsts.DEFAULT_OBJECT_NO_COLLAPSE;
82
+ wwaData.delPlayerFlag = false;
83
+ wwaData.bgm = 0;
84
+ wwaData.effectCoords = [];
85
+ wwaData.effectWaits = 0;
86
+ wwaData.imgStatusEnergyX = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_X + infra_1.WWAConsts.IMGRELPOS_ENERGY_ICON_X;
87
+ wwaData.imgStatusEnergyY = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_Y;
88
+ wwaData.imgStatusStrengthX = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_X + infra_1.WWAConsts.IMGRELPOS_STRENGTH_ICON_X;
89
+ wwaData.imgStatusStrengthY = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_Y;
90
+ wwaData.imgStatusDefenceX = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_X + infra_1.WWAConsts.IMGRELPOS_DEFENCE_ICON_X;
91
+ wwaData.imgStatusDefenceY = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_Y;
92
+ wwaData.imgStatusGoldX = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_X + infra_1.WWAConsts.IMGRELPOS_GOLD_ICON_X;
93
+ wwaData.imgStatusGoldY = infra_1.WWAConsts.IMGPOS_DEFAULT_STATUS_Y;
94
+ wwaData.imgWideCellX = infra_1.WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_X;
95
+ wwaData.imgWideCellY = infra_1.WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_Y;
96
+ wwaData.imgItemboxX = infra_1.WWAConsts.IMGPOS_DEFAULT_ITEMBOX_X;
97
+ wwaData.imgItemboxY = infra_1.WWAConsts.IMGPOS_DEFAULT_ITEMBOX_Y;
98
+ wwaData.imgFrameX = infra_1.WWAConsts.IMGPOS_DEFAULT_FRAME_X;
99
+ wwaData.imgFrameY = infra_1.WWAConsts.IMGPOS_DEFAULT_FRAME_Y;
100
+ wwaData.imgBattleEffectX = infra_1.WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_X;
101
+ wwaData.imgBattleEffectY = infra_1.WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_Y;
102
+ wwaData.imgClickX = 0;
103
+ wwaData.imgClickY = 0;
104
+ wwaData.frameColorR = infra_1.WWAConsts.DEFAULT_FRAME_COLOR_R;
105
+ wwaData.frameColorG = infra_1.WWAConsts.DEFAULT_FRAME_COLOR_G;
106
+ wwaData.frameColorB = infra_1.WWAConsts.DEFAULT_FRAME_COLOR_B;
107
+ wwaData.frameOutColorR = infra_1.WWAConsts.DEFAULT_FRAMEOUT_COLOR_R;
108
+ wwaData.frameOutColorG = infra_1.WWAConsts.DEFAULT_FRAMEOUT_COLOR_G;
109
+ wwaData.frameOutColorB = infra_1.WWAConsts.DEFAULT_FRAMEOUT_COLOR_B;
110
+ wwaData.fontColorR = infra_1.WWAConsts.DEFAULT_STR_COLOR_R;
111
+ wwaData.fontColorG = infra_1.WWAConsts.DEFAULT_STR_COLOR_G;
112
+ wwaData.fontColorB = infra_1.WWAConsts.DEFAULT_STR_COLOR_B;
113
+ wwaData.statusColorR = infra_1.WWAConsts.DEFAULT_STATUS_COLOR_R;
114
+ wwaData.statusColorG = infra_1.WWAConsts.DEFAULT_STATUS_COLOR_G;
115
+ wwaData.statusColorB = infra_1.WWAConsts.DEFAULT_STATUS_COLOR_B;
116
+ wwaData.moves = infra_1.WWAConsts.DEFAULT_MOVES;
117
+ wwaData.gameSpeedIndex = infra_1.WWAConsts.DEFAULT_SPEED_INDEX;
118
+ wwaData.permitChangeGameSpeed = true;
119
+ wwaData.userVar = new Array(infra_1.WWAConsts.USER_VAR_NUM);
120
+ for (let i = 0; i < infra_1.WWAConsts.USER_VAR_NUM; i++) {
121
+ wwaData.userVar[i] = 0;
122
+ }
123
+ wwaData.playTime = 0;
124
+ wwaData.isVisibleStatusEnergy = true;
125
+ wwaData.isVisibleStatusStrength = true;
126
+ wwaData.isVisibleStatusDefence = true;
127
+ wwaData.isVisibleStatusGold = true;
128
+ wwaData.gameOverPolicy = "default";
129
+ wwaData.bgmDelayDurationMs = 0;
130
+ return wwaData;
131
+ }
132
+ getMessageFromData() {
133
+ let str = "";
134
+ let i = 0;
135
+ for (i = 0; i < 1500; i++) {
136
+ if (this.compressedMapData[this.currentPos + i * 2] == 0 &&
137
+ this.compressedMapData[this.currentPos + i * 2 + 1] == 0) {
138
+ break;
139
+ }
140
+ str += String.fromCharCode((this.compressedMapData[this.currentPos + i * 2 + 1] << 8) +
141
+ this.compressedMapData[this.currentPos + i * 2]);
142
+ }
143
+ this.currentPos += i * 2 + 2;
144
+ return str;
145
+ }
146
+ }
147
+ exports.TextLoader = TextLoader;
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { WWALoader } from "./core";
2
+ export * from "./infra";
package/lib/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.WWALoader = void 0;
18
+ var core_1 = require("./core");
19
+ Object.defineProperty(exports, "WWALoader", { enumerable: true, get: function () { return core_1.WWALoader; } });
20
+ __exportStar(require("./infra"), exports);
@@ -0,0 +1,98 @@
1
+ import { WWAData } from "@wwawing/common-interface";
2
+ import { IEventEmitter } from "@wwawing/event-emitter";
3
+ export declare class WWAConsts {
4
+ static ITEMBOX_SIZE: number;
5
+ static MAP_ATR_MAX: number;
6
+ static OBJ_ATR_MAX: number;
7
+ static OLD_MAP_ATR_MAX: number;
8
+ static OLD_OBJ_ATR_MAX: number;
9
+ static ATR_CROP1: number;
10
+ static ATR_CROP2: number;
11
+ static ATR_TYPE: number;
12
+ static ATR_JUMP_X: number;
13
+ static ATR_JUMP_Y: number;
14
+ static MAP_LOCALGATE: number;
15
+ static OBJECT_LOCALGATE: number;
16
+ static SYSTEM_MESSAGE_NUM: number;
17
+ static IMGPOS_DEFAULT_YESNO_X: number;
18
+ static IMGPOS_DEFAULT_YESNO_Y: number;
19
+ static IMGPOS_DEFAULT_PLAYER_X: number;
20
+ static IMGPOS_DEFAULT_PLAYER_Y: number;
21
+ static IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_X: number;
22
+ static IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_Y: number;
23
+ static IMGPOS_DEFAULT_STATUS_X: number;
24
+ static IMGPOS_DEFAULT_STATUS_Y: number;
25
+ static IMGRELPOS_ENERGY_ICON_X: number;
26
+ static IMGRELPOS_STRENGTH_ICON_X: number;
27
+ static IMGRELPOS_DEFENCE_ICON_X: number;
28
+ static IMGRELPOS_GOLD_ICON_X: number;
29
+ static IMGPOS_DEFAULT_WIDE_CELL_X: number;
30
+ static IMGPOS_DEFAULT_WIDE_CELL_Y: number;
31
+ static IMGPOS_DEFAULT_ITEMBOX_X: number;
32
+ static IMGPOS_DEFAULT_ITEMBOX_Y: number;
33
+ static IMGPOS_DEFAULT_FRAME_X: number;
34
+ static IMGPOS_DEFAULT_FRAME_Y: number;
35
+ static IMGPOS_DEFAULT_BATTLE_EFFECT_X: number;
36
+ static IMGPOS_DEFAULT_BATTLE_EFFECT_Y: number;
37
+ static DEFAULT_DISABLE_SAVE: boolean;
38
+ static DEFAULT_OLDMAP: boolean;
39
+ static DEFAULT_OBJECT_NO_COLLAPSE: boolean;
40
+ static DEFAULT_FRAME_COLOR_R: number;
41
+ static DEFAULT_FRAME_COLOR_G: number;
42
+ static DEFAULT_FRAME_COLOR_B: number;
43
+ static DEFAULT_FRAMEOUT_COLOR_R: number;
44
+ static DEFAULT_FRAMEOUT_COLOR_G: number;
45
+ static DEFAULT_FRAMEOUT_COLOR_B: number;
46
+ static DEFAULT_STR_COLOR_R: number;
47
+ static DEFAULT_STR_COLOR_G: number;
48
+ static DEFAULT_STR_COLOR_B: number;
49
+ static DEFAULT_STATUS_COLOR_R: number;
50
+ static DEFAULT_STATUS_COLOR_G: number;
51
+ static DEFAULT_STATUS_COLOR_B: number;
52
+ static DEFAULT_MOVES: number;
53
+ static DEFAULT_SPEED_INDEX: number;
54
+ static USER_VAR_NUM: number;
55
+ }
56
+ export declare class LoaderError implements Error {
57
+ name: string;
58
+ message: string;
59
+ }
60
+ export declare class LoaderProgress {
61
+ current: number;
62
+ total: number;
63
+ stage: LoadStage;
64
+ }
65
+ export declare enum PartsType {
66
+ MAP = 1,
67
+ OBJECT = 0
68
+ }
69
+ export declare enum LoadStage {
70
+ INIT = 0,
71
+ MAP_LOAD = 1,
72
+ OBJ_LOAD = 2,
73
+ MAP_ATTR = 3,
74
+ OBJ_ATTR = 4,
75
+ RAND_PARTS = 5,
76
+ MESSAGE = 6
77
+ }
78
+ export declare function createDefaultWWAData(): WWAData;
79
+ export interface Progress {
80
+ current: number;
81
+ total: number;
82
+ stage: LoadStage;
83
+ }
84
+ export interface LoaderError {
85
+ name: string;
86
+ message: string;
87
+ }
88
+ export interface WWALoaderEventEmitter extends IEventEmitter {
89
+ dispatch(eventName: "mapData", data: WWAData): void;
90
+ dispatch(eventName: "progress", data: Progress): void;
91
+ dispatch(eventName: "error", data: LoaderError): void;
92
+ addListener(eventName: "mapData", callback: (data: WWAData) => any): (data: WWAData) => any;
93
+ addListener(eventName: "progress", callback: (data: Progress) => any): (data: Progress) => any;
94
+ addListener(eventName: "error", callback: (data: LoaderError) => any): (data: LoaderError) => any;
95
+ removeListener(eventName: "mapData", callback: (...arg: any[]) => any): void;
96
+ removeListener(eventName: "progress", callback: (...arg: any[]) => any): void;
97
+ removeListener(eventName: "error", callback: (...arg: any[]) => any): void;
98
+ }
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoadStage = exports.PartsType = exports.LoaderProgress = exports.LoaderError = exports.WWAConsts = void 0;
4
+ exports.createDefaultWWAData = createDefaultWWAData;
5
+ class WWAConsts {
6
+ }
7
+ exports.WWAConsts = WWAConsts;
8
+ WWAConsts.ITEMBOX_SIZE = 12;
9
+ WWAConsts.MAP_ATR_MAX = 60;
10
+ WWAConsts.OBJ_ATR_MAX = 60;
11
+ WWAConsts.OLD_MAP_ATR_MAX = 40;
12
+ WWAConsts.OLD_OBJ_ATR_MAX = 40;
13
+ WWAConsts.ATR_CROP1 = 1;
14
+ WWAConsts.ATR_CROP2 = 2;
15
+ WWAConsts.ATR_TYPE = 3;
16
+ WWAConsts.ATR_JUMP_X = 16;
17
+ WWAConsts.ATR_JUMP_Y = 17;
18
+ WWAConsts.MAP_LOCALGATE = 2;
19
+ WWAConsts.OBJECT_LOCALGATE = 18;
20
+ WWAConsts.SYSTEM_MESSAGE_NUM = 20;
21
+ WWAConsts.IMGPOS_DEFAULT_YESNO_X = 3;
22
+ WWAConsts.IMGPOS_DEFAULT_YESNO_Y = 1;
23
+ WWAConsts.IMGPOS_DEFAULT_PLAYER_X = 2;
24
+ WWAConsts.IMGPOS_DEFAULT_PLAYER_Y = 0;
25
+ WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_X = 0;
26
+ WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_Y = 0;
27
+ WWAConsts.IMGPOS_DEFAULT_STATUS_X = 3;
28
+ WWAConsts.IMGPOS_DEFAULT_STATUS_Y = 2;
29
+ WWAConsts.IMGRELPOS_ENERGY_ICON_X = 0;
30
+ WWAConsts.IMGRELPOS_STRENGTH_ICON_X = 1;
31
+ WWAConsts.IMGRELPOS_DEFENCE_ICON_X = 2;
32
+ WWAConsts.IMGRELPOS_GOLD_ICON_X = 3;
33
+ WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_X = 4;
34
+ WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_Y = 3;
35
+ WWAConsts.IMGPOS_DEFAULT_ITEMBOX_X = 1;
36
+ WWAConsts.IMGPOS_DEFAULT_ITEMBOX_Y = 2;
37
+ WWAConsts.IMGPOS_DEFAULT_FRAME_X = 0;
38
+ WWAConsts.IMGPOS_DEFAULT_FRAME_Y = 1;
39
+ WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_X = 3;
40
+ WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_Y = 3;
41
+ WWAConsts.DEFAULT_DISABLE_SAVE = false;
42
+ WWAConsts.DEFAULT_OLDMAP = false;
43
+ WWAConsts.DEFAULT_OBJECT_NO_COLLAPSE = false;
44
+ WWAConsts.DEFAULT_FRAME_COLOR_R = 0xff;
45
+ WWAConsts.DEFAULT_FRAME_COLOR_G = 0xff;
46
+ WWAConsts.DEFAULT_FRAME_COLOR_B = 0xff;
47
+ WWAConsts.DEFAULT_FRAMEOUT_COLOR_R = 0x60;
48
+ WWAConsts.DEFAULT_FRAMEOUT_COLOR_G = 0x60;
49
+ WWAConsts.DEFAULT_FRAMEOUT_COLOR_B = 0x60;
50
+ WWAConsts.DEFAULT_STR_COLOR_R = 0x0;
51
+ WWAConsts.DEFAULT_STR_COLOR_G = 0x0;
52
+ WWAConsts.DEFAULT_STR_COLOR_B = 0x0;
53
+ WWAConsts.DEFAULT_STATUS_COLOR_R = 0x0;
54
+ WWAConsts.DEFAULT_STATUS_COLOR_G = 0x0;
55
+ WWAConsts.DEFAULT_STATUS_COLOR_B = 0x0;
56
+ WWAConsts.DEFAULT_MOVES = 0;
57
+ WWAConsts.DEFAULT_SPEED_INDEX = 3;
58
+ WWAConsts.USER_VAR_NUM = 256;
59
+ class LoaderError {
60
+ }
61
+ exports.LoaderError = LoaderError;
62
+ class LoaderProgress {
63
+ }
64
+ exports.LoaderProgress = LoaderProgress;
65
+ var PartsType;
66
+ (function (PartsType) {
67
+ PartsType[PartsType["MAP"] = 1] = "MAP";
68
+ PartsType[PartsType["OBJECT"] = 0] = "OBJECT";
69
+ })(PartsType || (exports.PartsType = PartsType = {}));
70
+ var LoadStage;
71
+ (function (LoadStage) {
72
+ LoadStage[LoadStage["INIT"] = 0] = "INIT";
73
+ LoadStage[LoadStage["MAP_LOAD"] = 1] = "MAP_LOAD";
74
+ LoadStage[LoadStage["OBJ_LOAD"] = 2] = "OBJ_LOAD";
75
+ LoadStage[LoadStage["MAP_ATTR"] = 3] = "MAP_ATTR";
76
+ LoadStage[LoadStage["OBJ_ATTR"] = 4] = "OBJ_ATTR";
77
+ LoadStage[LoadStage["RAND_PARTS"] = 5] = "RAND_PARTS";
78
+ LoadStage[LoadStage["MESSAGE"] = 6] = "MESSAGE";
79
+ })(LoadStage || (exports.LoadStage = LoadStage = {}));
80
+ function createDefaultWWAData() {
81
+ return {
82
+ version: undefined,
83
+ gameoverX: undefined,
84
+ gameoverY: undefined,
85
+ playerX: undefined,
86
+ playerY: undefined,
87
+ mapPartsMax: undefined,
88
+ objPartsMax: undefined,
89
+ isOldMap: undefined,
90
+ isOldMove: undefined,
91
+ statusEnergyMax: undefined,
92
+ statusEnergy: undefined,
93
+ statusStrength: undefined,
94
+ statusDefence: undefined,
95
+ statusGold: undefined,
96
+ itemBox: undefined,
97
+ mapWidth: undefined,
98
+ messageNum: undefined,
99
+ map: undefined,
100
+ mapObject: undefined,
101
+ mapCompressed: undefined,
102
+ mapObjectCompressed: undefined,
103
+ mapAttribute: undefined,
104
+ objectAttribute: undefined,
105
+ worldPassword: undefined,
106
+ message: undefined,
107
+ worldName: undefined,
108
+ worldPassNumber: undefined,
109
+ charCGName: undefined,
110
+ mapCGName: undefined,
111
+ systemMessage: undefined,
112
+ moves: undefined,
113
+ yesnoImgPosX: undefined,
114
+ yesnoImgPosY: undefined,
115
+ playerImgPosX: undefined,
116
+ playerImgPosY: undefined,
117
+ clickableItemSignImgPosX: undefined,
118
+ clickableItemSignImgPosY: undefined,
119
+ disableSaveFlag: undefined,
120
+ compatibleForOldMapFlag: undefined,
121
+ objectNoCollapseDefaultFlag: undefined,
122
+ delPlayerFlag: undefined,
123
+ bgm: undefined,
124
+ effectCoords: undefined,
125
+ effectWaits: undefined,
126
+ imgStatusEnergyX: undefined,
127
+ imgStatusEnergyY: undefined,
128
+ imgStatusStrengthX: undefined,
129
+ imgStatusStrengthY: undefined,
130
+ imgStatusDefenceX: undefined,
131
+ imgStatusDefenceY: undefined,
132
+ imgStatusGoldX: undefined,
133
+ imgStatusGoldY: undefined,
134
+ imgWideCellX: undefined,
135
+ imgWideCellY: undefined,
136
+ imgItemboxX: undefined,
137
+ imgItemboxY: undefined,
138
+ imgFrameX: undefined,
139
+ imgFrameY: undefined,
140
+ imgBattleEffectX: undefined,
141
+ imgBattleEffectY: undefined,
142
+ imgClickX: undefined,
143
+ imgClickY: undefined,
144
+ frameColorR: undefined,
145
+ frameColorG: undefined,
146
+ frameColorB: undefined,
147
+ frameOutColorR: undefined,
148
+ frameOutColorG: undefined,
149
+ frameOutColorB: undefined,
150
+ fontColorR: undefined,
151
+ fontColorG: undefined,
152
+ fontColorB: undefined,
153
+ statusColorR: undefined,
154
+ statusColorG: undefined,
155
+ statusColorB: undefined,
156
+ checkOriginalMapString: undefined,
157
+ checkString: undefined,
158
+ isItemEffectEnabled: undefined,
159
+ frameCount: undefined,
160
+ gamePadButtonItemTable: undefined,
161
+ userVar: undefined,
162
+ permitChangeGameSpeed: undefined,
163
+ gameSpeedIndex: undefined,
164
+ playTime: undefined,
165
+ isVisibleStatusEnergy: undefined,
166
+ isVisibleStatusStrength: undefined,
167
+ isVisibleStatusDefence: undefined,
168
+ isVisibleStatusGold: undefined,
169
+ isGameOverDisabled: undefined,
170
+ gameOverPolicy: "default",
171
+ bgmDelayDurationMs: undefined,
172
+ customSystemMessages: {},
173
+ };
174
+ }
@@ -0,0 +1,2 @@
1
+ export declare const new2DArray: (size1: number, size2: number) => number[][];
2
+ export declare const signedByte: (b: number) => number;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signedByte = exports.new2DArray = void 0;
4
+ const new2DArray = (size1, size2) => {
5
+ const arr = new Array(size1);
6
+ for (let i = 0; i < arr.length; i++) {
7
+ arr[i] = new Array(size2);
8
+ }
9
+ return arr;
10
+ };
11
+ exports.new2DArray = new2DArray;
12
+ const signedByte = (b) => {
13
+ b = b % 0x100;
14
+ return b >= 0x80 ? b - 0x100 : b;
15
+ };
16
+ exports.signedByte = signedByte;
@@ -0,0 +1,6 @@
1
+ export interface DecompressResult {
2
+ byteMapData: Uint8Array;
3
+ byteMapLength: number;
4
+ compressedEndPosition: number;
5
+ }
6
+ export declare function decompressMapData(srcData: Uint8Array): DecompressResult;
@@ -0,0 +1,28 @@
1
+ const MEM_BLOCK = 65000;
2
+ const EXT_LAST_PADDING = 3;
3
+ export function decompressMapData(srcData) {
4
+ let destData = new Uint8Array(srcData.length);
5
+ let srcCounter, destCounter;
6
+ for (srcCounter = 0, destCounter = 0; srcCounter < srcData.length; srcCounter++) {
7
+ if (srcData[srcCounter] === 0 &&
8
+ srcData[srcCounter + 1] === 0 &&
9
+ srcData[srcCounter + 2] === 0) {
10
+ break;
11
+ }
12
+ destData[destCounter++] = srcData[srcCounter];
13
+ if (srcData[srcCounter] === srcData[srcCounter + 1]) {
14
+ const maxim = srcData[srcCounter + 2];
15
+ for (let i = 0; i < maxim; i++) {
16
+ destData[destCounter++] = srcData[srcCounter];
17
+ }
18
+ srcCounter += 2;
19
+ }
20
+ if (destCounter + 255 >= destData.length) {
21
+ var newDestData = new Uint8Array(destData.length + MEM_BLOCK);
22
+ newDestData.set(destData);
23
+ destData = newDestData;
24
+ }
25
+ }
26
+ console.log("EXTRACT DATA = " + destCounter + " " + srcCounter);
27
+ return { byteMapData: destData, byteMapLength: destCounter, compressedEndPosition: srcCounter + EXT_LAST_PADDING };
28
+ }
@@ -0,0 +1 @@
1
+ export declare function checkMapDataBroken(mapData: Uint8Array, dataLength: number): void;
@@ -0,0 +1,27 @@
1
+ import { signedByte } from "../../infra/util";
2
+ import { BytePosition } from "./constants";
3
+ function calculateCorrectCheckSum(mapData) {
4
+ return mapData[BytePosition.CHECK] + mapData[BytePosition.CHECK + 1] * 0x100;
5
+ }
6
+ function calculateByteSum(mapData, dataLength) {
7
+ let sum = 0;
8
+ if (mapData[BytePosition.VERSION] >= 29) {
9
+ for (let i = 2; i < dataLength; i++) {
10
+ sum += signedByte(mapData[i]) * (i % 8 + 1);
11
+ }
12
+ sum = (sum % 0x10000) & 0xffff;
13
+ }
14
+ return sum;
15
+ }
16
+ export function checkMapDataBroken(mapData, dataLength) {
17
+ const correctCheckSum = calculateCorrectCheckSum(mapData);
18
+ const sum = calculateByteSum(mapData, dataLength);
19
+ if (correctCheckSum !== sum) {
20
+ throw new Error("マップデータが壊れているようです。\n チェックサムの値は" +
21
+ correctCheckSum +
22
+ "ですが、" +
23
+ "実際の和は" +
24
+ sum +
25
+ "でした。");
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ export declare enum BytePosition {
2
+ CHECK = 0,
3
+ VERSION = 2,
4
+ OLD_MAP_COUNT = 3,
5
+ OLD_OBJ_COUNT = 4,
6
+ OLD_PLAYER_X = 5,
7
+ OLD_PLAYER_Y = 6,
8
+ STATUS_ENERGY = 10,
9
+ STATUS_STRENGTH = 12,
10
+ STATUS_DEFENCE = 14,
11
+ STATUS_GOLD = 16,
12
+ OLD_GAMEOVER_X = 18,
13
+ OLD_GAMEOVER_Y = 19,
14
+ OLD_ITEMBOX_TOP = 20,
15
+ STATUS_ENERGY_MAX = 32,
16
+ MAP_COUNT = 34,
17
+ OBJ_COUNT = 36,
18
+ PLAYER_X = 38,
19
+ PLAYER_Y = 40,
20
+ GAMEOVER_X = 42,
21
+ GAMEOVER_Y = 44,
22
+ MAP_SIZE = 46,
23
+ MESSAGE_NUM = 48,
24
+ ITEMBOX_TOP = 60,
25
+ MAPDATA_TOP = 90,
26
+ OLD_MAPDATA_TOP = 100
27
+ }
@@ -0,0 +1,28 @@
1
+ export var BytePosition;
2
+ (function (BytePosition) {
3
+ BytePosition[BytePosition["CHECK"] = 0] = "CHECK";
4
+ BytePosition[BytePosition["VERSION"] = 2] = "VERSION";
5
+ BytePosition[BytePosition["OLD_MAP_COUNT"] = 3] = "OLD_MAP_COUNT";
6
+ BytePosition[BytePosition["OLD_OBJ_COUNT"] = 4] = "OLD_OBJ_COUNT";
7
+ BytePosition[BytePosition["OLD_PLAYER_X"] = 5] = "OLD_PLAYER_X";
8
+ BytePosition[BytePosition["OLD_PLAYER_Y"] = 6] = "OLD_PLAYER_Y";
9
+ BytePosition[BytePosition["STATUS_ENERGY"] = 10] = "STATUS_ENERGY";
10
+ BytePosition[BytePosition["STATUS_STRENGTH"] = 12] = "STATUS_STRENGTH";
11
+ BytePosition[BytePosition["STATUS_DEFENCE"] = 14] = "STATUS_DEFENCE";
12
+ BytePosition[BytePosition["STATUS_GOLD"] = 16] = "STATUS_GOLD";
13
+ BytePosition[BytePosition["OLD_GAMEOVER_X"] = 18] = "OLD_GAMEOVER_X";
14
+ BytePosition[BytePosition["OLD_GAMEOVER_Y"] = 19] = "OLD_GAMEOVER_Y";
15
+ BytePosition[BytePosition["OLD_ITEMBOX_TOP"] = 20] = "OLD_ITEMBOX_TOP";
16
+ BytePosition[BytePosition["STATUS_ENERGY_MAX"] = 32] = "STATUS_ENERGY_MAX";
17
+ BytePosition[BytePosition["MAP_COUNT"] = 34] = "MAP_COUNT";
18
+ BytePosition[BytePosition["OBJ_COUNT"] = 36] = "OBJ_COUNT";
19
+ BytePosition[BytePosition["PLAYER_X"] = 38] = "PLAYER_X";
20
+ BytePosition[BytePosition["PLAYER_Y"] = 40] = "PLAYER_Y";
21
+ BytePosition[BytePosition["GAMEOVER_X"] = 42] = "GAMEOVER_X";
22
+ BytePosition[BytePosition["GAMEOVER_Y"] = 44] = "GAMEOVER_Y";
23
+ BytePosition[BytePosition["MAP_SIZE"] = 46] = "MAP_SIZE";
24
+ BytePosition[BytePosition["MESSAGE_NUM"] = 48] = "MESSAGE_NUM";
25
+ BytePosition[BytePosition["ITEMBOX_TOP"] = 60] = "ITEMBOX_TOP";
26
+ BytePosition[BytePosition["MAPDATA_TOP"] = 90] = "MAPDATA_TOP";
27
+ BytePosition[BytePosition["OLD_MAPDATA_TOP"] = 100] = "OLD_MAPDATA_TOP";
28
+ })(BytePosition || (BytePosition = {}));
@@ -0,0 +1,19 @@
1
+ import { WWAData } from "@wwawing/common-interface";
2
+ import { WWALoaderEventEmitter } from "../../infra";
3
+ export declare class WWADataExtractor {
4
+ private byteMapData;
5
+ private eventEmitter;
6
+ private wwaData;
7
+ private currentPosition;
8
+ constructor(byteMapData: Uint8Array, byteMapLength: number, eventEmitter: WWALoaderEventEmitter);
9
+ extractAllData(): WWAData;
10
+ private _convertAttributeV2toV3;
11
+ private _get1ByteNumber;
12
+ private _get2BytesNumber;
13
+ private _extractInitialParameters;
14
+ private _extractInitialItemData;
15
+ private _getFieldDataFromBits;
16
+ private _getPartsDataFromBits;
17
+ private _replaceAllRandomObjects;
18
+ private emitProgress;
19
+ }