This commit is contained in:
nannal
2020-05-02 21:09:22 +03:00
parent 2129889248
commit 457182504f
11 changed files with 570 additions and 127 deletions

View File

@@ -0,0 +1,7 @@
FROM nginx
ADD ./ /usr/share/nginx/html
LABEL traefik.port="80"
EXPOSE 80
CMD ["nginx", "-g", "'daemon off'"]

View File

@@ -1,12 +1,109 @@
body{
margin:40px auto;
max-width:650px;
max-width:90%;
line-height:1.6;
font-size:18px;
color:#444;
padding:0 10px;
font-family: monospace;
}
h1,h2,h3{
line-height:1.2
}
}
.donateInput{
width: 35%;
}
select{
height: auto;
width: 80%;
font-size: large;
}
input{
height: auto;
width: 80%;
font-size: large;
}
button{
height: auto;
width: 18%;
font-size: large;
}
#controls{
width: 100%;
}
#Reigster-Container{
visibility: visible;
width: 100%;
}
#Make-Container{
visibility: hidden;
scale: 0;
}
#Join-Container{
visibility: hidden;
scale: 0;
}
#Start-Container{
visibility: hidden;
scale: 0;
}
#Donate-Container{
visibility: hidden;
scale: 0;
}
#Accuse-Container{
visibility: hidden;
scale: 0;
}
#messages{
visibility: hidden;
scale: 0;
}
#games{
visibility: hidden;
scale: 0;
}
#gameInfo{
visibility: hidden;
scale: 0;
}
#myCharity{
visibility: hidden;
scale: 0;
}
#charityStatus{
visibility: hidden;
scale: 0;
}
#boardFunding{
visibility: hidden;
scale: 0;
}
#transactionLog{
visibility: hidden;
scale: 0;
}
#accusationLog{
visibility: hidden;
scale: 0;
}

View File

@@ -4,70 +4,118 @@
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding"/>
<script src="index.js"></script>
<script src="jq.js"></script>
<script type="text/javascript">
//sorry
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", "*.nannal.com"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//matomo.nannal.com/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
(function(f, a, t, h, o, m){
a[h]=a[h]||function(){
(a[h].q=a[h].q||[]).push(arguments)
};
o=f.createElement('script'),
m=f.getElementsByTagName('script')[0];
o.async=1; o.src=t; o.id='fathom-script';
m.parentNode.insertBefore(o,m)
})(document, window, '//fathom.nannal.com/tracker.js', 'fathom');
fathom('set', 'siteId', 'QYBFW');
fathom('trackPageview');
</script>
<noscript><p><img src="//matomo.nannal.com/matomo.php?idsite=1&amp;rec=1" style="border:0;" alt="" /></p></noscript>
</head>
<body>
<div class="controls">
<div class="Reigster-Container">
</br>Register
<h1>Embezzle</h1>
<div id="controls">
<div id="Reigster-Container">
<div id="faq">
<h2>How To Play</h2>
By joining a game you become apointed to the board of a multinational company who in the name of extreme altruism (and for some significant tax breaks) must distribute some of their immesne profits to lowly charities. As the cunning fox you are, you've setup your own charity and must now redirect as much of this firehose of funds from silly rinky-dink operations like oxfam to your own back pocket.
</br>
However, you can't be <i>entierly</i> blatant about it as, after each quaters funds are distributed, a board member must be fired as they are undoubtedly performing the heinous crime of cold-heartedly stealing what few morsels of funding the benevolent company has seen fit to bestow on the worlds most needy and vulnerable. <b>The swines!</b>
<ul>Join a board of directors</ul>
<ul>Distribute funds to yourown and other's charities</ul>
<ul>Vote out one of your fellow board members</ul>
<ul>Have the most capital in your charity when only two members remain on the board to win</ul>
</div>
</br>Register a player</br>
<input id="register" type="text" placeholder="Name"/> <button onclick="register()">Register</button>
</div>
<div class="Make-Container">
</br>Make
<div id="Make-Container">
</br>Make A game (Select a number of player slots)</br>
<input id="makeSeats" type="number"/> <button onclick="make()">Make</button>
</div>
<div class="Join-Container">
</br>Join
<div id="Join-Container">
</br>Join a game (Using a GameID)</br>
<input id="join" type="text" placeholder="Name"/> <button onclick="join()">Join</button>
</div>
<div class="Start-Container">
</br>Start
<div id="Start-Container">
</br>Start the game!</br>
<button onclick="start()">Start</button>
</div>
<div class="Donate-Container">
</br>Donate
<select id="donate" name="list">
<option value="x">x</option>
<div id="Donate-Container">
</br>Donate</br>
<select id="donate" name="list" class="donateInput">
<option value="stringthatbrickstheserver">If you can see this, you're being naughty</option>
</select>
<input id="amount" type="number">
<input id="amount" type="number" class="donateInput">
<button onclick="donate()">Donate</button>
</div>
<div class="Accuse-Container">
</br>Accuse
<div id="Accuse-Container">
</br>Accuse a player of embezzlement</br>
<input id="accuse" type="text" placeholder="Name"/> <button onclick="accuse()">Accuse</button>
<select id="accuse" name="list" class="accuseInput">
<option value="stringthatbrickstheserver">If you can see this, you're being naughty</option>
</select>
<button onclick="accuse()">Accuse</button>
</div>
</div>
<div id="info">
<div id="gameID"></div>
<div id="messages"></div>
<div id="games"></div>
<div id="gameInfo"></div>
<div id="playerInfo"></div>
<div id="myCharity"></div>
<div id="charityStatus"></div>
<div id="boardFunding"></div>
<div id="transactionLog"></div>
<div id="accusationLog"></div>
<div id="messages"></div>
</div>
</body>
</html>
</html>

View File

@@ -1,6 +1,5 @@
// Global Vars
serverAddr="http://localhost:3000"
serverAddr="https://embezzle-server.nannal.com"
ownerID=''
// ownerID='6298bc89-41cb-4cc7-84cd-7fd8e419f263'
gameID=''
@@ -24,6 +23,10 @@ function register(){
//hide register
//show make & join
//show list of games
cssHide("Reigster-Container")
cssShow("Make-Container")
cssShow("Join-Container")
listGames()
})
.catch((error) => {
@@ -37,7 +40,8 @@ function listGames(){
return response.json();
})
.then((data) => {
document.getElementById('messages').value='data.gamesArr'
gamesFormat(data)
cssShow("games")
console.log(data);
});
}
@@ -60,6 +64,16 @@ function make(){
// console.log(data)
gameID=data.gameID
gameData(gameID)
document.getElementById("gameID").innerHTML="<h2>Your gameID is:"+gameID+"</h2><p> share the gameID with any users you want to join your game</p>"
cssHide("games")
cssHide("Make-Container")
cssHide("Join-Container")
cssShow("messages")
cssShow("gameInfo")
cssShow("playerInfo")
cssShow("Start-Container")
})
.catch((error) => {
@@ -70,6 +84,15 @@ function make(){
function join(){
console.log("join")
gameID=document.getElementById('join').value
gameData(gameID)
cssHide("games")
cssHide("Make-Container")
cssHide("Join-Container")
cssShow("messages")
cssShow("gameInfo")
cssShow("playerInfo")
const data = {
ownerID: ownerID,
gameID: gameID };
@@ -83,11 +106,19 @@ function join(){
})
.then((response) => response.json())
.then((data) => {
document.getElementById("gameID").innerHTML="<h2>Your gameID is:"+gameID+"</h2><p> share the gameID with any users you want to join your game</p>"
// console.log(data)
gameData(gameID)
})
.catch((error) => {
console.error('Error:', error);
cssShow("games")
cssShow("Make-Container")
cssShow("Join-Container")
cssHide("messages")
cssHide("gameInfo")
});
}
@@ -105,14 +136,18 @@ function gameData(gameID) {
gameData(gameID)
clearInterval(checkIfStarted)
}, 1000)
if (document.getElementById("messages").innerText != "Game Name: "+data.name+", GameID: "+data.gameID) {
document.getElementById("messages").innerText="Game Name: "+data.name+", GameID: "+data.gameID
html="Waiting For "+data.name+" to start the game, "+data.players.length+"/"+data.seats+" seats are full</br>"
data.players.forEach(element => {
html=html+"Player: "+element.name+"</br>"
})
if (document.getElementById("messages").innerHTML != html) {
document.getElementById("messages").innerHTML=html
}
})
}
function start(){
console.log("start")
const data = {
ownerID: ownerID,
gameID: gameID };
@@ -127,7 +162,7 @@ function start(){
.then((response) => response.json())
.then((data) => {
console.log(data)
cssHide("Start-Container")
})
.catch((error) => {
console.error('Error:', error);
@@ -156,6 +191,7 @@ function donate(){
})
.then((response) => response.json())
.then((data) => {
donateFormat(data)
// console.log(data)
// gameData(gameID)
})
@@ -182,7 +218,7 @@ function accuse(){
.then((response) => response.json())
.then((data) => {
// console.log(data)
document.getElementById("accuseLog").innerText=data
accuseFormat(data)
// gameData(gameID)
})
.catch((error) => {
@@ -219,7 +255,7 @@ function status() {
//Quick Recurring updates
setInterval(function(){
statusint = setInterval(function(){
fetch(serverAddr+'/game/'+gameID+'/boardFunding', {
method: 'POST',
headers: {
@@ -249,9 +285,9 @@ function status() {
});
if (document.getElementById("donate").innerHTML != dropDownList){
document.getElementById("donate").innerHTML=dropDownList
statusObj.charitylist=data
// statusObj.charitylist=data
}
document.getElementById("charityStatus").innerHTML=charityStatusFormat(data)
charityStatusFormat(data)
});
@@ -260,9 +296,39 @@ function status() {
return response.json();
})
.then((data) => {
statusObj.playerlist=data
playerListFormat(data)
// statusObj.playerlist=data
// console.log(data);
});
fetch(serverAddr+'/game/'+gameID+'/accuseinfo')
.then((response) => {
return response.json();
})
.then((data) => {
accuseFormat(data)
// statusObj.playerlist=data
// console.log(data);
});
fetch(serverAddr+'/game/'+gameID+'/distributioninfo')
.then((response) => {
return response.json();
})
.then((data) => {
donateFormat(data)
// statusObj.playerlist=data
// console.log(data);
});
fetch(serverAddr+'/game/'+gameID+'/statusinfo')
.then((response) => {
return response.json();
})
.then((data) => {
statusFormat(data)
// statusObj.playerlist=data
// console.log(data);
});
// fdocument.getElementById("info").innerText=prettyprint(statusObj)
}, 3000)
}
@@ -276,12 +342,127 @@ function myCharityFormat(data) {
function charityStatusFormat(data) {
html=""
data.forEach(element => {
html=html+"<b>"+element.name+":</b> "+element.capital
data.charatiesArr.forEach(element => {
html=html+"<b>"+element.name+":</b> "+element.capital+"</br>"
})
return html
if (document.getElementById("charityStatus").innerHTML != html) {
document.getElementById("charityStatus").innerHTML=html
}
}
function boardFundingFormat(data) {
if (document.getElementById("boardFunding").innerHTML != "<b>My Funds: </b>"+data.funds) {
document.getElementById("boardFunding").innerHTML= "<b>My Funds: </b>"+data.funds
}
}
function donateFormat(data) {
html=""
data.log.forEach(element => {
html=html+element.donator+", donated "+element.amount+" to "+element.charity+"</br>"
})
if(document.getElementById("transactionLog").innerHTML != html){
document.getElementById("transactionLog").innerHTML=html
}
}
function accuseFormat(data) {
html=""
if(typeof data.winner != "undefined"){
document.getElementById("accusationLog").innerHTML="<h1>"+data.winner+" has won the game</h1>"
clearInterval(statusint)
}
else{
accusers=Object.keys(data.log)
accusers.forEach(element => {
html=html+element+" accuses "+data.log[element]+"</br>"
})
if(document.getElementById("accusationLog").innerHTML != html){
document.getElementById("accusationLog").innerHTML=html
}
}
}
function gamesFormat(data) {
html="<h4>Games:</h4></br>"
data.gamesArr.forEach(element => {
html=html+element.gameID+", "+element.name+"</br>"
})
if (document.getElementById("games").innerHTML != html) {
document.getElementById("games").innerHTML = html
}
}
function playerListFormat(data) {
html=""
accuseListFormat(data.playersArr)
data.playersArr.forEach(element => {
html=html+"<b>"+element.name+"</b>: Funds "+element.funds+", Status: "+element.status+"</br>"
})
if (document.getElementById("playerInfo").innerHTML != html){
document.getElementById("playerInfo").innerHTML=html
}
}
function statusFormat(data) {
if (document.getElementById("gameInfo").innerHTML != "<h1>Round Status: "+data.status+"</h1>") {
document.getElementById("gameInfo").innerHTML="<h1>Round Status: "+data.status+"</h1>"
}
if (data.status == "Distribution") {
cssHide("messages")
cssShow("gameInfo")
cssShow("myCharity")
cssShow("charityStatus")
cssShow("boardFunding")
cssShow("Donate-Container")
cssShow("transactionLog")
cssHide("messages")
cssHide("accusationLog")
cssHide("Accuse-Container")
}
else {
cssHide("Donate-Container")
cssShow("accusationLog")
cssShow("Accuse-Container")
}
}
function accuseListFormat(data){
dropDownList=""
data.forEach(element => {
dropDownList=dropDownList+'<option value="'+element.name+'">'+element.name+'</option>'
});
if (document.getElementById("accuse").innerHTML != dropDownList){
document.getElementById("accuse").innerHTML=dropDownList
// statusObj.charitylist=data
}
}
function cssHide(id){
if (document.getElementById(id).style.visibility != "Hidden") {
document.getElementById(id).style.lineHeight=0
document.getElementById(id).style.margin=0
document.getElementById(id).style.fontSize=0
document.getElementById(id).style.visibility="Hidden"
document.getElementById(id).style.size="0px"
document.getElementById(id).style.zIndex="100"
document.getElementById(id).style.scale="0"
}
}
function cssShow(id){
if (document.getElementById(id).style.visibility != "Visible") {
document.getElementById(id).style.lineHeight=1.6
document.getElementById(id).style.fontSize="Large"
document.getElementById(id).style.visibility="Visible"
document.getElementById(id).style.size="Auto"
document.getElementById(id).style.zIndex="0"
document.getElementById(id).style.scale="1"
}
}

File diff suppressed because one or more lines are too long