added basic control functions to the decks UI
This commit is contained in:
parent
ec9b1017e5
commit
f8583ab99e
@ -24,13 +24,32 @@ function updateEvent() {
|
|||||||
var deck = window.gameState.decks[deckID];
|
var deck = window.gameState.decks[deckID];
|
||||||
window.UI.display[deckID] = elementPlace("#decks","Deck_"+deck.name,"deck","li");
|
window.UI.display[deckID] = elementPlace("#decks","Deck_"+deck.name,"deck","li");
|
||||||
window.UI.display[deckID].innerText = deck.name+":"+deck.size;
|
window.UI.display[deckID].innerText = deck.name+":"+deck.size;
|
||||||
|
buttonAdd("#Deck_"+deck.name,null,"Add Cards", function () {
|
||||||
|
popupDialog("deckLoader","Select DDF (Deck Definition File)",true,inputDialog,{"inputType":"file"},function (f) {
|
||||||
|
var myFile = new FileReader();
|
||||||
|
myFile.onload = function (file) {
|
||||||
|
var message = {};
|
||||||
|
message.action = "ddf";
|
||||||
|
message.deck = deckID;
|
||||||
|
message.ddf = file;
|
||||||
|
window.gameSession.send(JSON.stringify(message));
|
||||||
|
}
|
||||||
|
myFile.readAsText(f[0]);
|
||||||
|
});
|
||||||
|
},"deck_button add_cards","div");
|
||||||
|
buttonAdd("#Deck_"+deck.name,null,"Shuffle", function () {
|
||||||
|
window.gameSession.send('{"action":"shuffle", "deck":"'+deckID+'"}');
|
||||||
|
}, "deck_button shuffle","div");
|
||||||
|
buttonAdd("#Deck_"+deck.name,null,"Draw", function () {
|
||||||
|
window.gameSession.send('{"action":"draw","deck":"'+deckID+'","hand":"'+"default"+'"}'); // Will need to be updated when I figure out selection
|
||||||
|
}, "deck_button draw","div");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (window.UI.menu.users.button.checked) {
|
if (window.UI.menu.users.button.checked) {
|
||||||
elementPlace("#display","users",null,"ol");
|
elementPlace("#display","users",null,"ol");
|
||||||
window.gameState.users.forEach(function (user) {
|
window.gameState.users.forEach(function (user) {
|
||||||
window.UI.display[user] = elementPlace("#users","User_"+user,"username","li");
|
window.UI.display[user] = elementPlace("#users","User_"+user,"username","li");
|
||||||
window.UI.display[user].innerText = user;
|
window.UI.display[user].innerText = user;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (window.UI.menu.hands.button.checked) {
|
if (window.UI.menu.hands.button.checked) {
|
||||||
@ -87,48 +106,7 @@ function startGameSession() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//elementPlace("body","menu",null,"div");
|
|
||||||
//buttonAdd("#menu","upload","Upload Deck", function () {
|
|
||||||
// popupDialog("deckLoader","Select Deck definition File",true,inputDialog,{"inputType":"file"},function (f) {
|
|
||||||
// var myFile = new FileReader();
|
|
||||||
// myFile.onload = function (file) {
|
|
||||||
// // Probably validate the file somehow befor eating it
|
|
||||||
// var ourFile = JSON.parse(file.target.result);
|
|
||||||
// window.gameState.deck = [];
|
|
||||||
// deckFromJSON(ourFile);
|
|
||||||
// window.hand = [];
|
|
||||||
// sendGameState();
|
|
||||||
// }
|
|
||||||
// myFile.readAsText(f[0]);
|
|
||||||
// });
|
|
||||||
//},null,"div");
|
|
||||||
//buttonAdd("#menu","add","Add Deck", function () {
|
|
||||||
// popupDialog("deckLoader","Select Deck definition to add",true,inputDialog,{"inputType":"file"},function (f) {
|
|
||||||
// var myFile = new FileReader();
|
|
||||||
// myFile.onload = function (file) {
|
|
||||||
// var ourFile = JSON.parse(file.target.result);
|
|
||||||
// deckFromJSON(ourFile);
|
|
||||||
// sendGameState();
|
|
||||||
// }
|
|
||||||
// myFile.readAsText(f[0]);
|
|
||||||
//});
|
|
||||||
//}, null, "div");
|
|
||||||
//buttonAdd("#menu","shuffle", "Shuffle Deck", function () {
|
|
||||||
// shuffleDeck(window.gameState.deck);
|
|
||||||
// sendGameState();
|
|
||||||
//}, null, "div");
|
|
||||||
//buttonAdd("#menu","shuffleAll", "Shuffle Hand to Deck", function () {
|
|
||||||
// window.gameState.deck = window.gameState.deck.concat(window.hand);
|
|
||||||
// window.hand = [];
|
|
||||||
// shuffleDeck(window.gameState.deck);
|
|
||||||
// sendGameState();
|
|
||||||
//}, null, "div");
|
|
||||||
//buttonAdd("#menu","draw", "Draw Card", function () {
|
|
||||||
// if (window.gameState.deck.length > 0) {
|
|
||||||
// window.hand.unshift(window.gameState.deck.shift());
|
|
||||||
// sendGameState();
|
|
||||||
// }
|
|
||||||
//}, null, "div");
|
|
||||||
|
|
||||||
window.document.body.innerHTML = "";
|
window.document.body.innerHTML = "";
|
||||||
window.UI = {};
|
window.UI = {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user