mirror of
https://forge.murkfall.net/bluesaxman/deckard-and-company.git
synced 2026-03-13 08:54:20 -06:00
Initial commit for deckard and company
This commit is contained in:
126
UI/css.css
Normal file
126
UI/css.css
Normal file
@@ -0,0 +1,126 @@
|
||||
*|* {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content:center;
|
||||
align-items:center;
|
||||
}
|
||||
|
||||
#disc {
|
||||
display:block;
|
||||
width:80%;
|
||||
min-height:60%;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#menu {
|
||||
display:flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
#display {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: stretch;
|
||||
height: 80vh;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#deck, #deckDisp {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#deck {
|
||||
width: 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
|
||||
#hand {
|
||||
display: flex;
|
||||
width: 50%;
|
||||
max-width: 50%;
|
||||
overflow: auto;
|
||||
justify-content: left;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.library {
|
||||
background: rgba(200,200,200,1);
|
||||
text-align:left;
|
||||
margin:5px 5px -15px 5px;
|
||||
padding:5px 5px 20px 5px;
|
||||
min-height:10%;
|
||||
border:solid 1px rgba(140,140,140,1);
|
||||
border-radius:10px 10px 0px 0px;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
background: rgba(150,150,150,0.7);
|
||||
user-select: none;
|
||||
margin:1px;
|
||||
padding:2px;
|
||||
border:solid 1px rgba(90,90,90,0.5);
|
||||
border-radius:5px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background: rgba(140,140,140,1);
|
||||
margin:0px;
|
||||
padding:3px;
|
||||
transition:0.2s;
|
||||
}
|
||||
|
||||
.dialog_back {
|
||||
position:absolute;
|
||||
display:flex;
|
||||
justify-content:center;
|
||||
align-items:center;
|
||||
top:0;
|
||||
left:0;
|
||||
width:100%;
|
||||
height:100%;
|
||||
background: rgba(0,0,0,0.7);
|
||||
}
|
||||
|
||||
.dialog_window {
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
background: rgba(255,255,255,1);
|
||||
border-radius:5px;
|
||||
}
|
||||
|
||||
.dialog_title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: rgba(0,0,0,0.3);
|
||||
padding: 0px 0px 0px 5px;
|
||||
}
|
||||
|
||||
.dialog_content {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.card {
|
||||
height: 3in;
|
||||
width: 2in;
|
||||
display: inline-block;
|
||||
border: 1px rgba(0,0,0,1) solid;
|
||||
border-radius: 5px;
|
||||
min-height: 3in;
|
||||
min-width: 2in;
|
||||
max-height:3in;
|
||||
max-width:5in;
|
||||
overflow: auto;
|
||||
background: rgb(216, 206, 184);
|
||||
}
|
||||
107
UI/index.html
Normal file
107
UI/index.html
Normal file
@@ -0,0 +1,107 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Deckard</title>
|
||||
<link href="css.css" rel="stylesheet">
|
||||
<script src="https://labs.murkfall.net/bluesaxman/blue.js/raw/master/libs/bluecore.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to Deckard<h1>
|
||||
</body>
|
||||
<script>
|
||||
|
||||
window.deck = [];
|
||||
window.hand = [];
|
||||
|
||||
function updateEvent() {
|
||||
window.UI.deck.innerHTML = "";
|
||||
window.UI.hand.innerHTML = "";
|
||||
var theDeck = elementPlace("#deck","deckDisp","card","div");
|
||||
theDeck.innerHTML = "<div>"+window.deck.length+"</div>";
|
||||
window.hand.forEach(function (card,index) {
|
||||
if (index < 10) {
|
||||
var currentCard = elementPlace("#hand",null,"card","li");
|
||||
currentCard.innerHTML = card;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function shuffleDeck(deck) {
|
||||
deck.forEach(function (card,index) {
|
||||
var swapCardIndex = Math.floor( Math.random() * deck.length );
|
||||
var swapCard = deck[swapCardIndex];
|
||||
deck[swapCardIndex] = card;
|
||||
deck[index] = swapCard;
|
||||
});
|
||||
}
|
||||
|
||||
function deckFromJSON(ourFile) {
|
||||
if ( Array.isArray(ourFile) ) {
|
||||
ourFile.forEach(function (deck) {
|
||||
window.deck = window.deck.concat(generateDeck(deck));
|
||||
});
|
||||
} else {
|
||||
window.deck = window.deck.concat(generateDeck(ourFile));
|
||||
}
|
||||
}
|
||||
|
||||
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.deck = [];
|
||||
deckFromJSON(ourFile);
|
||||
window.hand = [];
|
||||
updateEvent();
|
||||
}
|
||||
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);
|
||||
updateEvent();
|
||||
}
|
||||
myFile.readAsText(f[0]);
|
||||
});
|
||||
}, null, "div");
|
||||
buttonAdd("#menu","shuffle", "Shuffle Deck", function () {
|
||||
shuffleDeck(window.deck);
|
||||
}, null, "div");
|
||||
buttonAdd("#menu","shuffleAll", "Shuffle Whole Deck", function () {
|
||||
window.deck = window.deck.concat(window.hand);
|
||||
window.hand = [];
|
||||
shuffleDeck(window.deck);
|
||||
updateEvent();
|
||||
}, null, "div");
|
||||
buttonAdd("#menu","draw", "Draw Card", function () {
|
||||
if (window.deck.length > 0) {
|
||||
window.hand.unshift(window.deck.shift());
|
||||
updateEvent();
|
||||
}
|
||||
}, null, "div");
|
||||
elementPlace("body","display",null,"div");
|
||||
window.UI = {};
|
||||
window.UI.deck = elementPlace("#display","deck",null,"div");
|
||||
window.UI.hand = elementPlace("#display","hand",null,"ol");
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user