-
Notifications
You must be signed in to change notification settings - Fork 1
/
location.php
70 lines (66 loc) · 2.33 KB
/
location.php
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
<?php include("db_connect.php") ?>
<html>
<?php make_header() ?>
<body>
<?php
make_top();
echo("<div id='content'>");
$query = Array('url' => $_GET['l']);
if($_GET['l'] == "class_select")
{
$db->users->update(Array('name' => $_SESSION['name']),Array('$set' => Array('hp_max' => 10, 'hp_cur' => 10, 'mp_cur' => 10, 'mp_max' => 10, 'attack' => 3, 'defense' => 20, 'speed' => 7)));
}
if(!isset($_GET['l']) || $db->locations->find($query)->count() == 0)
{
$query = Array('url' => 'main');
}
$result = $db->locations->findOne($query);
$type = $result['typeof'];
$img = $result['img'];
if($type == 'container')
{
//Create a container of links
$i = 0;
$locations = $db->containers->find(Array('outside' => $result['name']));
echo("<table>");
foreach($locations as $square)
{
if($i == 0)
{
echo("<tr>");
}
$temp = $db->locations->findOne(Array('name' => $square['name']));
$img = $temp['img'];
$url = $temp['url'];
echo("<td><a href='location.php?l=$url'><img src='$img'></a></td>");
$i++;
if($i == 3)
{
echo("</tr>");
$i = 0;
}
}
echo("</table>");
}
elseif($type == 'battle')
{
$monsters = $db->monsters->find(Array('location' => $result['name']));
srand(time());
$_SESSION['last'] = "";
$i = rand()%$monsters->count();
foreach($monsters as $monster)
{
if($i == 0)
{
$_SESSION['monster'] = $monster;
}
$i--;
}
$mname = $_SESSION['monster']['name'];
echo("You encounter a $mname. <a href='battle.php'>Fight</a> or <a
href='location.php'> Flee? </a>");
}
echo("</div>");
?>
</body>
</html>