minor corrections and addition of more deck UI controls. Minor testing

This commit is contained in:
bluesaxman 2020-09-17 14:23:12 -06:00
parent f8583ab99e
commit b395dfaf82
3 changed files with 25 additions and 8 deletions

View File

@ -346,7 +346,12 @@ my $server = Net::WebSocket::Server->new(
# each card (so we scale better)
if (@hand) { for (@hand) {
my $card = $_;
$current->send_utf8('{"action":"addCard","hand":"'.$handID.'", "card":"'.$card.'"}');
my %message = (
action => "addCard",
hand => $handID,
card => $card
);
$current->send_utf8(to_json(\%message));
}}
}
}}}
@ -371,7 +376,7 @@ my $server = Net::WebSocket::Server->new(
$conn->send_utf8('{"info":"hand returned to deck","request":"update"}');
}
if ($messageData->{action} =~ /shuffle/) {
shuffleDeck($conn->{session},$messageData->{action});
shuffleDeck($conn->{session},$messageData->{deck});
$conn->send_utf8('{"info":"deck shuffeled","request":"update"}');
}
if ($messageData->{action} =~ /add/) {

View File

@ -47,7 +47,7 @@ body {
display: flex;
justify-content: space-around;
align-items: stretch;
height: 80vh;
height: 95vh;
width: 100%;
}
@ -60,7 +60,7 @@ body {
#decks, #hands, #pools, #users {
display: flex;
flex-direction: column;
justify-content: space-around;
justify-content: start;
align-items: center;
list-style: none;
width: 100%;

View File

@ -20,7 +20,9 @@ function updateEvent() {
window.UI.display.innerHTML = "";
if (window.UI.menu.decks.button.checked) {
elementPlace("#display","decks",null,"ol");
Object.keys(window.gameState.decks).forEach(function (deckID) {
var myKeys = Object.keys(window.gameState.decks);
myKeys.sort();
myKeys.forEach(function (deckID) {
var deck = window.gameState.decks[deckID];
window.UI.display[deckID] = elementPlace("#decks","Deck_"+deck.name,"deck","li");
window.UI.display[deckID].innerText = deck.name+":"+deck.size;
@ -31,7 +33,7 @@ function updateEvent() {
var message = {};
message.action = "ddf";
message.deck = deckID;
message.ddf = file;
message.ddf = file.target.result;
window.gameSession.send(JSON.stringify(message));
}
myFile.readAsText(f[0]);
@ -44,9 +46,15 @@ function updateEvent() {
window.gameSession.send('{"action":"draw","deck":"'+deckID+'","hand":"'+"default"+'"}'); // Will need to be updated when I figure out selection
}, "deck_button draw","div");
});
buttonAdd("#decks",null,"+",function () {
popupDialog("addDeck","Please name new deck",true, inputDialog,{"inputType":"text"},function (newDeckName) {
window.gameSession.send('{"action":"add","type":"deck","id":"'+newDeckName+'"}');
});
}, "add_button","li");
}
if (window.UI.menu.users.button.checked) {
elementPlace("#display","users",null,"ol");
window.gameState.users.sort();
window.gameState.users.forEach(function (user) {
window.UI.display[user] = elementPlace("#users","User_"+user,"username","li");
window.UI.display[user].innerText = user;
@ -54,7 +62,9 @@ function updateEvent() {
}
if (window.UI.menu.hands.button.checked) {
elementPlace("#display","hands",null,"ol");
Object.keys(window.gameState.hands).forEach(function (handID) {
var myHands = Object.keys(window.gameState.hands);
myHands.sort();
myHands.forEach(function (handID) {
var hand = window.gameState.hands[handID];
window.UI.display[handID] = elementPlace("#hands","Hand_"+hand.name,"hand","li");
window.UI.display[handID].innerText = hand.name;
@ -67,7 +77,9 @@ function updateEvent() {
}
if (window.UI.menu.pools.button.checked) {
elementPlace("#display","pools",null,"ol");
Object.keys(window.gameState.pools).forEach(function (poolID) {
var myPools = Object.keys(window.gameState.pools);
myPools.sort();
myPools.forEach(function (poolID) {
var pool = window.gameState.pools[poolID];
window.UI.display[poolID] = elementPlace("#pools","Pool_"+pool.name,"pool","li");
window.UI.display[poolID].innerText = pool.name+":"+pool.top;