madden-franchise 2.3.15 → 2.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.
package/FranchiseFile.js CHANGED
@@ -286,6 +286,29 @@ class FranchiseFile extends EventEmitter {
286
286
  return null;
287
287
  }
288
288
  };
289
+
290
+ getReferencesToRecord(tableId, recordIndex) {
291
+ const referencedTable = this.getTableById(tableId);
292
+
293
+ if (referencedTable) {
294
+ const fullBinary = utilService.getBinaryReferenceData(tableId, recordIndex);
295
+ const hex = utilService.bin2hex(fullBinary);
296
+
297
+ return this.tables.filter((table) => {
298
+ return table.schema && table.schema.attributes.find((attribute) => {
299
+ return attribute.type === referencedTable.name;
300
+ });
301
+ }).filter((table) => {
302
+ return table.data.indexOf(hex, 0, 'hex') !== -1;
303
+ }).map((table) => {
304
+ return {
305
+ tableId: table.header.tableId,
306
+ name: table.name,
307
+ table: table
308
+ }
309
+ });
310
+ }
311
+ };
289
312
  };
290
313
 
291
314
  module.exports = FranchiseFile;
@@ -44,6 +44,10 @@ class FranchiseFileTable extends EventEmitter {
44
44
  get schema () {
45
45
  return this._schema;
46
46
  };
47
+
48
+ getBinaryReferenceToRecord(index) {
49
+ return utilService.getBinaryReferenceData(this.header.tableId, index);
50
+ };
47
51
 
48
52
  updateBuffer() {
49
53
  // need to check table2 data first because it may change offsets of the legit records.
@@ -592,7 +596,7 @@ function readOffsetTable(data, schema, header) {
592
596
  'originalIndex': parseInt(attribute.index),
593
597
  'name': attribute.name,
594
598
  'type': (minValue < 0 || maxValue < 0) ? 's_' + attribute.type : attribute.type,
595
- 'isReference': !attribute.enum && (attribute.type[0] == attribute.type[0].toUpperCase() || attribute.type.includes('[]')) ? true : false,
599
+ 'isReference': !attribute.enum && (attribute.type[0] == attribute.type[0].toUpperCase() || attribute.type.includes('[]') || attribute.type === 'record') ? true : false,
596
600
  'valueInSecondTable': header.hasSecondTable && attribute.type === 'string',
597
601
  'isSigned': minValue < 0 || maxValue < 0,
598
602
  'minValue': minValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "2.3.15",
3
+ "version": "2.4.0",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {