Bingo script

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Bingo script

      Wie o wie kan mij op weg helpen met een bingo script?

      Ik heb allerlei dingen gevonden, maar dit zijn complete scripts. en ik wil zeg maar iets inbouwen in een bestaand systeem.
      De bedoeling is als volgt:

      een bingo kaart ( die elke keer veranderd als de bingo afgelopen is ), en ballen met de nummers die vallen.
      De nummers moeten dan worden afgestreept.

      Ik hoef geen compleet script maar dat iemand mij op weg kan helpen.
    • <td colspan="11"><button type="button" class="btn btn-sm btn-primary" onclick="GenerateCurrentNumber()">Volgende nummer</button> <button type = "button" onclick="checkWinner();" class = "btn btn-primary">BINGO!</button>

      Heb het tot zover allemaal werkend, nu zou ik echter willen dat:

      De volgende ball submit button automatisch submit tot 75 x en daarna de ballen op zijn.
      Heb je dan bingo, dan krijg je een melding van gewonnen, heb je geen bingo dan melding verloren.

      JavaScript Source Code

      1. <script type="text/javascript">
      2. // array of numbers on board, make sure there are no repeates
      3. var arr = [];
      4. var current_num_arr = [];
      5. innerArr = [];
      6. //keeps track of the state of the board and updates loaction to true when clicked
      7. var current_board_array = [];
      8. // counts amout of true vals int he current board array
      9. true_counter = 0;
      10. // flag tracks wins
      11. flag = true;
      12. // generating all the number on the board, no repeat
      13. for (var i = 0; i < 25; i++) {
      14. var columnB = document.getElementsByTagName('p')[i];
      15. if (i % 5 == 0) {
      16. num = getRandom(1, 15);
      17. while (arr.includes(num)) {
      18. num = getRandom(1, 15);
      19. }
      20. arr.push(num);
      21. columnB.innerHTML = num;
      22. }
      23. if (i % 5 == 1) {
      24. num = getRandom(16, 30);
      25. while (arr.includes(num)) {
      26. num = getRandom(16, 30);
      27. }
      28. arr.push(num);
      29. columnB.innerHTML = num;
      30. }
      31. if (i % 5 == 2) {
      32. num = getRandom(31, 45);
      33. while (arr.includes(num)) {
      34. num = getRandom(31, 45);
      35. }
      36. arr.push(num);
      37. columnB.innerHTML = num;
      38. }
      39. if (i % 5 == 3) {
      40. num = getRandom(46, 60);
      41. while (arr.includes(num)) {
      42. num = getRandom(46, 60);
      43. }
      44. arr.push(num);
      45. columnB.innerHTML = num;
      46. }
      47. if (i % 5 == 4) {
      48. num = getRandom(61, 75);
      49. while (arr.includes(num)) {
      50. num = getRandom(61, 75);
      51. }
      52. arr.push(num);
      53. columnB.innerHTML = num;
      54. }
      55. }
      56. function getRandom(min, max) {
      57. return Math.floor(Math.random() * (max - min + 1)) + min;
      58. }
      59. // generates the current numbers. makes an array to make sure they dont repeat
      60. function GenerateCurrentNumber() {
      61. var current_num_spot = document.getElementsByTagName('h1')[5];
      62. var current_num = getRandom(1, 75);
      63. while (current_board_array.includes(current_num)) {
      64. var current_num = getRandom(1, 75);
      65. }
      66. current_num_arr.push(current_num);
      67. current_num_spot.innerHTML = current_num;
      68. }
      69. // doing different things when a button is clicked
      70. function marker(x) {
      71. // data is the number val of the box
      72. var data = parseInt(x.textContent);
      73. // if the user has checked a legal box
      74. if (current_num_arr.includes(data)) {
      75. x.style.backgroundColor = "#04C4C7";
      76. // updating the state of the current board, if clicked the val is changed to true
      77. for (var i = 0; i < 5; i++) {
      78. // getting the index number of the checked box in the array
      79. index_val = current_board_array[i].indexOf(data);
      80. if (index_val != -1) {
      81. current_board_array[i][index_val] = true;
      82. }
      83. }
      84. }
      85. }
      86. // Making a copy of the game board which will be constantly updated and compated to winnings states
      87. // 2d array
      88. function generateBoard() {
      89. for (var i = 0; i <= 26; i++) {
      90. if (i == 5 || i == 10 || i == 16 || i == 21 || i == 26) {
      91. current_board_array.push(innerArr);
      92. innerArr = [];
      93. }
      94. var nums = document.getElementsByTagName('p')[i];
      95. if (Number.isInteger(parseInt(nums.textContent))) {
      96. innerArr.push(parseInt(nums.textContent));
      97. } else {
      98. innerArr.push(true);
      99. i++;
      100. }
      101. }
      102. }
      103. // loops through the current game board to check if there is a winning state according to the dropdown
      104. function checkWinner() {
      105. // the place where we will output results
      106. var winner = document.getElementById("winner");
      107. // grabbing the state of the dropdown
      108. var e = document.getElementById("selection");
      109. var selected = e.options[e.selectedIndex].text;
      110. if (selected == "Horizontaal") {
      111. for (var i = 0; i < 5; i++) {
      112. for (var j = 0; j < 5; j++) {
      113. if (current_board_array[i][j] == true) {
      114. true_counter ++;
      115. }
      116. else {
      117. true_counter = 0;
      118. }
      119. }
      120. if (true_counter == 5) {
      121. winner.innerHTML = "<div class=\"goed\"><img src=\"images/icoons/meldinggoed.png\" width=\"16\" height=\"16\">B.I.N.G.O op horizontaal</div>"; }
      122. flag = true;
      123. }
      124. true_counter = 0;
      125. }
      126. if (flag == false) {
      127. winner.innerHTML = "<div class=\"fout\"><img src=\"/images/icoons/meldingfout.png\" width=\"16\" height=\"16\">Helaas nog (geen) B.I.N.G.O</div>"; }
      128. if (selected == "Verticaal") {
      129. for (var i = 0; i < 5; i++) {
      130. for (var j = 0; j < 5; j++) {
      131. if (current_board_array[j][i] == true) {
      132. true_counter ++;
      133. }
      134. else {
      135. true_counter = 0;
      136. }
      137. }
      138. if (true_counter == 5) {
      139. winner.innerHTML = "<div class=\"goed\"><img src=\"images/icoons/meldinggoed.png\" width=\"16\" height=\"16\">B.I.N.G.O op verticaal</div>";
      140. flag = true;
      141. }
      142. true_counter = 0;
      143. }
      144. if (flag == false) {
      145. winner.innerHTML = "<div class=\"fout\"><img src=\"images/icoons/meldingfout.png\" width=\"16\" height=\"16\">Helaas nog (geen) B.I.N.G.O</div>";
      146. }
      147. }
      148. if (selected == "Diagonaal") {
      149. if (((current_board_array[0][0]) == true && (current_board_array[1][1]) == true && (current_board_array[3][3]) == true && (current_board_array[4][4]) == true) || (((current_board_array[0][4]) == true && (current_board_array[1][3]) == true && (current_board_array[3][1]) == true && (current_board_array[4][0]) == true))) {
      150. winner.innerHTML = "<div class=\"goed\"><img src=\"images/icoons/meldinggoed.png\" width=\"16\" height=\"16\">B.I.N.G.O op diagonaal</div>";
      151. }
      152. else {
      153. winner.innerHTML = "<div class=\"fout\"><img src=\"images/icoons/meldingfout.png\" width=\"16\" height=\"16\">Helaas nog geen B.I.N.G.O</div>";
      154. }
      155. }
      156. if (selected == "4 hoeken") {
      157. if ((current_board_array[0][0]) == true && (current_board_array[0][4]) == true && (current_board_array[4][0]) == true && (current_board_array[4][4]) == true) {
      158. winner.innerHTML = "<div class=\"goed\"><img src=\"images/icoons/meldinggoed.png\" width=\"16\" height=\"16\">B.I.N.G.O op 4 hoeken</div>";
      159. }
      160. else {
      161. winner.innerHTML = "<div class=\"fout\"><img src=\"images/icoons/meldingfout.png\" width=\"16\" height=\"16\">Helaas nog geen B.I.N.G.O</div>";
      162. }
      163. }
      164. if (selected == "Volle Kaart") {
      165. for (var i = 0; i < 5; i++) {
      166. for (var j = 0; j < 5; j++) {
      167. if (current_board_array[j][i] == true) {
      168. true_counter ++;
      169. }
      170. else {
      171. true_counter = 0;
      172. }
      173. }
      174. }
      175. if (true_counter == 25) {
      176. winner.innerHTML = "<div class=\"goed\"><img src=\"images/icoons/meldinggoed.png\" width=\"16\" height=\"16\">B.I.N.G.O op een volle kaart</div>";
      177. }
      178. else {
      179. winner.innerHTML = "<div class=\"fout\"><img src=\"images/icoons/meldingfout.png\" width=\"16\" height=\"16\">Helaas nog geen B.I.N.G.O</div>";
      180. }
      181. }
      182. }
      183. var free = document.getElementById('free').getElementsByTagName('p')[0];
      184. free.innerHTML = "<p>VRIJ</p>";
      185. GenerateCurrentNumber();
      186. generateBoard();
      187. </script>
      Display All
      <td colspan="11"><button type="button" class="btn btn-sm btn-primary" onclick="GenerateCurrentNumber()">Volgende nummer</button> <button type = "button" onclick="checkWinner();" class = "btn btn-primary">BINGO!</button>

      Dit is de button ( de volgende nummer button )

      The post was edited 1 time, last by zwpgangster ().