This is a collection of Javascript utilities for manipulating Battlescribe rosters.
These utilities are used in the https://war.cards roster editor.
There is also a live demo here. The code for the demo is in the
examples
folder of this repository.
For additional help, hit up @stumpyzevon in the war.cards Discord channel.
First install the roster package:
$ npm install @war.cards/roster
Then load a roster from the .ros XML data. In this snippet it's loaded from a file, but it could be string data from an HTML File object:
import { createRosterFromXML } from '@war.cards/roster';
import fs from 'fs';
const rosterData = fs.readFileSync('./test_roster.ros');
const roster = createRosterFromXML(rosterData.toString());
roster.forces.forEach((force) => {
console.log(force._name);
force.selections.forEach((selection) => {
console.log(selection._name);
});
});
Coming soon! For now you can browse the roster.js and selection.js source files to see how the objects are structured and what functions are available.
There is an example roster viewer in the examples
folder. It's currently published here.
The example doesn't use any particular Javascript framework, but it does use Bootstrap.
It uses the localforage package to store the serialized roster in the browser.