1
0

index.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
  4. 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:
  5. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  6. 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.
  7. -->
  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. <link href="https://fonts.googleapis.com/css?family=Fredericka+the+Great" rel="stylesheet">
  22. <script src="lib/jquery-1.7.1.min.js" type="text/javascript" ></script>
  23. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js">
  24. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  25. <link href="css/yahtzee.css" type="text/css" rel="stylesheet" media="screen, projection" />
  26. </head>
  27. <body>
  28. <div id="banner"class="col-xs-12">
  29. <h1>FEBBWEISS' YAHTZEE!</h1>
  30. </div>
  31. <div class="container">
  32. <div class="row">
  33. <div class="col-xs-12 col-xl-4">
  34. <div>
  35. <dl><br>
  36. <dt>Three of a kind</dt>
  37. <dd>Three dice showing the same face (Ex. Three 3's)</dd>
  38. <dd>Scoring: Sum of all dice</dd>
  39. <br>
  40. <dt>Four of a kind</dt>
  41. <dd>Four dice showing the same face (Ex. Four 5's)</dd>
  42. <dd>Scoring: Sum of all dice</dd>
  43. <br>
  44. <dt>Full House</dt>
  45. <dd>A three-of-a-kind and a pair (Ex. Three 1's and Two 4's)</dd>
  46. <dd>Scoring: 25 points</dd>
  47. <br>
  48. <dt>Small straight</dt>
  49. <dd>Four sequential dice (Ex. 2, 3, 4, 5)</dd>
  50. <dd>Scoring: 30 points</dd>
  51. <br>
  52. <dt>Large straight</dt>
  53. <dd>Five sequential dice (Ex. 2, 3, 4, 5, 6)</dd>
  54. <dd>Scoring: 40 points</dd>
  55. <br>
  56. <dt>Yahtzee</dt>
  57. <dd>Five dice showing the same face (Ex. Five 4's)</dd>
  58. <dd>Scoring: 50 points</dd>
  59. <br>
  60. <dt>Chance</dt>
  61. <dd>Scoring: Sum of all dice</dd>
  62. </dl>
  63. </div>
  64. </div>
  65. <div class="col-xs-12 col-xl-4">
  66. <table border="1">
  67. <thead>
  68. <tr>
  69. <th style="text-align: center;">Combination</th>
  70. <th style="text-align: center;" width="84px">
  71. Score
  72. </th>
  73. <th style="text-align: center;" width="100px">Options</th>
  74. </tr>
  75. </thead>
  76. <tbody>
  77. <tr>
  78. <td>
  79. <span id="oneLabel">
  80. Ones
  81. </span>
  82. </td>
  83. <td style="text-align: center;">
  84. <span id="oneScore" class="score">&nbsp;</span>
  85. </td>
  86. <td>
  87. <a href="javascript:void(0)"id="oneKeep" data-id="one" class="keep">Keep</a>
  88. <a href="javascript:void(0)"id="oneTrash" data-id="one" class="trash">Trash</a>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td>
  93. <span id="twoLabel">
  94. Twos
  95. </span>
  96. </td>
  97. <td style="text-align: center;">
  98. <span id="twoScore" class="score">&nbsp;</span>
  99. </td>
  100. <td>
  101. <a href="javascript:void(0)"id="twoKeep" data-id="two" class="keep">Keep</a>
  102. <a href="javascript:void(0)"id="twoTrash" data-id="two" class="trash">Trash</a>
  103. </td>
  104. </tr>
  105. <tr>
  106. <td>
  107. <span id="threeLabel">
  108. Threes
  109. </span>
  110. </td>
  111. <td style="text-align: center;">
  112. <span id="threeScore" class="score">&nbsp;</span>
  113. </td>
  114. <td>
  115. <a href="javascript:void(0)"id="threeKeep" data-id="three" class="keep">Keep</a>
  116. <a href="javascript:void(0)"id="threeTrash" data-id="three" class="trash">Trash</a>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td>
  121. <span id="fourLabel">
  122. Fours
  123. </span>
  124. </td>
  125. <td style="text-align: center;">
  126. <span id="fourScore" class="score">&nbsp;</span>
  127. </td>
  128. <td>
  129. <a href="javascript:void(0)"id="fourKeep" data-id="four" class="keep">Keep</a>
  130. <a href="javascript:void(0)"id="fourTrash" data-id="four" class="trash">Trash</a>
  131. </td>
  132. </tr>
  133. <tr>
  134. <td>
  135. <span id="fiveLabel">
  136. Fives
  137. </span>
  138. </td>
  139. <td style="text-align: center;">
  140. <span id="fiveScore" class="score">&nbsp;</span>
  141. </td>
  142. <td>
  143. <a href="javascript:void(0)"id="fiveKeep" data-id="five" class="keep">Keep</a>
  144. <a href="javascript:void(0)"id="fiveTrash" data-id="five" class="trash">Trash</a>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td>
  149. <span id="sixLabel">
  150. Sixes
  151. </span>
  152. </td>
  153. <td style="text-align: center;">
  154. <span id="sixScore" class="score">&nbsp;</span>
  155. </td>
  156. <td>
  157. <a href="javascript:void(0)"id="sixKeep" data-id="six" class="keep">Keep</a>
  158. <a href="javascript:void(0)"id="sixTrash" data-id="six" class="trash">Trash</a>
  159. </td>
  160. </tr>
  161. <tr>
  162. <td>
  163. <span>
  164. Upper Score
  165. </span>
  166. </td>
  167. <td style="text-align: center;">
  168. <span class="score" id="topScore"></span>
  169. </td>
  170. </tr>
  171. </tbody>
  172. </table>
  173. <br>
  174. <div id="btn">
  175. <a href="javascript:void(0)" id="launchBtn">Roll the Dice</a>
  176. </div>
  177. <br>
  178. <div>
  179. <span>Dice Roll #:</span>
  180. <span id="launch"></span>
  181. </div>
  182. <br>
  183. <div>
  184. <div class="dice empty" id="dice1"></div>
  185. <div class="dice empty" id="dice2"></div>
  186. <div class="dice empty" id="dice3"></div>
  187. <div class="dice empty" id="dice4"></div>
  188. <div class="dice empty" id="dice5"></div>
  189. <div class="dice empty" id="dice6"></div>
  190. <div class="clear"></div>
  191. </div>
  192. <div>
  193. </div>
  194. </div>
  195. <div class="col-xs-12 col-xl-4">
  196. <table border="1">
  197. <thead>
  198. <tr>
  199. <th style="text-align: center;">Combination</th>
  200. <th style="text-align: center;">Probability</th>
  201. <th style="text-align: center;" width="84px">
  202. Score
  203. </th>
  204. <th style="text-align: center;" width="100px">Options</th>
  205. </tr>
  206. </thead>
  207. <tbody>
  208. <tr>
  209. <td>
  210. <span id="threeOfAKindLabel">
  211. Three of a kind
  212. </span>
  213. </td>
  214. <td>
  215. <div class="progress">
  216. <div class="bar" id="threeOfAKindBar"></div>
  217. <span id="threeOfAKindProbability" style="padding-left: 1px;">&nbsp;</span>
  218. </div>
  219. </td>
  220. <td style="text-align: center;">
  221. <span id="threeOfAKindScore" class="score">&nbsp;</span>
  222. </td>
  223. <td>
  224. <a href="javascript:void(0)"id="threeOfAKindKeep" data-id="threeOfAKind" class="keep">Keep</a>
  225. <a href="javascript:void(0)"id="threeOfAKindTrash" data-id="threeOfAKind" class="trash">Trash</a>
  226. </td>
  227. </tr>
  228. <tr>
  229. <td>
  230. <span id="fourOfAKindLabel">
  231. Four of a kind
  232. </span>
  233. </td>
  234. <td>
  235. <div class="progress">
  236. <div class="bar" id="fourOfAKindBar"></div>
  237. <span id="fourOfAKindProbability" style="padding-left: 1px;">&nbsp;</span>
  238. </div>
  239. </td>
  240. <td style="text-align: center;">
  241. <span id="fourOfAKindScore" class="score">&nbsp;</span>
  242. </td>
  243. <td>
  244. <a href="javascript:void(0)"id="fourOfAKindKeep" data-id="fourOfAKind" class="keep">Keep</a>
  245. <a href="javascript:void(0)"id="fourOfAKindTrash" data-id="fourOfAKind" class="trash">Trash</a>
  246. </td>
  247. </tr>
  248. <tr>
  249. <td>
  250. <span id="fullLabel">
  251. Full House
  252. </span>
  253. </td>
  254. <td>
  255. <div class="progress">
  256. <div class="bar" id="fullBar"></div>
  257. <span id="fullProbability" style="padding-left: 1px;">&nbsp;</span>
  258. </div>
  259. </td>
  260. <td style="text-align: center;">
  261. <span id="fullScore" class="score">&nbsp;</span>
  262. </td>
  263. <td>
  264. <a href="javascript:void(0)"id="fullKeep" data-id="full" class="keep">Keep</a>
  265. <a href="javascript:void(0)"id="fullTrash" data-id="full" class="trash">Trash</a>
  266. </td>
  267. </tr>
  268. <tr>
  269. <td>
  270. <span id="smallStraightLabel">
  271. Small Straight
  272. </span>
  273. </td>
  274. <td>
  275. <div class="progress">
  276. <div class="bar" id="smallStraightBar"></div>
  277. <span id="smallStraightProbability" style="padding-left: 1px;">&nbsp;</span>
  278. </div>
  279. </td>
  280. <td style="text-align: center;">
  281. <span id="smallStraightScore" class="score">&nbsp;</span>
  282. </td>
  283. <td>
  284. <a href="javascript:void(0)"id="smallStraightKeep" data-id="smallStraight" class="keep">Keep</a>
  285. <a href="javascript:void(0)"id="smallStraightTrash" data-id="smallStraight" class="trash">Trash</a>
  286. </td>
  287. </tr>
  288. <tr>
  289. <td>
  290. <span id="largeStraightLabel">
  291. Large Straight
  292. </span>
  293. </td>
  294. <td>
  295. <div class="progress">
  296. <div class="bar" id="largeStraightBar"></div>
  297. <span id="largeStraightProbability" style="padding-left: 1px;">&nbsp;</span>
  298. </div>
  299. </td>
  300. <td style="text-align: center;">
  301. <span id="largeStraightScore" class="score">&nbsp;</span>
  302. </td>
  303. <td>
  304. <a href="javascript:void(0)"id="largeStraightKeep" data-id="largeStraight" class="keep">Keep</a>
  305. <a href="javascript:void(0)"id="largeStraightTrash" data-id="largeStraight" class="trash">Trash</a>
  306. </td>
  307. </tr>
  308. <tr>
  309. <td>
  310. <span id="yahtzeeLabel">
  311. Yahtzee
  312. </span>
  313. </td>
  314. <td>
  315. <div class="progress">
  316. <div class="bar" id="yahtzeeBar"></div>
  317. <span id="yahtzeeProbability" style="padding-left: 1px;">&nbsp;</span>
  318. </div>
  319. </td>
  320. <td style="text-align: center;">
  321. <span id="yahtzeeScore" class="score">&nbsp;</span>
  322. </td>
  323. <td>
  324. <a href="javascript:void(0)"id="yahtzeeKeep" data-id="yahtzee" class="keep">Keep</a>
  325. <a href="javascript:void(0)"id="yahtzeeTrash" data-id="yahtzee" class="trash">Trash</a>
  326. </td>
  327. </tr>
  328. <tr>
  329. <td>
  330. <span id="luckLabel">
  331. Chance
  332. </span>
  333. </td>
  334. <td>
  335. <div class="progress">
  336. <div class="bar" id="luckBar"></div>
  337. <span id="luckProbability" style="padding-left: 1px;">&nbsp;</span>
  338. </div>
  339. </td>
  340. <td style="text-align: center;">
  341. <span id="luckScore" class="score">&nbsp;</span>
  342. </td>
  343. <td>
  344. <a href="javascript:void(0)"id="luckKeep" data-id="luck" class="keep">Keep</a>
  345. <a href="javascript:void(0)"id="luckTrash" data-id="luck" class="trash">Trash</a>
  346. </td>
  347. </tr>
  348. <tr>
  349. <td>
  350. <span>
  351. Lower Score
  352. </span>
  353. </td>
  354. <td>
  355. </td>
  356. <td style="text-align: center;">
  357. <span id="bottomScore" class="score"></span>
  358. </td>
  359. </tr>
  360. </tbody>
  361. </table>
  362. <br>
  363. <div id="scorePanel" style="display: none;">
  364. <table class="table table-bordered">
  365. <tr>
  366. <th>Final Score</th>
  367. </tr>
  368. <tr>
  369. <td>Upper grid score</td>
  370. <td id="upperScore" style="text-align: center"></td>
  371. </tr>
  372. <tr>
  373. <td>Bonus</td>
  374. <td id="bonus" style="text-align: center"></td>
  375. </tr>
  376. <tr>
  377. <td>Lower grid score</td>
  378. <td id="lowerScore" style="text-align: center"></td>
  379. </tr>
  380. <tr>
  381. <td><b>Total</b></td>
  382. <td id="totalScore" style="text-align: center"><b></b></td>
  383. </tr>
  384. </table>
  385. </div>
  386. </div>
  387. </div>
  388. </div>
  389. <script src="js/yahtzee.js" type="text/javascript" ></script>
  390. <script type="text/javascript">
  391. $(document).ready(function ()
  392. {
  393. $(".dice").click(function(evt)
  394. {
  395. if( $(this).hasClass("selected") )
  396. $(this).removeClass("selected");
  397. else
  398. $(this).addClass("selected");
  399. });
  400. $(".keep").click(function(evt)
  401. {
  402. console.log("Keeping " + $(this).attr('data-id'));
  403. Yahtzee.keep($(this).attr('data-id'));
  404. });
  405. $(".trash").click(function(evt)
  406. {
  407. console.log("Trashing " + $(this).attr('data-id'));
  408. Yahtzee.trash($(this).attr('data-id'));
  409. });
  410. $("#launchBtn").click(function()
  411. {
  412. Yahtzee.shuffle();
  413. Yahtzee.findCombinations();
  414. if( Yahtzee.launch < 3 )
  415. Yahtzee.findPossibilities();
  416. });
  417. });
  418. </script>
  419. </body>
  420. </html>