-
Notifications
You must be signed in to change notification settings - Fork 17
/
team_[9].html
109 lines (104 loc) · 2.86 KB
/
team_[9].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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p id="demo">
</p>
<script type="text/javascript">
// write your code here
var cards = new Array("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K");
var kinds = new Array("B", "H", "D", "C");
var poker = new Array();
var count = 0;
for(i=0; i<kinds.length; i++){
for(j=0; j<cards.length; j++){
//console.log(kinds[i]+cards[j]+"\n");
poker[count] = kinds[i]+cards[j];
count++;
}
}
//---------------------------------------------------------------
var num = poker.length;
var temp, rand;
var newpoker = new Array();
for(i=0; i<52; i++){
rand = Math.floor((Math.random() * num));
temp = poker[rand];
poker[rand] = poker[poker.length-1];
poker[poker.length-1] = temp;
newpoker[i] = temp;
poker.pop();
num--;
}
/*for(i=0; i<newpoker.length; i++)
console.log(i+":"+newpoker[i]+"\n");*/
//---------------------------------------------------------------
document.write("B_黑桃, H_紅心, D_方塊, C_梅花<br>");
var p1, p2, p3, p4;
p1 = p2 = p3 = p4 = new Array();
var x1, x2, x3, x4;
x1 = x2 = x3 = x4 = 0;
for(i=0; i<newpoker.length; i++){
if(i<2){
p1[x1] = newpoker[i];
if(newpoker[i].match(/B/g)){
temp = newpoker[i].split("B");
temp = temp.pop();
console.log("p1_"+x1+":"+newpoker[i]+" --- > "+temp+"\n");
}
else
console.log("p1_"+x1+":"+newpoker[i]+" --- > "+"none"+"\n");
x1++;
}
else if(i<4){
p2[x2] = newpoker[i];
if(newpoker[i].match(/B/g)){
temp = newpoker[i].split("B");
temp = temp.pop();
console.log("p2_"+x2+":"+newpoker[i]+" --- > "+temp+"\n");
}
else
console.log("p2_"+x2+":"+newpoker[i]+" --- > "+"none"+"\n");
x2++;
}
else if(i<6){
p3[x3] = newpoker[i];
if(newpoker[i].match(/B/g)){
temp = newpoker[i].split("B");
temp = temp.pop();
console.log("p3_"+x3+":"+newpoker[i]+" --- > "+temp+"\n");
}
else
console.log("p3_"+x3+":"+newpoker[i]+" --- > "+"none"+"\n");
x3++;
}
else if(i<8){
p4[x4] = newpoker[i];
if(newpoker[i].match(/B/g)){
temp = newpoker[i].split("B");
temp = temp.pop();
console.log("p4_"+x4+":"+newpoker[i]+" --- > "+temp+"\n");
}
else
console.log("p4_"+x4+":"+newpoker[i]+" --- > "+"none"+"\n");
x4++;
}
else
break;
}
/*for(i=0; i<newpoker.length; i++){
if(newpoker[i].match(/B/g)){
temp = newpoker[i].split("B");
temp = temp.pop();
console.log(i+":"+temp+"\n");
}
}*/
</script>
</body>
</html>