madden-franchise 2.1.2 → 2.2.3

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/FranchiseFile.js CHANGED
@@ -135,7 +135,30 @@ class FranchiseFile extends EventEmitter {
135
135
  resolve();
136
136
  });
137
137
 
138
- Promise.all([schemaPromise, tablePromise]).then(() => {
138
+ let assetTablePromise = new Promise((resolve, reject) => {
139
+ this.assetTable = [];
140
+
141
+ const assetTableOffset = this.unpackedFileContents.readUInt32BE(4);
142
+ const assetTableEntries = this.unpackedFileContents.readUInt32BE(36);
143
+
144
+ let currentOffset = assetTableOffset;
145
+
146
+ for (let i = 0; i < assetTableEntries; i++) {
147
+ const assetId = this.unpackedFileContents.readUInt32BE(currentOffset);
148
+ const reference = this.unpackedFileContents.readUInt32BE(currentOffset + 4);
149
+
150
+ this.assetTable.push({
151
+ 'assetId': assetId,
152
+ 'reference': reference
153
+ });
154
+
155
+ currentOffset += 8;
156
+ }
157
+
158
+ resolve();
159
+ });
160
+
161
+ Promise.all([schemaPromise, tablePromise, assetTablePromise]).then(() => {
139
162
  that.tables.forEach((table, index) => {
140
163
  const schema = that.schemaList.getSchema(table.name);
141
164
 
@@ -249,6 +272,20 @@ class FranchiseFile extends EventEmitter {
249
272
  const reference = utilService.getReferenceData(referenceValue);
250
273
  return this.getTableById(reference.tableId).records[reference.rowNumber];
251
274
  };
275
+
276
+ getReferenceFromAssetId (assetId) {
277
+ const assetEntry = this.assetTable.find((assetEntry) => {
278
+ return assetEntry.assetId === assetId;
279
+ });
280
+
281
+ if (assetEntry) {
282
+ const referenceBinaryString = assetEntry.reference.toString(2).padStart(32);
283
+ return utilService.getReferenceData(referenceBinaryString);
284
+ }
285
+ else {
286
+ return null;
287
+ }
288
+ };
252
289
  };
253
290
 
254
291
  module.exports = FranchiseFile;
@@ -371,6 +408,9 @@ function getGameYear(data, isCompressed, format) {
371
408
  else if (yearIdentifier[2] === 0x31) {
372
409
  return 21;
373
410
  }
411
+ else if (yearIdentifier[2] === 0x32) {
412
+ return 22;
413
+ }
374
414
  else {
375
415
  const schemaMajor = getCompressedSchema(data).major;
376
416
  const year = schemaMax.find((schema) => { return schema.max >= schemaMajor; }).year;
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "2.1.2",
3
+ "version": "2.2.3",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {
@@ -1,8 +1,8 @@
1
1
  const fs = require('fs');
2
2
  const zlib = require('zlib');
3
3
 
4
- const filePath = 'D:\\Projects\\Madden 20\\FranchiseData\\CAREER-M03TEST_INFLATE.frt';
5
- const outputPath = 'D:\\Projects\\Madden 20\\FranchiseData\\CAREER-M03TEST_MOD'
4
+ const filePath = 'D:\\Projects\\Madden 20\\FranchiseData\\Franchise-Expression-binary-modified.frt';
5
+ const outputPath = 'D:\\Projects\\Madden 20\\FranchiseData\\Franchise-Expression-Binary1.FTC'
6
6
 
7
7
  const stream = fs.createReadStream(filePath)
8
8
 
Binary file