changed DDF syntax to follow JSON standards

This commit is contained in:
2020-09-04 10:19:26 -06:00
parent f6ccab0919
commit 6758972a84
5 changed files with 109 additions and 96 deletions

View File

@@ -27,15 +27,18 @@ function updateEvent() {
function generateDeck(DDF) {
var cards = [""];
for (var attribute in DDF) {
DDF.sort(function (a,b) {
return a.dataIndex - b.dataIndex;
});
DDF.forEach( function (data) {
var tempcards = [];
cards.forEach( function (current) {
DDF[attribute].forEach( function (value) {
DDF.data.forEach( function (value) {
tempcards.push(current+value);
} );
} );
cards = tempcards.slice();
}
});
return cards;
}
@@ -49,7 +52,7 @@ function shuffleDeck(deck) {
}
function deckFromJSON(ourFile) {
if ( Array.isArray(ourFile) ) {
if ( Array.isArray(ourFile[0]) ) {
ourFile.forEach(function (deck) {
window.deck = window.deck.concat(generateDeck(deck));
});