madden-franchise 3.0.5 → 3.0.6

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
@@ -276,7 +276,7 @@ class FranchiseFile extends EventEmitter {
276
276
 
277
277
  getReferencedRecord (referenceValue) {
278
278
  const reference = utilService.getReferenceData(referenceValue);
279
- return this.getTableById(reference.tableId).records[reference.rowNumber];
279
+ return this.getTableById(reference.tableId)?.records[reference.rowNumber];
280
280
  };
281
281
 
282
282
  getReferenceFromAssetId (assetId) {
@@ -433,7 +433,7 @@ function getGameYear(data, isCompressed, format) {
433
433
  'max': 95
434
434
  },
435
435
  {
436
- 'year': 22,
436
+ 'year': 24,
437
437
  'max': 999
438
438
  }
439
439
  ];
@@ -468,6 +468,9 @@ function getGameYear(data, isCompressed, format) {
468
468
  else if (yearIdentifier[2] === 0x33) {
469
469
  return 23;
470
470
  }
471
+ else if (yearIdentifier[2] === 0x34 || yearIdentifier[2] === 'd') {
472
+ return 24;
473
+ }
471
474
  else {
472
475
  const schemaMajor = getCompressedSchema(data).major;
473
476
  const year = schemaMax.find((schema) => { return schema.max >= schemaMajor; }).year;
@@ -85,8 +85,15 @@ class FranchiseFileField {
85
85
  this._value = theEnum.name;
86
86
  }
87
87
  catch (err) {
88
- this._value = null;
89
- throw err;
88
+ // if user tries entering an invalid enum value, check if it's an empty record reference (will be binary)
89
+ if (utilService.stringOnlyContainsBinaryDigits(value)) {
90
+ this._value = value;
91
+ this._unformattedValue.setBits(this.offset.offset, value, this.offset.length);
92
+ }
93
+ else {
94
+ this._value = null;
95
+ throw err;
96
+ }
90
97
  }
91
98
  }
92
99
  else {
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {
@@ -0,0 +1,38 @@
1
+ const FranchiseFile = require('../FranchiseFile');
2
+ const utilService = require('../services/utilService');
3
+
4
+ const franchisePath = 'C:\\Users\\Matt\\Downloads\\CAREER-COACHTEST';
5
+ const ftcPath = 'D:\\Projects\\Madden 24\\FTCs\\franchise-league-binary.FTC';
6
+ const schemaPath = 'C:\\Users\\Matt\\AppData\\Roaming\\madden-franchise-editor\\schemas\\M24_144_6.gz';
7
+
8
+ (async () => {
9
+ function franchiseFileLoadPromise(file) {
10
+ return new Promise((resolve, reject) => {
11
+ file.on('ready', () => {
12
+ resolve();
13
+ });
14
+ });
15
+ };
16
+
17
+ const file = new FranchiseFile(franchisePath, {
18
+ schemaOverride: {
19
+ path: schemaPath
20
+ }
21
+ });
22
+
23
+ const ftc = new FranchiseFile(ftcPath, {
24
+ schemaOverride: {
25
+ path: schemaPath
26
+ }
27
+ });
28
+
29
+ await Promise.all([franchiseFileLoadPromise(file), franchiseFileLoadPromise(ftc)]);
30
+
31
+ const tableToFind = file.getTableById(4227);
32
+ await tableToFind.readRecords();
33
+
34
+ const college = tableToFind.records[2].getFieldByKey('College');
35
+ const collegeVal = utilService.bin2dec(college.value);
36
+ const ref = ftc.getReferenceFromAssetId(collegeVal);
37
+ console.log(ref);
38
+ })();
Binary file