-
Notifications
You must be signed in to change notification settings - Fork 0
/
fish.inc
219 lines (202 loc) · 8.32 KB
/
fish.inc
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
/*==================================================
GONE FISHING
v1.0 April 2001
Nigel Gilbert
n.gilbert@soc.surrey.ac.uk
====================================================*/
/* displays the main Gone Fishing page and asks the user to specify an investment.
Included by index.php
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML lang="en">
<HEAD>
<META HTTP-EQUIV="REFRESH" CONTENT="600">
<TITLE>Gone Fishing!</TITLE>
</HEAD>
<BODY BGCOLOR="#006699" text= "white" link="#FFCC00" vlink="#FFFF00"
TOPMARGIN="0" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- top bar -->
<table BORDER="0" CELLSPACING="0" CELLPADDING="5" WIDTH="100%">
<tr BGCOLOR="#003333" HEIGHT="50">
<td ALIGN=left VALIGN=middle><font SIZE=5> <b>Gone Fishing!</b></font></td>
<td ALIGN=right VALIGN=middle><font SIZE=4><?php echo date("g:ia, l j F Y"); ?> </font></td></tr>
<tr>
<td ALIGN=left><font SIZE=4 face="arial">
<?php
switch ($welcome_back) {
case "old_user":
echo "Welcome back, ";
break;
case "new_user":
echo "Welcome, ";
break;
default:
break;
}
echo ucfirst($name) . ", sailing in the \"$fisher->boat\"</font>";
?>
</td>
<td ALIGN=right><font SIZE=2 face="arial">
<?php
/* display the names of the boats also at sea */
$query = new query("SELECT * FROM people WHERE logintime IS NOT NULL and name != '$name'");
$nboats = $query->num_recs();
$printed_name = 0;
while ($query->next_rec()) {
if ($printed_name) {
if ($printed_name == $nboats - 1) { echo " and ";} else {echo "; ";};
}
$printed_name++;
printf(" %s", $query->field("boat"));
}
if ($printed_name) {
echo ($printed_name == 1 ? " is" : " are");
echo " also at sea.\n";
}
else {echo "No one else is at sea.\n";}
echo "<BR>";
/* and those not at sea */
$printed_name = 0;
$query = new query("SELECT * FROM people WHERE logintime IS NULL");
$nboats = $query->num_recs();
while ($query->next_rec()) {
if ($printed_name) {
if ($printed_name == $nboats - 1) { echo " and ";} else {echo "; ";};
}
$printed_name++;
printf(" %s", $query->field("boat"));
}
if ($printed_name) {
echo ($printed_name == 1 ? " is" : " are");
echo " tied up in harbour.\n";
}
else {echo "No one is in port.\n";}
echo "<BR><a href=\"ranks.php\">See how the other fishers are doing</a>";
?>
</font>
</td>
</tr>
</table>
<table BORDER="0" CELLSPACING="2" CELLPADDING="1" WIDTH=100%>
<tr ALIGN="left" VALIGN="top">
<!-- left margin -->
<td WIDTH=20><br></td>
<!-- left middle -->
<td>
<table BORDER="0" CELLSPACING="2" CELLPADDING="5" width=100%>
<!-- vertical spacer -->
<tr><td HEIGHT=40><br></td></tr>
<!-- current state box -->
<tr ALIGN="left" VALIGN="top">
<td BGCOLOR="#99CCFF"><font SIZE="2" color="black" face="arial">
Your bank balance is now € <B><?php echo $fisher->balance; ?></B><p>
<?php
$query = new query("SELECT max(balance) as maxbalance FROM people WHERE name <> '$name'");
$query->next_rec();
$maxbalance = $query->field("maxbalance");
if ($fisher->balance > $maxbalance) {
echo "At the moment, you are the fisher with the largest bank balance - congratulations!<p>\n";
}
else {
if ($fisher->balance == $maxbalance) {
echo "You are one of the group of richest fishers who all have a balance of € $maxbalance.<p>\n";
}
else {
$query = new query("SELECT boat FROM people WHERE balance = '$maxbalance'");
$query->next_rec();
$richest = $query->field("boat");
echo "The balance of the richest fisher ($richest) is € <B>$maxbalance</B><p>\n";
}
}
?>
The market price of fish today is € <B><?php echo ($sea->marketPrice ? $sea->marketPrice : "--"); ?></B><p>
The harbour fees per trip are € <B><?php echo $sea->maintenance; ?> </B><p>
Average amount invested per trip is € <B><?php echo
($log->averageInvestment ? $log->averageInvestment : "--") ?> </B><p>
Average size of recent catches is <B><?php echo ($log->averageCatchSize ?
$log->averageCatchSize : "--") ?> </B><p>
The number of fish in the lake is <B><?php echo $sea->stock; ?> </B> <p></font>
</td>
</tr>
<!-- investment box -->
<tr>
<td BGCOLOR="#99CCFF" VALIGN=middle>
<form METHOD="post" ACTION="index.php">
<input TYPE=hidden NAME=action VALUE=gofishing>
<table border=0> <tr><td>
<font SIZE="2" color="black" face="arial">
<b>Before setting sail, I want to invest </b>€ </font>
<input TYPE="text" NAME="investment" MAXLENGTH="7" SIZE="7"> <br>
<font SIZE="2" color="black" face="arial"><b>in fishing equipment.</b></font>
</td><td align=right>
<input TYPE="submit" NAME="gofishing" VALUE="Go fishing...">
</td></tr></table>
</form>
</td></tr>
<!-- take a holiday option -->
<tr><td BGCOLOR="#006699" VALIGN=middle>
<font SIZE="2" COLOR="white">
If you want to withdraw from fishing for a time,<br>
to get on with other things, you can
<A HREF="index.php?action=logout">take a holiday</A>.
</font>
</td>
</tr>
<!-- vertical spacer -->
<tr><td height=20><br></td></tr>
</table>
<!-- ships radio -->
<?php
/* display the list of messages that have been received */
include("radio.inc");
?>
</td>
<!-- centre gulley -->
<td width=40><BR></td>
<!-- right middle -->
<td>
<table BORDER="0" CELLSPACING="0" CELLPADDING="5">
<!-- chart -->
<tr><td colspan=4 align=center><img src="chart.php?<?php echo time() ?>"></td></tr>
<?php
/* display table of recent activity */
$query = new query("SELECT id FROM log WHERE name='$name'");
if ($query->num_recs()) {
?>
<tr><td colspan=4><hr></td></tr>
<tr><td colspan=4 align=center><font face="arial" size="3">
<b>Log for the <?php echo $fisher->boat ?></b></font>
</td></tr>
<tr><td colspan=4><hr></td></tr>
<tr>
<td><font size="2"><b>Time</b></font></td>
<td><font size="2"><b>Investment</b> (€)</font></td>
<td><font size="2"><b>Catch</b> (fish)</font></td>
<td><font size="2"><b>In bank</b> (€)</font></td>
</tr>
<?php
/* extract the last five records */
$query = new query("SELECT to_char(time, 'DD Mon, HH24:MI') as date, investment, harvest, balance FROM log
WHERE name = '$name' ORDER BY time DESC LIMIT 5");
$query->last_rec();
while ($query->prev_rec()) {
printf("<tr>
<td align=left><font size=2>%s</font></td>
<td align=right><font size=2>%s</font></td>
<td align=right><font size=2>%s</font></td>
<td align=right><font size=2>%s</font></td>
</tr>",
$query->field("date"), $query->field("investment"), $query->field("harvest"), $query->field("balance"));
}
echo "<tr><td colspan=4><hr>";
}
?>
</td></tr>
</table>
</td>
<!-- right margin -->
<td WIDTH=20><br></td>
</tr>
</table>