added example deck and added import function

This commit is contained in:
bluesaxman 2020-05-19 17:00:02 -06:00
parent 11fe602f70
commit ea37f2f436
2 changed files with 37 additions and 1 deletions

View File

@ -8,12 +8,26 @@
Welcome to Deckcard Welcome to Deckcard
</body> </body>
<script> <script>
function generateDeck(DDF) {
var cards = [""];
for (var attribute in DDF) {
var tempcards = [];
cards.forEach( function (current) {
DDF[attribute].forEach( function (value) {
tempcards.push(current+value);
} );
} );
cards = tempcards.slice();
}
return cards;
}
var menu = elementPlace("body","menu",null,"div"); var menu = elementPlace("body","menu",null,"div");
buttonAdd("#menu","upload","Upload Deck", function () { buttonAdd("#menu","upload","Upload Deck", function () {
popupDialog("deckLoader","Select Deck definition File",true,inputDialog,{"inputType":"file"},function (f) { popupDialog("deckLoader","Select Deck definition File",true,inputDialog,{"inputType":"file"},function (f) {
var myFile = new FileReader(); var myFile = new FileReader();
myFile.onload = function (file) { myFile.onload = function (file) {
window.deck = file.target.result; window.deck = generateDeck(JSON.parse(file.target.result));
} }
myFile.readAsText(f[0]); myFile.readAsText(f[0]);
}) })

22
standardfaces.ddf Normal file
View File

@ -0,0 +1,22 @@
{"value":[
"A",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"J",
"Q",
"K"],
"shape":[
"round",
"sharp"],
"color":[
"red",
"black"
]}