-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpokerv3.html
38 lines (36 loc) · 1.2 KB
/
pokerv3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<script>
let poker = [];
for (let i=0; i<52; i++) poker[i] = i;
for (let i = poker.length-1; i>0; i--){
let rand = parseInt(Math.random()*(i+1));
[poker[i],poker[rand]] = [poker[rand],poker[i]];
}
// for (let i in poker){
// document.write(poker[i] + "<br>");
// }
document.write("<hr>");
let players = [[],[],[],[]];
for (let i=0; i<poker.length; i++){
players[i%4][parseInt(i/4)] = poker[i];
}
</script>
<table width="100%" border="1" style="border-collapse: collapse">
<script>
let suits = ['♠','♥','♦','♣'];
let nums = ['A',2,3,4,5,6,7,8,9,10,'J','Q','K'];
for(let player of players){
player.sort(function(a,b){return a-b;});
document.write("<tr>");
for (let card of player){
if (parseInt(card/13)==1 || parseInt(card/13)==2 ){
document.write("<td style='color:red'>");
}else{
document.write("<td style='color:black'>");
}
document.write(suits[parseInt(card/13)] + nums[card%13]);
document.write("</td>");
}
document.write("</tr>");
}
</script>
</table>