wc3maptranslator 4.0.0 → 4.0.2

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 (118) hide show
  1. package/LICENSE.md +23 -23
  2. package/dist/AngleConverter.d.ts +3 -0
  3. package/dist/AngleConverter.d.ts.map +1 -0
  4. package/dist/AngleConverter.js +12 -0
  5. package/dist/AngleConverter.js.map +1 -0
  6. package/dist/CommonInterfaces.d.ts +17 -0
  7. package/dist/CommonInterfaces.d.ts.map +1 -0
  8. package/dist/CommonInterfaces.js +3 -0
  9. package/dist/CommonInterfaces.js.map +1 -0
  10. package/dist/HexBuffer.d.ts +15 -0
  11. package/dist/HexBuffer.d.ts.map +1 -0
  12. package/{lib/HexBuffer.ts → dist/HexBuffer.js} +71 -81
  13. package/dist/HexBuffer.js.map +1 -0
  14. package/dist/W3Buffer.d.ts +14 -0
  15. package/dist/W3Buffer.d.ts.map +1 -0
  16. package/{lib/W3Buffer.ts → dist/W3Buffer.js} +63 -69
  17. package/dist/W3Buffer.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/{index.js → dist/index.js} +1 -1
  21. package/dist/index.js.map +1 -0
  22. package/dist/translators/CamerasTranslator.d.ts +23 -0
  23. package/dist/translators/CamerasTranslator.d.ts.map +1 -0
  24. package/{lib/translators/CamerasTranslator.ts → dist/translators/CamerasTranslator.js} +76 -101
  25. package/dist/translators/CamerasTranslator.js.map +1 -0
  26. package/dist/translators/DoodadsTranslator.d.ts +23 -0
  27. package/dist/translators/DoodadsTranslator.d.ts.map +1 -0
  28. package/{lib/translators/DoodadsTranslator.ts → dist/translators/DoodadsTranslator.js} +146 -178
  29. package/dist/translators/DoodadsTranslator.js.map +1 -0
  30. package/dist/translators/ImportsTranslator.d.ts +16 -0
  31. package/dist/translators/ImportsTranslator.d.ts.map +1 -0
  32. package/{lib/translators/ImportsTranslator.ts → dist/translators/ImportsTranslator.js} +62 -78
  33. package/dist/translators/ImportsTranslator.js.map +1 -0
  34. package/dist/translators/InfoTranslator.d.ts +124 -0
  35. package/dist/translators/InfoTranslator.d.ts.map +1 -0
  36. package/{lib/translators/InfoTranslator.ts → dist/translators/InfoTranslator.js} +422 -584
  37. package/dist/translators/InfoTranslator.js.map +1 -0
  38. package/dist/translators/ObjectsTranslator.d.ts +23 -0
  39. package/dist/translators/ObjectsTranslator.d.ts.map +1 -0
  40. package/{lib/translators/ObjectsTranslator.ts → dist/translators/ObjectsTranslator.js} +91 -125
  41. package/dist/translators/ObjectsTranslator.js.map +1 -0
  42. package/dist/translators/RegionsTranslator.d.ts +22 -0
  43. package/dist/translators/RegionsTranslator.d.ts.map +1 -0
  44. package/{lib/translators/RegionsTranslator.ts → dist/translators/RegionsTranslator.js} +96 -123
  45. package/dist/translators/RegionsTranslator.js.map +1 -0
  46. package/dist/translators/SoundsTranslator.d.ts +35 -0
  47. package/dist/translators/SoundsTranslator.d.ts.map +1 -0
  48. package/{lib/translators/SoundsTranslator.ts → dist/translators/SoundsTranslator.js} +183 -237
  49. package/dist/translators/SoundsTranslator.js.map +1 -0
  50. package/dist/translators/StringsTranslator.d.ts +7 -0
  51. package/dist/translators/StringsTranslator.d.ts.map +1 -0
  52. package/{lib/translators/StringsTranslator.ts → dist/translators/StringsTranslator.js} +44 -49
  53. package/dist/translators/StringsTranslator.js.map +1 -0
  54. package/dist/translators/TerrainTranslator.d.ts +33 -0
  55. package/dist/translators/TerrainTranslator.d.ts.map +1 -0
  56. package/{lib/translators/TerrainTranslator.ts → dist/translators/TerrainTranslator.js} +221 -276
  57. package/dist/translators/TerrainTranslator.js.map +1 -0
  58. package/dist/translators/UnitsTranslator.d.ts +40 -0
  59. package/dist/translators/UnitsTranslator.d.ts.map +1 -0
  60. package/{lib/translators/UnitsTranslator.ts → dist/translators/UnitsTranslator.js} +199 -261
  61. package/dist/translators/UnitsTranslator.js.map +1 -0
  62. package/{lib/translators/index.ts → dist/translators/index.d.ts} +11 -10
  63. package/dist/translators/index.d.ts.map +1 -0
  64. package/dist/translators/index.js +23 -0
  65. package/dist/translators/index.js.map +1 -0
  66. package/package.json +4 -2
  67. package/.codeclimate.yml +0 -12
  68. package/.editorconfig +0 -8
  69. package/.eslintignore +0 -5
  70. package/.eslintrc +0 -55
  71. package/.github/workflows/codeql-analysis.yml +0 -54
  72. package/.nycrc +0 -18
  73. package/.travis.yml +0 -23
  74. package/CHANGELOG.md +0 -73
  75. package/index.ts +0 -14
  76. package/lib/AngleConverter.ts +0 -7
  77. package/lib/CommonInterfaces.ts +0 -22
  78. package/test/.mocharc.json +0 -4
  79. package/test/AngleConverterTest.ts +0 -18
  80. package/test/HexBufferTest.ts +0 -170
  81. package/test/TranslatorReversion.ts +0 -218
  82. package/test/W3BufferTest.ts +0 -50
  83. package/test/data/cameras.json +0 -16
  84. package/test/data/doodads.json +0 -2730
  85. package/test/data/imports.json +0 -386
  86. package/test/data/info.json +0 -250
  87. package/test/data/obj-abilities.json +0 -4892
  88. package/test/data/obj-buffs.json +0 -38
  89. package/test/data/obj-destructables.json +0 -31
  90. package/test/data/obj-doodads.json +0 -38
  91. package/test/data/obj-items.json +0 -31
  92. package/test/data/obj-units.json +0 -40
  93. package/test/data/obj-upgrades.json +0 -38
  94. package/test/data/regions.json +0 -206
  95. package/test/data/sounds.json +0 -50
  96. package/test/data/strings.json +0 -115
  97. package/test/data/terrain.json +0 -1
  98. package/test/data/units.json +0 -452
  99. package/test/data/war3map.doo +0 -0
  100. package/test/data/war3map.imp +0 -0
  101. package/test/data/war3map.j +0 -3442
  102. package/test/data/war3map.shd +0 -0
  103. package/test/data/war3map.w3a +0 -0
  104. package/test/data/war3map.w3b +0 -0
  105. package/test/data/war3map.w3c +0 -0
  106. package/test/data/war3map.w3d +0 -0
  107. package/test/data/war3map.w3e +0 -0
  108. package/test/data/war3map.w3h +0 -0
  109. package/test/data/war3map.w3i +0 -0
  110. package/test/data/war3map.w3q +0 -0
  111. package/test/data/war3map.w3r +0 -0
  112. package/test/data/war3map.w3s +0 -0
  113. package/test/data/war3map.w3t +0 -0
  114. package/test/data/war3map.w3u +0 -0
  115. package/test/data/war3map.wts +0 -631
  116. package/test/data/war3mapUnits.doo +0 -0
  117. package/tsconfig.json +0 -25
  118. package/tslint.json +0 -47
@@ -1,276 +1,221 @@
1
- import { HexBuffer } from '../HexBuffer';
2
- import { W3Buffer } from '../W3Buffer';
3
- import { WarResult, JsonResult } from '../CommonInterfaces'
4
-
5
- interface Terrain {
6
- tileset: string;
7
- customTileset: boolean;
8
- tilePalette: string[];
9
- cliffTilePalette: string[];
10
- map: Map;
11
- // "Masks"
12
- groundHeight: number[],
13
- waterHeight: number[],
14
- boundaryFlag: boolean[],
15
- flags: number[],
16
- groundTexture: number[],
17
- groundVariation: number[],
18
- cliffVariation: number[],
19
- cliffTexture: number[],
20
- layerHeight: number[]
21
- }
22
-
23
- interface Map {
24
- width: number;
25
- height: number;
26
- offset: Offset;
27
- }
28
-
29
- interface Offset {
30
- x: number;
31
- y: number;
32
- }
33
-
34
- function splitLargeArrayIntoWidthArrays(array: any[], width: number) {
35
- const rows = [];
36
- for(let i = 0; i < array.length / width; i++) {
37
- rows.push(array.slice(i * width, (i+1) * width));
38
- }
39
- return rows;
40
- }
41
-
42
- export abstract class TerrainTranslator {
43
-
44
- public static jsonToWar(terrainJson: Terrain): WarResult {
45
- const outBufferToWar = new HexBuffer();
46
-
47
- /*
48
- * Header
49
- */
50
- outBufferToWar.addChars('W3E!'); // file id
51
- outBufferToWar.addInt(11); // file version
52
- outBufferToWar.addChar(terrainJson.tileset); // base tileset
53
- outBufferToWar.addInt(+terrainJson.customTileset); // 1 = using custom tileset, 0 = not
54
-
55
- /*
56
- * Tiles
57
- */
58
- outBufferToWar.addInt(terrainJson.tilePalette.length);
59
- terrainJson.tilePalette.forEach((tile) => {
60
- outBufferToWar.addChars(tile);
61
- });
62
-
63
- /*
64
- * Cliffs
65
- */
66
- outBufferToWar.addInt(terrainJson.cliffTilePalette.length);
67
- terrainJson.cliffTilePalette.forEach((cliffTile) => {
68
- outBufferToWar.addChars(cliffTile);
69
- });
70
-
71
- /*
72
- * Map size data
73
- */
74
- outBufferToWar.addInt(terrainJson.map.width + 1);
75
- outBufferToWar.addInt(terrainJson.map.height + 1);
76
-
77
- /*
78
- * Map offset
79
- */
80
- outBufferToWar.addFloat(terrainJson.map.offset.x);
81
- outBufferToWar.addFloat(terrainJson.map.offset.y);
82
-
83
- /*
84
- * Tile points
85
- */
86
- // Partition the terrainJson masks into "chunks" (i.e. rows) of (width+1) length,
87
- // reverse that list of rows (due to vertical flipping), and then write the rows out
88
- const rows = {
89
- groundHeight: splitLargeArrayIntoWidthArrays(terrainJson.groundHeight, terrainJson.map.width + 1),
90
- waterHeight: splitLargeArrayIntoWidthArrays(terrainJson.waterHeight, terrainJson.map.width + 1),
91
- boundaryFlag: splitLargeArrayIntoWidthArrays(terrainJson.boundaryFlag, terrainJson.map.width + 1),
92
- flags: splitLargeArrayIntoWidthArrays(terrainJson.flags, terrainJson.map.width + 1),
93
- groundTexture: splitLargeArrayIntoWidthArrays(terrainJson.groundTexture, terrainJson.map.width + 1),
94
- groundVariation: splitLargeArrayIntoWidthArrays(terrainJson.groundVariation, terrainJson.map.width + 1),
95
- cliffVariation: splitLargeArrayIntoWidthArrays(terrainJson.cliffVariation, terrainJson.map.width + 1),
96
- cliffTexture: splitLargeArrayIntoWidthArrays(terrainJson.cliffTexture, terrainJson.map.width + 1),
97
- layerHeight: splitLargeArrayIntoWidthArrays(terrainJson.layerHeight, terrainJson.map.width + 1)
98
- };
99
-
100
- rows.groundHeight.reverse();
101
- rows.waterHeight.reverse();
102
- rows.boundaryFlag.reverse();
103
- rows.flags.reverse();
104
- rows.groundTexture.reverse();
105
- rows.groundVariation.reverse();
106
- rows.cliffVariation.reverse();
107
- rows.cliffTexture.reverse();
108
- rows.layerHeight.reverse();
109
-
110
- for(let i = 0; i < rows.groundHeight.length; i++) {
111
- for(let j = 0; j < rows.groundHeight[i].length; j++) {
112
- // these bit operations are based off documentation from https://github.com/stijnherfst/HiveWE/wiki/war3map.w3e-Terrain
113
- const groundHeight = rows.groundHeight[i][j];
114
- const waterHeight = rows.waterHeight[i][j];
115
- const boundaryFlag = rows.boundaryFlag[i][j];
116
- const flags = rows.flags[i][j];
117
- const groundTexture = rows.groundTexture[i][j];
118
- const groundVariation = rows.groundVariation[i][j];
119
- const cliffVariation = rows.cliffVariation[i][j];
120
- const cliffTexture = rows.cliffTexture[i][j];
121
- const layerHeight = rows.layerHeight[i][j];
122
-
123
- const hasBoundaryFlag = boundaryFlag ? 0x4000 : 0;
124
-
125
- outBufferToWar.addShort(groundHeight);
126
- outBufferToWar.addShort(waterHeight | hasBoundaryFlag);
127
- outBufferToWar.addByte(flags | groundTexture);
128
- outBufferToWar.addByte(groundVariation | cliffVariation);
129
- outBufferToWar.addByte(cliffTexture | layerHeight);
130
- }
131
- }
132
-
133
- return {
134
- errors: [],
135
- buffer: outBufferToWar.getBuffer()
136
- };
137
- }
138
-
139
- public static warToJson(buffer: Buffer): JsonResult<Terrain> {
140
- // create buffer
141
- const result: Terrain = {
142
- tileset: '',
143
- customTileset: false,
144
- tilePalette: [],
145
- cliffTilePalette: [],
146
- map: {
147
- width: 1,
148
- height: 1,
149
- offset: {
150
- x: 0,
151
- y: 0
152
- }
153
- },
154
- groundHeight: [],
155
- waterHeight: [],
156
- boundaryFlag: [],
157
- flags: [],
158
- groundTexture: [],
159
- groundVariation: [],
160
- cliffVariation: [],
161
- cliffTexture: [],
162
- layerHeight: []
163
- };
164
- const outBufferToJSON = new W3Buffer(buffer);
165
-
166
- /**
167
- * Header
168
- */
169
- const w3eHeader = outBufferToJSON.readChars(4); // W3E!
170
- const version = outBufferToJSON.readInt(); // 0B 00 00 00
171
- const tileset = outBufferToJSON.readChars(1); // tileset
172
- const customTileset = (outBufferToJSON.readInt() === 1);
173
-
174
- result.tileset = tileset;
175
- result.customTileset = customTileset;
176
-
177
- /**
178
- * Tiles
179
- */
180
- const numTilePalettes = outBufferToJSON.readInt();
181
- const tilePalettes = [];
182
- for (let i = 0; i < numTilePalettes; i++) {
183
- tilePalettes.push(outBufferToJSON.readChars(4));
184
- }
185
-
186
- result.tilePalette = tilePalettes;
187
-
188
- /**
189
- * Cliffs
190
- */
191
- const numCliffTilePalettes = outBufferToJSON.readInt();
192
- const cliffPalettes = [];
193
- for (let i = 0; i < numCliffTilePalettes; i++) {
194
- const cliffPalette = outBufferToJSON.readChars(4);
195
- cliffPalettes.push(cliffPalette);
196
- }
197
-
198
- result.cliffTilePalette = cliffPalettes;
199
-
200
- /**
201
- * map dimensions
202
- */
203
- const width = outBufferToJSON.readInt() - 1;
204
- const height = outBufferToJSON.readInt() - 1;
205
- result.map = { width, height, offset: { x: 0, y: 0 } };
206
-
207
- const offsetX = outBufferToJSON.readFloat();
208
- const offsetY = outBufferToJSON.readFloat();
209
- result.map.offset = { x: offsetX, y: offsetY };
210
-
211
- /**
212
- * map tiles
213
- */
214
- const arr_groundHeight = [];
215
- const arr_waterHeight = [];
216
- const arr_boundaryFlag = [];
217
- const arr_flags = [];
218
- const arr_groundTexture = [];
219
- const arr_groundVariation = [];
220
- const arr_cliffVariation = [];
221
- const arr_cliffTexture = [];
222
- const arr_layerHeight = [];
223
-
224
- while(!outBufferToJSON.isExhausted()) {
225
- const groundHeight = outBufferToJSON.readShort();
226
- const waterHeightAndBoundary = outBufferToJSON.readShort();
227
- const flagsAndGroundTexture = outBufferToJSON.readByte();
228
- const groundAndCliffVariation = outBufferToJSON.readByte();
229
- const cliffTextureAndLayerHeight = outBufferToJSON.readByte();
230
-
231
- // parse out different bits (based on documentation from https://github.com/stijnherfst/HiveWE/wiki/war3map.w3e-Terrain)
232
- const waterHeight = waterHeightAndBoundary & 32767;
233
- const boundaryFlag = (waterHeightAndBoundary & 0x4000) === 0x4000;
234
- const flags = flagsAndGroundTexture & 240;
235
- const groundTexture = flagsAndGroundTexture & 15;
236
- const groundVariation = groundAndCliffVariation & 248;
237
- const cliffVariation = groundAndCliffVariation & 7;
238
- const cliffTexture = cliffTextureAndLayerHeight & 240;
239
- const layerHeight = cliffTextureAndLayerHeight & 15;
240
-
241
- arr_groundHeight.push(groundHeight);
242
- arr_waterHeight.push(waterHeight);
243
- arr_boundaryFlag.push(boundaryFlag);
244
- arr_flags.push(flags);
245
- arr_groundTexture.push(groundTexture);
246
- arr_groundVariation.push(groundVariation);
247
- arr_cliffVariation.push(cliffVariation);
248
- arr_cliffTexture.push(cliffTexture);
249
- arr_layerHeight.push(layerHeight);
250
- }
251
-
252
- function convertArrayOfArraysIntoFlatArray(arr) {
253
- return arr.reduce((a, b) => {
254
- return [...a, ...b]
255
- });
256
- }
257
-
258
- // The map was read in "backwards" because wc3 maps have origin (0,0)
259
- // at the bottom left instead of top left as we desire. Flip the rows
260
- // vertically to fix this.
261
- result.groundHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundHeight, result.map.width + 1).reverse())
262
- result.waterHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_waterHeight, result.map.width + 1).reverse())
263
- result.boundaryFlag = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_boundaryFlag, result.map.width + 1).reverse())
264
- result.flags = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_flags, result.map.width + 1).reverse())
265
- result.groundTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundTexture, result.map.width + 1).reverse())
266
- result.groundVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundVariation, result.map.width + 1).reverse())
267
- result.cliffVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffVariation, result.map.width + 1).reverse())
268
- result.cliffTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffTexture, result.map.width + 1).reverse())
269
- result.layerHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_layerHeight, result.map.width + 1).reverse())
270
-
271
- return {
272
- errors: [],
273
- json: result
274
- };
275
- }
276
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TerrainTranslator = void 0;
4
+ const HexBuffer_1 = require("../HexBuffer");
5
+ const W3Buffer_1 = require("../W3Buffer");
6
+ function splitLargeArrayIntoWidthArrays(array, width) {
7
+ const rows = [];
8
+ for (let i = 0; i < array.length / width; i++) {
9
+ rows.push(array.slice(i * width, (i + 1) * width));
10
+ }
11
+ return rows;
12
+ }
13
+ class TerrainTranslator {
14
+ static jsonToWar(terrainJson) {
15
+ const outBufferToWar = new HexBuffer_1.HexBuffer();
16
+ /*
17
+ * Header
18
+ */
19
+ outBufferToWar.addChars('W3E!'); // file id
20
+ outBufferToWar.addInt(11); // file version
21
+ outBufferToWar.addChar(terrainJson.tileset); // base tileset
22
+ outBufferToWar.addInt(+terrainJson.customTileset); // 1 = using custom tileset, 0 = not
23
+ /*
24
+ * Tiles
25
+ */
26
+ outBufferToWar.addInt(terrainJson.tilePalette.length);
27
+ terrainJson.tilePalette.forEach((tile) => {
28
+ outBufferToWar.addChars(tile);
29
+ });
30
+ /*
31
+ * Cliffs
32
+ */
33
+ outBufferToWar.addInt(terrainJson.cliffTilePalette.length);
34
+ terrainJson.cliffTilePalette.forEach((cliffTile) => {
35
+ outBufferToWar.addChars(cliffTile);
36
+ });
37
+ /*
38
+ * Map size data
39
+ */
40
+ outBufferToWar.addInt(terrainJson.map.width + 1);
41
+ outBufferToWar.addInt(terrainJson.map.height + 1);
42
+ /*
43
+ * Map offset
44
+ */
45
+ outBufferToWar.addFloat(terrainJson.map.offset.x);
46
+ outBufferToWar.addFloat(terrainJson.map.offset.y);
47
+ /*
48
+ * Tile points
49
+ */
50
+ // Partition the terrainJson masks into "chunks" (i.e. rows) of (width+1) length,
51
+ // reverse that list of rows (due to vertical flipping), and then write the rows out
52
+ const rows = {
53
+ groundHeight: splitLargeArrayIntoWidthArrays(terrainJson.groundHeight, terrainJson.map.width + 1),
54
+ waterHeight: splitLargeArrayIntoWidthArrays(terrainJson.waterHeight, terrainJson.map.width + 1),
55
+ boundaryFlag: splitLargeArrayIntoWidthArrays(terrainJson.boundaryFlag, terrainJson.map.width + 1),
56
+ flags: splitLargeArrayIntoWidthArrays(terrainJson.flags, terrainJson.map.width + 1),
57
+ groundTexture: splitLargeArrayIntoWidthArrays(terrainJson.groundTexture, terrainJson.map.width + 1),
58
+ groundVariation: splitLargeArrayIntoWidthArrays(terrainJson.groundVariation, terrainJson.map.width + 1),
59
+ cliffVariation: splitLargeArrayIntoWidthArrays(terrainJson.cliffVariation, terrainJson.map.width + 1),
60
+ cliffTexture: splitLargeArrayIntoWidthArrays(terrainJson.cliffTexture, terrainJson.map.width + 1),
61
+ layerHeight: splitLargeArrayIntoWidthArrays(terrainJson.layerHeight, terrainJson.map.width + 1)
62
+ };
63
+ rows.groundHeight.reverse();
64
+ rows.waterHeight.reverse();
65
+ rows.boundaryFlag.reverse();
66
+ rows.flags.reverse();
67
+ rows.groundTexture.reverse();
68
+ rows.groundVariation.reverse();
69
+ rows.cliffVariation.reverse();
70
+ rows.cliffTexture.reverse();
71
+ rows.layerHeight.reverse();
72
+ for (let i = 0; i < rows.groundHeight.length; i++) {
73
+ for (let j = 0; j < rows.groundHeight[i].length; j++) {
74
+ // these bit operations are based off documentation from https://github.com/stijnherfst/HiveWE/wiki/war3map.w3e-Terrain
75
+ const groundHeight = rows.groundHeight[i][j];
76
+ const waterHeight = rows.waterHeight[i][j];
77
+ const boundaryFlag = rows.boundaryFlag[i][j];
78
+ const flags = rows.flags[i][j];
79
+ const groundTexture = rows.groundTexture[i][j];
80
+ const groundVariation = rows.groundVariation[i][j];
81
+ const cliffVariation = rows.cliffVariation[i][j];
82
+ const cliffTexture = rows.cliffTexture[i][j];
83
+ const layerHeight = rows.layerHeight[i][j];
84
+ const hasBoundaryFlag = boundaryFlag ? 0x4000 : 0;
85
+ outBufferToWar.addShort(groundHeight);
86
+ outBufferToWar.addShort(waterHeight | hasBoundaryFlag);
87
+ outBufferToWar.addByte(flags | groundTexture);
88
+ outBufferToWar.addByte(groundVariation | cliffVariation);
89
+ outBufferToWar.addByte(cliffTexture | layerHeight);
90
+ }
91
+ }
92
+ return {
93
+ errors: [],
94
+ buffer: outBufferToWar.getBuffer()
95
+ };
96
+ }
97
+ static warToJson(buffer) {
98
+ // create buffer
99
+ const result = {
100
+ tileset: '',
101
+ customTileset: false,
102
+ tilePalette: [],
103
+ cliffTilePalette: [],
104
+ map: {
105
+ width: 1,
106
+ height: 1,
107
+ offset: {
108
+ x: 0,
109
+ y: 0
110
+ }
111
+ },
112
+ groundHeight: [],
113
+ waterHeight: [],
114
+ boundaryFlag: [],
115
+ flags: [],
116
+ groundTexture: [],
117
+ groundVariation: [],
118
+ cliffVariation: [],
119
+ cliffTexture: [],
120
+ layerHeight: []
121
+ };
122
+ const outBufferToJSON = new W3Buffer_1.W3Buffer(buffer);
123
+ /**
124
+ * Header
125
+ */
126
+ const w3eHeader = outBufferToJSON.readChars(4); // W3E!
127
+ const version = outBufferToJSON.readInt(); // 0B 00 00 00
128
+ const tileset = outBufferToJSON.readChars(1); // tileset
129
+ const customTileset = (outBufferToJSON.readInt() === 1);
130
+ result.tileset = tileset;
131
+ result.customTileset = customTileset;
132
+ /**
133
+ * Tiles
134
+ */
135
+ const numTilePalettes = outBufferToJSON.readInt();
136
+ const tilePalettes = [];
137
+ for (let i = 0; i < numTilePalettes; i++) {
138
+ tilePalettes.push(outBufferToJSON.readChars(4));
139
+ }
140
+ result.tilePalette = tilePalettes;
141
+ /**
142
+ * Cliffs
143
+ */
144
+ const numCliffTilePalettes = outBufferToJSON.readInt();
145
+ const cliffPalettes = [];
146
+ for (let i = 0; i < numCliffTilePalettes; i++) {
147
+ const cliffPalette = outBufferToJSON.readChars(4);
148
+ cliffPalettes.push(cliffPalette);
149
+ }
150
+ result.cliffTilePalette = cliffPalettes;
151
+ /**
152
+ * map dimensions
153
+ */
154
+ const width = outBufferToJSON.readInt() - 1;
155
+ const height = outBufferToJSON.readInt() - 1;
156
+ result.map = { width, height, offset: { x: 0, y: 0 } };
157
+ const offsetX = outBufferToJSON.readFloat();
158
+ const offsetY = outBufferToJSON.readFloat();
159
+ result.map.offset = { x: offsetX, y: offsetY };
160
+ /**
161
+ * map tiles
162
+ */
163
+ const arr_groundHeight = [];
164
+ const arr_waterHeight = [];
165
+ const arr_boundaryFlag = [];
166
+ const arr_flags = [];
167
+ const arr_groundTexture = [];
168
+ const arr_groundVariation = [];
169
+ const arr_cliffVariation = [];
170
+ const arr_cliffTexture = [];
171
+ const arr_layerHeight = [];
172
+ while (!outBufferToJSON.isExhausted()) {
173
+ const groundHeight = outBufferToJSON.readShort();
174
+ const waterHeightAndBoundary = outBufferToJSON.readShort();
175
+ const flagsAndGroundTexture = outBufferToJSON.readByte();
176
+ const groundAndCliffVariation = outBufferToJSON.readByte();
177
+ const cliffTextureAndLayerHeight = outBufferToJSON.readByte();
178
+ // parse out different bits (based on documentation from https://github.com/stijnherfst/HiveWE/wiki/war3map.w3e-Terrain)
179
+ const waterHeight = waterHeightAndBoundary & 32767;
180
+ const boundaryFlag = (waterHeightAndBoundary & 0x4000) === 0x4000;
181
+ const flags = flagsAndGroundTexture & 240;
182
+ const groundTexture = flagsAndGroundTexture & 15;
183
+ const groundVariation = groundAndCliffVariation & 248;
184
+ const cliffVariation = groundAndCliffVariation & 7;
185
+ const cliffTexture = cliffTextureAndLayerHeight & 240;
186
+ const layerHeight = cliffTextureAndLayerHeight & 15;
187
+ arr_groundHeight.push(groundHeight);
188
+ arr_waterHeight.push(waterHeight);
189
+ arr_boundaryFlag.push(boundaryFlag);
190
+ arr_flags.push(flags);
191
+ arr_groundTexture.push(groundTexture);
192
+ arr_groundVariation.push(groundVariation);
193
+ arr_cliffVariation.push(cliffVariation);
194
+ arr_cliffTexture.push(cliffTexture);
195
+ arr_layerHeight.push(layerHeight);
196
+ }
197
+ function convertArrayOfArraysIntoFlatArray(arr) {
198
+ return arr.reduce((a, b) => {
199
+ return [...a, ...b];
200
+ });
201
+ }
202
+ // The map was read in "backwards" because wc3 maps have origin (0,0)
203
+ // at the bottom left instead of top left as we desire. Flip the rows
204
+ // vertically to fix this.
205
+ result.groundHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundHeight, result.map.width + 1).reverse());
206
+ result.waterHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_waterHeight, result.map.width + 1).reverse());
207
+ result.boundaryFlag = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_boundaryFlag, result.map.width + 1).reverse());
208
+ result.flags = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_flags, result.map.width + 1).reverse());
209
+ result.groundTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundTexture, result.map.width + 1).reverse());
210
+ result.groundVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundVariation, result.map.width + 1).reverse());
211
+ result.cliffVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffVariation, result.map.width + 1).reverse());
212
+ result.cliffTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffTexture, result.map.width + 1).reverse());
213
+ result.layerHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_layerHeight, result.map.width + 1).reverse());
214
+ return {
215
+ errors: [],
216
+ json: result
217
+ };
218
+ }
219
+ }
220
+ exports.TerrainTranslator = TerrainTranslator;
221
+ //# sourceMappingURL=TerrainTranslator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerrainTranslator.js","sourceRoot":"","sources":["../../src/translators/TerrainTranslator.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,0CAAuC;AAgCvC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,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAEvI,OAAO;YACH,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,MAAM;SACf,CAAC;IACN,CAAC;CACJ;AA1OD,8CA0OC"}
@@ -0,0 +1,40 @@
1
+ /// <reference types="node" />
2
+ import { WarResult, JsonResult, angle } from '../CommonInterfaces';
3
+ interface Unit {
4
+ type: string;
5
+ variation: number;
6
+ position: number[];
7
+ rotation: angle;
8
+ scale: number[];
9
+ hero: Hero;
10
+ inventory: Inventory[];
11
+ abilities: Abilities[];
12
+ player: number;
13
+ hitpoints: number;
14
+ mana: number;
15
+ gold: number;
16
+ targetAcquisition: number;
17
+ color: number;
18
+ id: number;
19
+ }
20
+ interface Hero {
21
+ level: number;
22
+ str: number;
23
+ agi: number;
24
+ int: number;
25
+ }
26
+ interface Inventory {
27
+ slot: number;
28
+ type: string;
29
+ }
30
+ interface Abilities {
31
+ ability: string;
32
+ active: boolean;
33
+ level: number;
34
+ }
35
+ export declare abstract class UnitsTranslator {
36
+ static jsonToWar(unitsJson: Unit[]): WarResult;
37
+ static warToJson(buffer: Buffer): JsonResult<Unit[]>;
38
+ }
39
+ export {};
40
+ //# sourceMappingURL=UnitsTranslator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnitsTranslator.d.ts","sourceRoot":"","sources":["../../src/translators/UnitsTranslator.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAElE,UAAU,IAAI;IACV,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACd;AAED,UAAU,IAAI;IACV,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,SAAS;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,8BAAsB,eAAe;WAEnB,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,SAAS;WA8FvC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;CA4H9D"}