madden-file-tools

2.7.4 • Public • Published

madden-file-tools

JS API for reading and extracting EA/Madden files.

Usage

This package is useful for parsing the following files:

  • TDB files: used by legacy Madden, NCAA, and Head Coach games. (Can Read and write)
  • AST files: used by many games. (Note: Read only as of now)
    • Contain other resource files such as DDS files.

EA TDB Files (Legacy Madden, NCAA 14)

const TDBHelper = require('madden-file-tools/helpers/TDBHelper');
const tdbPath = [path to file];

const helper = new TDBHelper();
helper.load(tdbPath)
    .then((file) => {
        // You have access to all the tables here.
        
        // Access individual table
        const awplTable = file.AWPL;
            // Alternative: file.tables[0];
            // `tables` is just an array.

        // To get access to the records, you need to read them in by each table. Tables are not automatically read due to memory constraints.
        file.AWPL.readRecords()
            .then(() => {
                // Here you have access to all the AWPL records and data.
                
                // Access field values
                const firstStc1Field = file.AWPL.records[0].fields['STC1'].value;
                    // Or file.AWPL.records[0].fields.STC1.value;

                    // Alternative: file.AWPL.records[0].STC1;
                    // The alternative is nicer to use, but less performant.


                // Set field values
                file.AWPL.records[0].fields['STC1'].value = 20;

                    // Alternative: file.AWPL.records[0].STC1 = 20;
                    // Again, this way is a little slower, but is nicer to write.

                // Save the file
                helper.save([optional new file here, otherwise overwrite])
                    .then(() => {
                        // File has been saved here.
                    });
            });
    });

Read HC09 Files

The Head Coach 09 save is a little different from the others. It does not contain the DB file at the very beginning, so I've included a nice helper to load and save.

const HeadCoach09Helper = require('madden-file-tools/helpers/HeadCoach09Helper');
const headCoachSaveFilePath = [path to file];

const helper = new HeadCoach09Helper();
helper.load(headCoachSaveFilePath)
    .then((file) => {
        // Same TDB file API as above. You have access to all the tables here.

        // Make changes here

        // Save the file
        helper.save([optional new file here, otherwise overwrite])
            .then(() => {
                // File has been saved here.
            });
    });

Generic TDB Reader/Writer Usage

const fs = require('fs');
const TDBParser = require('madden-file-tools/streams/TDBParser');
const TDBWriter = require('madden-file-tools/streams/TDBWriter');

const parser = new TDBParser();
const readStream = fs.createReadStream([file path here]);

stream.on('end', function () {
    const file = parser.file;

    // Make changes here

    // Save
    const writeStream = fs.createWriteStream([path to write]);
    const writer = new TDBWriter(file);

    writeStream.on('end', () => {
        // File has been saved here.
    });

    writer
        .pipe(writeStream);
});

stream
    .pipe(parser);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.7.45latest

Version History

VersionDownloads (Last 7 Days)Published
2.7.45
2.7.30
2.7.20
2.7.10
2.7.00
2.6.23
2.6.10
2.6.00
2.5.50
2.5.40
2.5.30
2.5.21
2.5.11
2.5.00
2.4.131
2.4.120
2.4.110
2.4.100
2.4.90
2.4.80
2.4.70
2.4.60
2.4.50
2.4.40
2.4.30
2.4.20
2.4.10
2.4.00
2.3.20
2.3.10
2.3.00
2.2.60
2.2.50
2.2.40
2.2.30
2.2.20
2.2.10
2.2.00
2.0.30
2.0.20
2.0.10
2.0.00
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i madden-file-tools

Weekly Downloads

11

Version

2.7.4

License

MIT

Unpacked Size

268 kB

Total Files

91

Last publish

Collaborators

  • matthewpanetta