<body>
<title>Основные комбинации покера на костях </title>
<style>
.someclass{
font-size:100px;
}
</style>
<div id="mytable" class="someclass">
</div>
<br>
<input type="button" onclick="myfunc()" value="выдать комбинации">
<script>
let arraynumber = [];
let big_combination = 0;
let kare = 0;
let fromkare = 0;
start();
function big_generation(){
arraynumber = [];
let el_1 = document.getElementById("mytable");
el_1.innerHTML = '';
let n = Math.floor(Math.random() * 6)+1;
fromkare = n;
let endnum = Math.floor(Math.random() * 6)+1;
while (true){
endnum = Math.floor(Math.random() * 6)+1;
if (n != endnum ) break;
}
for (let i = 0; i < 5;i++){
arraynumber.push(n);
el_1.innerHTML += n;
el_1.innerHTML += " ";
}
arraynumber.push(endnum);
el_1.innerHTML += endnum;
}
function start(){
big_combination += Math.floor(Math.random() *2)+1;
if (big_combination > 10){
big_combination = 0;
big_generation();
kare = 1;
}
else{
arraynumber = [];
let el_1 = document.getElementById("mytable");
el_1.innerHTML = '';
for (let i = 0; i <= 5;i++){
let n = Math.floor(Math.random() * 6)+1;
arraynumber.push(n);
el_1.innerHTML += n;
el_1.innerHTML += " ";
}
}
}
function myfunc(){
let one = 0;
let two = 0;
let three = 0;
let four = 0;
let five = 0;
let six = 0;
for (let i = 0; i <= 5;i++){
if (arraynumber[i] == 1) one++;
if (arraynumber[i] == 2) two++;
if (arraynumber[i] == 3) three++;
if (arraynumber[i] == 4) four++;
if (arraynumber[i] == 5) five++;
if (arraynumber[i] == 6) six++;
}
//пара
if (one == 2 && one < 3){
alert("Одна пара 1");
}
if (two == 2 && two < 3){
alert("Одна пара 2");
}
if (three == 2 && three < 3){
alert("Одна пара 3");
}
if (four == 2 && four < 3){
alert("Одна пара 4");
}
if (five == 2 && five < 3){
alert("Одна пара 5");
}
if (six == 2 && six < 3){
alert("Одна пара 6");
}
//тройка
if (one == 3 && one < 4){
alert("Одна тройка 1");
}
if (two == 3 && two < 4){
alert("Одна тройка 2");
}
if (three == 3 && three < 4){
alert("Одна тройка 3");
}
if (four == 3 && four < 4){
alert("Одна тройка 4");
}
if (five == 3 && five < 4){
alert("Одна тройка 5");
}
if (six == 3 && six < 4){
alert("Одна тройка 6");
}
if (kare == 1)
{
kare = 0;
alert("Каре из "+fromkare);
}
start();
}
</script>
</body>
|