<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 = [];
start();
function start(){
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 (one == 4 && one < 5){
alert("Одно каре 1");
}
if (two == 4 && two < 5){
alert("Одно каре 2");
}
if (three == 4 && three < 5){
alert("Одно каре 3");
}
if (four == 4 && four < 5){
alert("Одно каре 4");
}
if (five == 4 && five < 5){
alert("Одно каре 5");
}
if (six == 4 && six < 5){
alert("Одно каре 6");
}
//покер
if (one == 5){
alert("Покер");
}
if (two == 5){
alert("Покер");
}
if (three == 5){
alert("Покер");
}
if (four == 5){
alert("Покер");
}
if (five == 5){
alert("Покер");
}
if (six == 5){
alert("Покер");
}
start();
}
</script>
</body>
|