index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <?php require_once 'header.php'; ?>
  5. <title>Dominion Randomizer</title>
  6. <script type="text/javascript" src="scripts/cards.js"></script>
  7. <script type="text/javascript">
  8. $.dominion = {};
  9. function drawCards(table, cards)
  10. {
  11. if (typeof(cards) == typeof(undefined))
  12. {
  13. return;
  14. }
  15. table.html("");
  16. var row = $("<tr>").appendTo(table);
  17. var count = 0;
  18. cards.forEach(function(card)
  19. {
  20. $(card.drawTableCell(true, true)).appendTo(row);
  21. count++;
  22. if (count % 10 == 0)
  23. {
  24. row = $("<tr>").appendTo(table);
  25. }
  26. }
  27. );
  28. row.append($("<td />", {style : "width:*%;"}));
  29. }
  30. function loadCards()
  31. {
  32. var result = [];
  33. var dataArray = {};
  34. $("input").each(function()
  35. {
  36. var input = $(this);
  37. var name = typeof input.attr('name') === typeof undefined ? input.attr('id'):input.attr('name');
  38. if (input.is(":checkbox"))
  39. {
  40. if (input.is(":checked"))
  41. {
  42. dataArray[name] = "y";
  43. }
  44. else
  45. {
  46. dataArray[name] = "n";
  47. }
  48. }
  49. else
  50. {
  51. if (!input.is(":radio") || input.is(":checked"))
  52. {
  53. dataArray[name] = input.val();
  54. }
  55. }
  56. if (typeof(dataArray[name]) != typeof(undefined))
  57. {
  58. $.cookie(name, dataArray[name]);
  59. }
  60. });
  61. $.ajax(
  62. {
  63. type: "POST",
  64. url: "scripts/getCards.php",
  65. async: false,
  66. data: dataArray,
  67. cache: false
  68. })
  69. .done(function(data)
  70. {
  71. data = data.split(';');
  72. for (i = 0; i < data.length; i++)
  73. {
  74. result[i] = [];
  75. data[i] = data[i].split('\n');
  76. for (j=0; j<data[i].length; j++)
  77. {
  78. data[i][j] = data[i][j].split(',');
  79. var note = data[i][j].length > 4?data[i][j][4]:null;
  80. result[i][j] = new Card(
  81. data[i][j][0],
  82. parseInt(data[i][j][1]),
  83. data[i][j][2],
  84. parseInt(data[i][j][3]),
  85. note
  86. );
  87. }
  88. }
  89. });
  90. return result;
  91. }
  92. function drawAllCards()
  93. {
  94. drawCards($("#cardTable"), $.dominion.kingdoms);
  95. drawCards($("#cardTableNonKingdom"), $.dominion.nonkingdoms);
  96. }
  97. function sortAllCards()
  98. {
  99. var sortArray = new Array();
  100. var i = 0;
  101. $("#sortBy li").each(function() {sortArray[i++] = $(this).text();});
  102. $.dominion.kingdoms = sortCards($.dominion.kingdoms, sortArray);
  103. $.dominion.nonkingdoms = sortCards($.dominion.nonkingdoms, sortArray);
  104. $.cookie("order", sortArray.join("->"));
  105. }
  106. $(document).ready(function()
  107. {
  108. $("#content").masonry();
  109. $("#loadButton").bind("click", function()
  110. {
  111. var cards = loadCards();
  112. $.dominion.kingdoms = cards[0];
  113. $.dominion.nonkingdoms = cards[1];
  114. $.dominion.blackMarketDeck = cards[2];
  115. sortAllCards();
  116. drawAllCards();
  117. if (typeof($.dominion.blackMarketDeck) !== typeof(undefined))
  118. {
  119. $("#blackMarketInterface").css("display", "block");
  120. }
  121. });
  122. $(".promoCard").bind("change", function()
  123. {
  124. if ($( this ).is(":checked"))
  125. {
  126. if (!$("#promCheck").is(":checked"))
  127. {
  128. $("#promCheck").prop('checked', true);
  129. }
  130. }
  131. else
  132. {
  133. if ($(".promoCard:checked").length == 0)
  134. {
  135. $("#promCheck").prop('checked', false);
  136. }
  137. }
  138. });
  139. $("#promCheck").bind("change", function()
  140. {
  141. if ($( this ).is(":checked"))
  142. {
  143. $(".promoCard").prop('checked', true);
  144. }
  145. else
  146. {
  147. $(".promoCard").prop('checked', false);
  148. }
  149. });
  150. $("#limitAlchCheck").bind("change", function()
  151. {
  152. if ($( this ).is(":checked"))
  153. {
  154. $("#alchCheck").prop('checked', true);
  155. }
  156. });
  157. $("#alchCheck").bind("change", function()
  158. {
  159. if (!$( this ).is(":checked"))
  160. {
  161. $("#limitAlchCheck").prop('checked', false);
  162. }
  163. });
  164. $("#platColoTogether").bind("change", function()
  165. {
  166. if ($(this).is(':checked'))
  167. {
  168. $("#useBoth").css("display", "block");
  169. $("#usePlat").css("display", "none");
  170. $("#useColo").css("display", "none");
  171. }
  172. else
  173. {
  174. $("#useBoth").css("display", "none");
  175. $("#usePlat").css("display", "block");
  176. $("#useColo").css("display", "block");
  177. }
  178. $("#content").masonry();
  179. });
  180. if (typeof($.cookie("order")) != typeof(undefined))
  181. {
  182. var order = $.cookie("order").split("->");
  183. $("#sortBy").html("");
  184. for (var i = 0; i < order.length; i++)
  185. {
  186. $("#sortBy").append("<li>"+order[i]+"</li>");
  187. }
  188. }
  189. $("#sortBy").sortable()
  190. .disableSelection()
  191. .bind("sortupdate", function(event, ui)
  192. {
  193. sortAllCards();
  194. drawAllCards();
  195. })
  196. .find("li")
  197. .prepend(
  198. $("<span />", {class: "ui-icon ui-icon-arrowthick-2-n-s"})
  199. .css("display", "inline-block")
  200. );
  201. $("input").each(function()
  202. {
  203. var input = $(this);
  204. var name = typeof input.attr('name') === typeof undefined ? input.attr('id'):input.attr('name');
  205. if (typeof($.cookie(name)) != typeof(undefined))
  206. {
  207. if (input.is(":checkbox"))
  208. {
  209. input.prop('checked', $.cookie(name) == "y");
  210. }
  211. else if (input.is(":radio"))
  212. {
  213. input.prop('checked', $.cookie(name) == input.val());
  214. }
  215. else if (!input.is(":button"))
  216. {
  217. input.val($.cookie(name));
  218. }
  219. input.change();
  220. }
  221. });
  222. }
  223. );
  224. </script>
  225. </head>
  226. <body>
  227. <h1>Dominion Utility Dev</h1>
  228. <div style="width: 100%;">
  229. <form id="content" name="content" style="max-width: 1100px; display: block;">
  230. <div id="sets" class="border">
  231. <input type="button" value="Check All" onclick="$('#sets input').each(function() {this.checked = true;});" />
  232. <input type="button" value="Check None" onclick="$('#sets input').each(function() {this.checked = false;});" /><br />
  233. <input type="checkbox" id="baseCheck" /><label>Base</label><br />
  234. <input type="checkbox" id="intrCheck" /><label>Intrigue</label><br />
  235. <input type="checkbox" id="seasCheck" /><label>Seaside</label><br />
  236. <input type="checkbox" id="alchCheck" /><label>Alchemy</label><br />
  237. <div class="subset">
  238. <input id="limitAlchCheck" type="checkbox" name="alchLimit" /><label>3-5 Alchemy if used</label><br />
  239. </div>
  240. <input type="checkbox" id="prosCheck" /><label>Prosperity</label><br />
  241. <input type="checkbox" id="cornCheck" /><label>Cornucopia</label><br />
  242. <input type="checkbox" id="hintCheck" /><label>Hinterlands</label><br />
  243. <input type="checkbox" id="darkCheck" /><label>Dark Ages</label><br />
  244. <input type="checkbox" id="guilCheck" /><label>Guilds</label><br />
  245. <input type="checkbox" id="promCheck" /><label>Promo</label><br />
  246. <div class="subset">
  247. <input type="checkbox" id="blaMarCheck" class="promoCard" /> <label>Black Market</label><br />
  248. <input type="checkbox" id="envoCheck" class="promoCard" /> <label>Envoy</label><br />
  249. <input type="checkbox" id="stasCheck" class="promoCard" /> <label>Stash</label><br />
  250. <input type="checkbox" id="wallCheck" class="promoCard" /> <label>Walled Village</label><br />
  251. <input type="checkbox" id="goveCheck" class="promoCard" /> <label>Governor</label><br />
  252. </div>
  253. </div>
  254. <div class="border">
  255. <label for="countInput">Card Count: </label>
  256. <div style="float: right; position: relative;">
  257. <input type="number" id="countInput" value="10" max="205" min="1" />
  258. </div>
  259. <br />
  260. <div class="note">
  261. Note: <br />
  262. Dominion is meant to be<br />
  263. played with 10 kingdom cards.
  264. </div>
  265. </div>
  266. <div class="border">
  267. Select from: <br />
  268. <input id="SelectAll" type="radio" name="selectFrom" value="all" checked />
  269. <label for="SelectAll">All Selected</label><br />
  270. <input id="SelectFixed" type="radio" name="selectFrom" value="someFixed" min="1" max="10" maxlength="2" />
  271. <input type="number" name="selectFixedAmount" value="3" min="1" max="10" maxlength="2" size="2" />
  272. <label for="SelectFixed"> of Selected</label><br />
  273. <input id="SelectRandom" type="radio" name="selectFrom" value="someRandom" />
  274. <label for="SelectRandom">Random Number of Selected</label>
  275. </div>
  276. <div class="border">
  277. <label for="playerCount">Player Count: </label>
  278. <div style="float: right; position: relative;">
  279. <input type="number" id="playerCount" value="3" max="6" min="2" />
  280. </div>
  281. </div>
  282. <div class="border">
  283. <label for="autoBlackMarket">Virtual Black Market: </label>
  284. <input type="checkbox" id="autoBlackMarket" />
  285. </div>
  286. <div class="border polydiv" style="max-width: 684px">
  287. <label for="platColoTogether">Use Platinum and Colony together: </label>
  288. <input type="checkbox" id="platColoTogether" name="platColoTogether" /><br />
  289. <div id="useBoth" style="display: none;">
  290. <h3>Use Platinum/Colony: </h3>
  291. <input type="radio" name="platColo" value="always" checked /><label>Always</label><br />
  292. <input type="radio" name="platColo" value="percent" />
  293. <input type="number" name="platColoPercent" value="50" min="1" max="99" maxlength="2" /><label>of the Time</label><br />
  294. <input type="radio" name="platColo" value="proportion" /><label>Proportional to Prosperity</label><br />
  295. <input type="radio" name="platColo" value="never" /><label>Never</label>
  296. </div>
  297. <div id="usePlat">
  298. <h3>Use Platinum: </h3>
  299. <input type="radio" name="platinum" value="always" checked /><label>Always</label><br />
  300. <input type="radio" name="platinum" value="percent" />
  301. <input type="number" name="platPercent" value="50" min="1" max="99" maxlength="2" /><label>of the Time</label><br />
  302. <input type="radio" name="platinum" value="proportion" /><label>Proportional to Prosperity</label><br />
  303. <input type="radio" name="platinum" value="never" /><label>Never</label>
  304. </div>
  305. <div id="useColo">
  306. <h3>Use Colony: </h3>
  307. <input type="radio" name="colony" value="always" checked /><label>Always</label><br />
  308. <input type="radio" name="colony" value="percent" />
  309. <input type="number" name="coloPercent" value="50" min="1" max="99" maxlength="2" /><label>of the Time</label><br />
  310. <input type="radio" name="colony" value="proportion" /><label>Proportional to Prosperity</label><br />
  311. <input type="radio" name="colony" value="never" /><label>Never</label>
  312. </div>
  313. <div id="useColo">
  314. <h3>Use Shelters: </h3>
  315. <input type="radio" name="shelters" value="always" checked /><label>Always</label><br />
  316. <input type="radio" name="shelters" value="percent" />
  317. <input type="number" name="shelPercent" value="50" min="1" max="99" maxlength="2" /><label>of the Time</label><br />
  318. <input type="radio" name="shelters" value="proportion" /><label>Proportional to Dark Ages</label><br />
  319. <input type="radio" name="shelters" value="never" /><label>Never</label>
  320. </div>
  321. </div>
  322. <div class="border">
  323. <h2>
  324. To Do List:
  325. </h2>
  326. <ol>
  327. <li>Virtual Black Market Deck</li>
  328. <li>Autoselect Bane</li>
  329. <li>Require cards</li>
  330. <li>Clear Cookie Button</li>
  331. </ol>
  332. </div>
  333. <div class="border">
  334. <div style="float: left;">
  335. Sort by:
  336. <ul id="sortBy" style="list-style-type: none; margin: 0; padding: 0;">
  337. <li>Name</li>
  338. <li>Set</li>
  339. <li>Cost</li>
  340. </ul>
  341. </div>
  342. </div>
  343. <div class="border">
  344. <input type="button" id="loadButton" value="Load Cards" />
  345. </div>
  346. </form>
  347. <div class="border" id="blackMarketInterface" style="display: none;">
  348. <table>
  349. <tr>
  350. <td class="cardCell">
  351. <img alt="Black Market Deck" src="images/promo/BlackMarketDeck.jpg" />
  352. </td>
  353. </tr>
  354. </table>
  355. </div>
  356. </div>
  357. <div>
  358. <table id="cardTable"></table>
  359. <table id="cardTableNonKingdom"></table>
  360. </div>
  361. </body>
  362. </html>