1
0

index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <!--
  2. Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  4. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  5. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  6. -->
  7. <!DOCTYPE html>
  8. <html>
  9. <head>
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <title>Yahtzee</title>
  12. <!--[if IE]>
  13. <style type="text/css" media="screen">
  14. body {
  15. behavior: url("/css/hack/csshover3.htc");
  16. }
  17. </style>
  18. <![endif]-->
  19. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  20. <link href='http://fonts.googleapis.com/css?family=Zeyada' rel='stylesheet' type='text/css'>
  21. <script src="lib/jquery-1.7.1.min.js" type="text/javascript" ></script>
  22. <link href="css/yahtzee.css" type="text/css" rel="stylesheet" media="screen, projection" />
  23. </head>
  24. <body>
  25. <div style="width: 50%;float: left;">
  26. <div class="dice empty" id="dice1"></div>
  27. <div class="dice empty" id="dice2"></div>
  28. <div class="dice empty" id="dice3"></div>
  29. <div class="dice empty" id="dice4"></div>
  30. <div class="dice empty" id="dice5"></div>
  31. <div class="dice empty" id="dice6"></div>
  32. <div class="clear"></div>
  33. <div>
  34. <span>Launch</span>
  35. <span id="launch"></span>
  36. </div>
  37. <a href="javascript:void(0)" id="launchBtn">Launch</a>
  38. <div>
  39. <dl>
  40. <dt>Three of a kind</dt>
  41. <dd>Three dice showing the same face</dd>
  42. <dd>Sum of all dice</dd>
  43. <dt>Four of a kind</dt>
  44. <dd>Four dice showing the same face</dd>
  45. <dd>Sum of all dice</dd>
  46. <dt>Full</dt>
  47. <dd>A three-of-a-kind and a pair</dd>
  48. <dd>25 points</dd>
  49. <dt>Small straight</dt>
  50. <dd>Four sequential dice</dd>
  51. <dd>30 points</dd>
  52. <dt>Large straight</dt>
  53. <dd>Five sequential dice</dd>
  54. <dd>40 points</dd>
  55. <dt>Yahtzee</dt>
  56. <dd>Five dice showing the same face</dd>
  57. <dd>50 points</dd>
  58. <dt>Chance</dt>
  59. <dd>Sum of all dice</dd>
  60. </dl>
  61. </div>
  62. <div id="scorePanel" style="display: none;">
  63. <table class="table table-bordered">
  64. <tr>
  65. <td>Upper grid score</td>
  66. <td id="upperScore" style="text-align: center"></td>
  67. </tr>
  68. <tr>
  69. <td>Bonus</td>
  70. <td id="bonus" style="text-align: center"></td>
  71. </tr>
  72. <tr>
  73. <td>Lower grid score</td>
  74. <td id="lowerScore" style="text-align: center"></td>
  75. </tr>
  76. <tr>
  77. <td><b>Total</b></td>
  78. <td id="totalScore" style="text-align: center"><b></b></td>
  79. </tr>
  80. </table>
  81. </div>
  82. </div>
  83. <div style="width: 50%;float: left;">
  84. <table border="1">
  85. <thead>
  86. <tr>
  87. <th style="text-align: center;">Combinaison</th>
  88. <th style="text-align: center;" width="84px">
  89. Score
  90. </th>
  91. <th style="text-align: center;" width="100px"></th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. <tr>
  96. <td>
  97. <span id="oneLabel">
  98. One
  99. </span>
  100. </td>
  101. <td style="text-align: center;">
  102. <span id="oneScore" class="score">&nbsp;</span>
  103. </td>
  104. <td>
  105. <a href="javascript:void(0)"id="oneKeep" data-id="one" class="keep">Keep</a>
  106. <a href="javascript:void(0)"id="oneTrash" data-id="one" class="trash">Trash</a>
  107. </td>
  108. </tr>
  109. <tr>
  110. <td>
  111. <span id="twoLabel">
  112. Two
  113. </span>
  114. </td>
  115. <td style="text-align: center;">
  116. <span id="twoScore" class="score">&nbsp;</span>
  117. </td>
  118. <td>
  119. <a href="javascript:void(0)"id="twoKeep" data-id="two" class="keep">Keep</a>
  120. <a href="javascript:void(0)"id="twoTrash" data-id="two" class="trash">Trash</a>
  121. </td>
  122. </tr>
  123. <tr>
  124. <td>
  125. <span id="threeLabel">
  126. Three
  127. </span>
  128. </td>
  129. <td style="text-align: center;">
  130. <span id="threeScore" class="score">&nbsp;</span>
  131. </td>
  132. <td>
  133. <a href="javascript:void(0)"id="threeKeep" data-id="three" class="keep">Keep</a>
  134. <a href="javascript:void(0)"id="threeTrash" data-id="three" class="trash">Trash</a>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td>
  139. <span id="fourLabel">
  140. Four
  141. </span>
  142. </td>
  143. <td style="text-align: center;">
  144. <span id="fourScore" class="score">&nbsp;</span>
  145. </td>
  146. <td>
  147. <a href="javascript:void(0)"id="fourKeep" data-id="four" class="keep">Keep</a>
  148. <a href="javascript:void(0)"id="fourTrash" data-id="four" class="trash">Trash</a>
  149. </td>
  150. </tr>
  151. <tr>
  152. <td>
  153. <span id="fiveLabel">
  154. Five
  155. </span>
  156. </td>
  157. <td style="text-align: center;">
  158. <span id="fiveScore" class="score">&nbsp;</span>
  159. </td>
  160. <td>
  161. <a href="javascript:void(0)"id="fiveKeep" data-id="five" class="keep">Keep</a>
  162. <a href="javascript:void(0)"id="fiveTrash" data-id="five" class="trash">Trash</a>
  163. </td>
  164. </tr>
  165. <tr>
  166. <td>
  167. <span id="sixLabel">
  168. Six
  169. </span>
  170. </td>
  171. <td style="text-align: center;">
  172. <span id="sixScore" class="score">&nbsp;</span>
  173. </td>
  174. <td>
  175. <a href="javascript:void(0)"id="sixKeep" data-id="six" class="keep">Keep</a>
  176. <a href="javascript:void(0)"id="sixTrash" data-id="six" class="trash">Trash</a>
  177. </td>
  178. </tr>
  179. </tbody>
  180. </table>
  181. <table border="1">
  182. <thead>
  183. <tr>
  184. <th style="text-align: center;">Combinaison</th>
  185. <th style="text-align: center;">Probability</th>
  186. <th style="text-align: center;" width="84px">
  187. Score
  188. </th>
  189. <th style="text-align: center;" width="100px"></th>
  190. </tr>
  191. </thead>
  192. <tbody>
  193. <tr>
  194. <td>
  195. <span id="threeOfAKindLabel">
  196. Three of a kind
  197. </span>
  198. </td>
  199. <td>
  200. <div class="progress">
  201. <div class="bar" id="threeOfAKindBar"></div>
  202. <span id="threeOfAKindProbability" style="padding-left: 1px;">&nbsp;</span>
  203. </div>
  204. </td>
  205. <td style="text-align: center;">
  206. <span id="threeOfAKindScore" class="score">&nbsp;</span>
  207. </td>
  208. <td>
  209. <a href="javascript:void(0)"id="threeOfAKindKeep" data-id="threeOfAKind" class="keep">Keep</a>
  210. <a href="javascript:void(0)"id="threeOfAKindTrash" data-id="threeOfAKind" class="trash">Trash</a>
  211. </td>
  212. </tr>
  213. <tr>
  214. <td>
  215. <span id="fourOfAKindLabel">
  216. Four of a kind
  217. </span>
  218. </td>
  219. <td>
  220. <div class="progress">
  221. <div class="bar" id="fourOfAKindBar"></div>
  222. <span id="fourOfAKindProbability" style="padding-left: 1px;">&nbsp;</span>
  223. </div>
  224. </td>
  225. <td style="text-align: center;">
  226. <span id="fourOfAKindScore" class="score">&nbsp;</span>
  227. </td>
  228. <td>
  229. <a href="javascript:void(0)"id="fourOfAKindKeep" data-id="fourOfAKind" class="keep">Keep</a>
  230. <a href="javascript:void(0)"id="fourOfAKindTrash" data-id="fourOfAKind" class="trash">Trash</a>
  231. </td>
  232. </tr>
  233. <tr>
  234. <td>
  235. <span id="fullLabel">
  236. Full
  237. </span>
  238. </td>
  239. <td>
  240. <div class="progress">
  241. <div class="bar" id="fullBar"></div>
  242. <span id="fullProbability" style="padding-left: 1px;">&nbsp;</span>
  243. </div>
  244. </td>
  245. <td style="text-align: center;">
  246. <span id="fullScore" class="score">&nbsp;</span>
  247. </td>
  248. <td>
  249. <a href="javascript:void(0)"id="fullKeep" data-id="full" class="keep">Keep</a>
  250. <a href="javascript:void(0)"id="fullTrash" data-id="full" class="trash">Trash</a>
  251. </td>
  252. </tr>
  253. <tr>
  254. <td>
  255. <span id="smallStraightLabel">
  256. Small straight
  257. </span>
  258. </td>
  259. <td>
  260. <div class="progress">
  261. <div class="bar" id="smallStraightBar"></div>
  262. <span id="smallStraightProbability" style="padding-left: 1px;">&nbsp;</span>
  263. </div>
  264. </td>
  265. <td style="text-align: center;">
  266. <span id="smallStraightScore" class="score">&nbsp;</span>
  267. </td>
  268. <td>
  269. <a href="javascript:void(0)"id="smallStraightKeep" data-id="smallStraight" class="keep">Keep</a>
  270. <a href="javascript:void(0)"id="smallStraightTrash" data-id="smallStraight" class="trash">Trash</a>
  271. </td>
  272. </tr>
  273. <tr>
  274. <td>
  275. <span id="largeStraightLabel">
  276. Large straight
  277. </span>
  278. </td>
  279. <td>
  280. <div class="progress">
  281. <div class="bar" id="largeStraightBar"></div>
  282. <span id="largeStraightProbability" style="padding-left: 1px;">&nbsp;</span>
  283. </div>
  284. </td>
  285. <td style="text-align: center;">
  286. <span id="largeStraightScore" class="score">&nbsp;</span>
  287. </td>
  288. <td>
  289. <a href="javascript:void(0)"id="largeStraightKeep" data-id="largeStraight" class="keep">Keep</a>
  290. <a href="javascript:void(0)"id="largeStraightTrash" data-id="largeStraight" class="trash">Trash</a>
  291. </td>
  292. </tr>
  293. <tr>
  294. <td>
  295. <span id="yahtzeeLabel">
  296. Yahtzee
  297. </span>
  298. </td>
  299. <td>
  300. <div class="progress">
  301. <div class="bar" id="yahtzeeBar"></div>
  302. <span id="yahtzeeProbability" style="padding-left: 1px;">&nbsp;</span>
  303. </div>
  304. </td>
  305. <td style="text-align: center;">
  306. <span id="yahtzeeScore" class="score">&nbsp;</span>
  307. </td>
  308. <td>
  309. <a href="javascript:void(0)"id="yahtzeeKeep" data-id="yahtzee" class="keep">Keep</a>
  310. <a href="javascript:void(0)"id="yahtzeeTrash" data-id="yahtzee" class="trash">Trash</a>
  311. </td>
  312. </tr>
  313. <tr>
  314. <td>
  315. <span id="luckLabel">
  316. Chance
  317. </span>
  318. </td>
  319. <td>
  320. <div class="progress">
  321. <div class="bar" id="luckBar"></div>
  322. <span id="luckProbability" style="padding-left: 1px;">&nbsp;</span>
  323. </div>
  324. </td>
  325. <td style="text-align: center;">
  326. <span id="luckScore" class="score">&nbsp;</span>
  327. </td>
  328. <td>
  329. <a href="javascript:void(0)"id="luckKeep" data-id="luck" class="keep">Keep</a>
  330. <a href="javascript:void(0)"id="luckTrash" data-id="luck" class="trash">Trash</a>
  331. </td>
  332. </tr>
  333. </tbody>
  334. </table>
  335. </div>
  336. </div>
  337. </div> <!-- End of span9 -->
  338. <script src="js/yahtzee.js" type="text/javascript" ></script>
  339. <script type="text/javascript">
  340. $(document).ready(function () {
  341. $(".dice").click(function(evt) {
  342. if( $(this).hasClass("selected") )
  343. $(this).removeClass("selected");
  344. else
  345. $(this).addClass("selected");
  346. });
  347. $(".keep").click(function(evt) {
  348. console.log("Keeping " + $(this).attr('data-id'));
  349. Yahtzee.keep($(this).attr('data-id'));
  350. });
  351. $(".trash").click(function(evt) {
  352. console.log("Trashing " + $(this).attr('data-id'));
  353. Yahtzee.trash($(this).attr('data-id'));
  354. });
  355. $("#launchBtn").click(function() {
  356. Yahtzee.shuffle();
  357. Yahtzee.findCombinaisons();
  358. if( Yahtzee.launch < 3 )
  359. Yahtzee.findPossibilities();
  360. });
  361. });
  362. </script>
  363. </body>
  364. </html>