-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMatch-PickingGame.htm
More file actions
156 lines (146 loc) · 4.68 KB
/
Match-PickingGame.htm
File metadata and controls
156 lines (146 loc) · 4.68 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Pick</title>
<style>
input
{
font-size:x-large;
}
font
{
font-size:x-large;
}
.style1
{
width: 231px;
}
.style2
{
width: 562px;
}
.style3
{
width: 249px;
}
div
{
font-size:x-large;
}
</style>
<script type="text/javascript">
var matches = 0;
var curr = 1;
var cu;
function init() {
t1.value = 1;
t2.value = 1;
matches = parseInt(count.value);
curr = parseInt(tt.value);
if (curr == 1) {
b1.disabled = false;
b2.disabled = true;
} else {
b1.disabled = true;
b2.disabled = false;
}
ad.innerHTML = "Initial Count = " + matches+"</br>";
}
function pick() {
var t = 0;
if (curr == 1) {
t = parseInt(t1.value)
if (!(t <= 3 && t >= 1)) {
alert("the picked matches must be between 1 and 3");
return;
}
matches -= t;
curr = 2;
t1.value = 1;
b1.disabled = true;
b2.disabled = false;
} else {
t = parseInt(t2.value)
if (!(t <= 3 && t >= 1)) {
alert("the picked matches must be between 1 and 3");
return;
}
matches -= t;
curr = 1;
t2.value = 1;
b1.disabled = false;
b2.disabled = true;
}
// dis.innerHTML = "<b>Current Count = " + matches + "</b>";
if (curr == 2) {
ad.innerHTML += "*Player <i>1</i> Selected <b>" + t + "</b> matches<br/>";
} else {
ad.innerHTML += "*Player <i>2</i> Selected <b>" + t + "</b> matches;<br/> ";
}
count.value = matches;
if (matches <= 1) {
if (curr == 2) {
alert("Player 2 lose");
ad.innerHTML += "Player 2 lose!";
return;
} else {
ad.innerHTML += "Player 1 lose";
alert("Player 1 lose!");
return;
}
}
}
</script>
</head>
<body background="b.jpg">
<table style="width:133%;">
<tr>
<td class="style1">
</td>
<td class="style2">
<h1>Have a Pick!</h1></td>
<td class="style3">
</td>
</tr>
<tr>
<td class="style1">
</td>
<td class="style2">
Developer: Donghua Chen<br />
</td>
<td class="style3">
</td>
</tr>
<tr>
<td class="style1">
<div id="ad" />
</td>
<td class="style2">
<font><br /><b>Setting:</b></font><br />
<font>Matches Count:</font><input type="text" id="count" value="10" /><br />
<br /><font>
Player </font><input type="text" id="tt" value="1" /><font> First<br />
</font><br /><input type="button" value="InitGame" onclick="init()" /></td>
<td class="style3">
</td>
</tr>
<tr>
<td class="style1">
</td>
<td class="style2"><br />
<font><b>Let's Play!</b></font>
<br />
<input type="text" value="1" id="t1" /><input type="button" id="b1" value="Player 1" onclick="pick()"/><br />
<br />
<input type="text" value="1" id="t2" /><input type="button" id="b2" value="Player 2" onclick="pick()" /><br />
</td>
<td class="style3">
</td>
</tr>
</table>
<br />
<br />
<br />
</body>
</html>