-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit-and-reveal-v1.html
259 lines (182 loc) · 10 KB
/
commit-and-reveal-v1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Commit and Reveal</title>
<link rel="stylesheet" href="./reset.css">
<link rel="stylesheet" href="./style.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js" defer></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" defer></script>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<script src="./commit-and-reveal.js" defer></script>
</head>
<body>
<div id="app">
<header>
<a href="#" v-bind:class="showHome" @click="showHome"> <img class="logo" src="./notes1.png" alt="logo"> </a>
<span id="jackpot"> ${{jackpot}} </span>
<a href="#" v-bind:class="showMore" @click="showRules"> Rules</a>
<a href="#" v-bind:class="showPlay" @click="showPlay"> Play</a>
<a href="#" v-bind:class="showAccount" @click="showAccount"> <img src="1.png" alt="me" > </a>
</header>
<main>
<div id="home">
<img id="dai" src="dai.jpg">
</div>
<div id="plans" style="display: none">
<h2>My plans for this round</h2>
<div id="form">
<button v-on:click="plans='steal'; plans=='' ? players.push(0) : players[players.length-1]=0; addStake" v-bind:class="[{active: true}, plans=='steal' ? focusSteal : '']">Steal </button>
<button v-on:click="plans='share'; plans=='' ? players.push(1) : players[players.length-1]=1" v-bind:class="[{active: true}, plans=='share' ? focusShare : '']">Share </button>
<button v-on:click="plans='block'; plans=='' ? players.push(2) : players[players.length-1]=2" v-bind:class="[{active: true},plans=='block' ? focusBlock : '']">Block </button>
</div>
</div>
<div id="actions" style="display: none">
<h2>My action for this round</h2>
<span id="timer">Timer</span>
<div id="form">
<button v-on:click="showResults('steal')" v-bind:disabled="noteEmpty" v-bind:class="[{active: !noteEmpty}, move=='steal' ? focusSteal : '']">Steal </button>
<button v-on:click="showResults('share')" v-bind:disabled="noteEmpty" v-bind:class="[{active: !noteEmpty}, move=='share' ? focusShare : '']">Share </button>
<button v-on:click="showResults('block')" v-bind:disabled="noteEmpty" v-bind:class="[{active: !noteEmpty}, move=='block' ? focusBlock : '']">Block </button>
</div>
</div>
<div id="reveal" style="display: none">
<div id="steakholders">
<h2>Stakeholders</h2>
<span v-for="player in players">
<span v-bind:class="[player==0 ? red : '' , player==1 ? green : '', player==2 ? grey : '']" ></span>
</span>
</div>
</div>
<div id="results" style="display: none">
<h2>Your Results</h2>
<div id="my-results">
<h1>YOU {{move}} </h1>
<h1> {{result}} </h1>
</div>
</div>
<div id="rules" style="display: none">
<h2>How to Play "Who stole the cookie from the cookie jar</h2>
<video width="320" height="240" controls>
<source src="PrisonersDilemma.mp4" type="video/mp4">
</video>
<!--
<iframe width="420" height="315"
src="https://vimeo.com/276045361/3660b5fee7">
</iframe>
-->
<p>
<em>SweepStake!</em> is a modified prisoners dilemma where you must decide to share or steal a pot of DAI. </p>
<p> <strong>Step 1</strong> – Under Account put in a stake to join a game. Each game costs 10 DAI.<br/>
<strong>Step 2</strong> – You can tell other players how you are going to vote with the broadcast buttons. Pressing these buttons changes the color of the circle that represents you. However, you might not want to trust everything you see as lying is encouraged!</p>
<ul>
<li>Green = I want to share.</li>
<li>Red = I want to steal.</li>
<li>Blue = I want to block.</li>
</ul>
<p> <strong>Step 3</strong> – Commit your action for the round before the time runs out. You can share, steal, or block (see How to Win/Lose below). If you do not take an action you will lose and are removed from the player pool.</p>
<p><strong>Step 4</strong> – When the commit count down clock expires all players actions are revealed. Players then either win, lose, or play in the next round. If the game goes to another round the losing players are removed but the pot remains. Ultimately some player or players will win.</p>
<h2>How to Win/Lose</h2>
<p>There are 7 ways to win/lose at SweepStake! depending on what players do in a round:
<ul>
<li>All Players Share – Everyone wins. The pot is split between all players.</li>
<li>All Players Steal – Everyone Loses. No one wins the pot. The pot roles over to a new game.</li>
<li>All Players Block – Everyone Loses. No one wins the pot. The pot roles over to a new game.</li>
<li>Player/s Share & Player/s Steal – All stealing players win. Stealing players split the pot.</li>
<li>Player/s Share & Player/s Block – All blocking players are eliminated. The game continues onto the next round with remaining players.</li>
<li>Player/s Steal & Player/s Block – All stealing players are eliminated. The game continues onto the next round with remaining players.</li>
<li>Player/s Steal & Player/s Share & Player/s Block – All stealing players are eliminated. The game continues onto the next round with remaining players. </li>
</p>
</div>
<div id="about" style="display: none">
<h2> username: {{username}} </h2>
<h2> bio: {{bio}}</h2> <br />
<div v-for="note in notes" id="notes">
<h4>{{ note }} </h4>
</div>
</div>
</main>
</div>
<script>
// Set the date we're counting down to
var countDownDate = new Date("Oct 1, 2019 8:00:00").getTime();
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("timer").innerText=hours+":"+minutes+":"+seconds
var interest=0;
// Update the count down every 15 seconds
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
if (seconds<10) {seconds="0"+seconds}
if (minutes<10) {minutes="0"+minutes}
document.getElementById("timer").innerText=hours+":"+minutes+":"+seconds
interest=interest+Math.floor(Math.random()*10);
document.getElementById("jackpot").innerText="$"+interest.toFixed(2).replace(/\d(?=(\d{3})+.)/g, '$&,');
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("days").innerText="00"
document.getElementById("hours").innerText="00"
document.getElementById("minutes").innerText="00"
players.push(1)
}
}, 1000);
</script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
font: normal 16px 'Roboto', sans-serif;
}
.countdown-container ul{
list-style: none;
display: inline;
position:absolute;
top: 83px;
left: 33px;
margin: 0;
padding: 0;
}
.countdown-container {
display: flex;
font: 'Roboto', sans-serif;
}
.countdown-container li{
display: inline-block;
font-size: 3em;
margin-right: 9px;
padding-left: 0;
width: 74px;
text-align: center;
}
span#timer, span#timer-1 {
position: absolute;
top: 15px;
right: 20px;
display: inline-block;
text-align: center;
font-size: 1.5em;
}
</style>
</body>
</html>