forked from Hollywood1/KMKingdoms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructures.php
More file actions
172 lines (170 loc) · 7.06 KB
/
structures.php
File metadata and controls
172 lines (170 loc) · 7.06 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
echo "You must be logged in to view this page!";
}else{
if(isset($_POST['build'])){
$tower = protect($_POST['tower']);
$seige = protect($_POST['seige equipment']);
$wizguild = protect($_POST['taxhouse guild']);
$granary = protect($_POST['granary']);
$taxhouse = protect($_POST['tax house']);
$gold_needed = (1000 * $tower) + (1000 * $seige) + (1500 * $wizguild) + (750 * $granary) + (750 * $taxhouse);
if($tower < 0 || $seige < 0 || $wizguild < 0 || $granary < 0 || $taxhouse < 0){
output("You must build a positive number of Structures!");
}elseif($stats['gold'] < $gold_needed){
output("You do not have enough gold!");
}else{
$building['tower'] += $tower;
$building['seige'] += $seige;
$building['wizguild'] += $wizguild;
$building['granary'] += $granary;
$building['taxhouse'] += $taxhouse;
$update_building = mysql_query("UPDATE `building` SET
`tower`='".$building['tower']."',
`seige`='".$building['seige']."',
`wizguild`='".$building['wizguild']."',
`granary`='".$building['granary']."',
`taxhouse`='".$building['taxhouse']."'
WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
$stats['gold'] -= $gold_needed;
$update_gold = mysql_query("UPDATE `stats` SET `gold`='".$stats['gold']."'
WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
include("update_stats.php");
output("You Structures have been built!");
}
}elseif(isset($_POST['destroy'])){
$tower = protect($_POST['tower']);
$seige = protect($_POST['seige']);
$wizguild = protect($_POST['wizguild']);
$granary = protect($_POST['granary']);
$taxhouse = protect($_POST['taxhouse']);
$gold_gained = (500 * $tower) + (500 * $seige) + (750 * $wizguild) + (400 * $granary) + (400 * $taxhouse);
if($tower < 0 || $seige < 0 || $wizguild < 0 || $granary < 0 || $taxhouse < 0 ){
output("You must untrain a positive number of buildings!");
}elseif($tower > $building['tower'] || $seige > $building['seige'] ||
$wizguild > $building['wizguild'] || $granary > $building['granary'] || $taxhouse > $building['taxhouse']){
output("You do not have that many buildings to deconstruct!");
}else{
$building['tower'] -= $tower;
$building['seige'] -= $seige;
$building['wizguild'] -= $wizguild;
$building['granary'] -= $granary;
$building['taxhouse'] -= $taxhouse;
$update_building = mysql_query("UPDATE `building` SET
`tower`='".$building['tower']."',
`seige`='".$building['seige']."',
`wizguild`='".$building['wizguild']."',
`granary`='".$building['granary']."',
`taxhouse`='".$building['taxhouse']."'
WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
$stats['gold'] += $gold_gained;
$update_gold = mysql_query("UPDATE `stats` SET `gold`='".$stats['gold']."'
WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
include("update_stats.php");
output("You have deconstructed your buildings!!");
}
}
?>
<center><h2>Your buildings</h2></center>
<br />
You can Build and Deconstruct your buildings here.
<br /><br />
<form action="buildings.php" method="post">
<table cellpadding="5" cellspacing="5">
<tr>
<td><b>Building Type</b></td>
<td><b>Number of Buildings</b></td>
<td><b>Building Cost</b></td>
<td><b>Build More</b></td>
</tr>
<tr>
<td>Tower</td>
<td><?php echo number_format($building['tower']); ?></td>
<td>1000 gold</td>
<td><input type="text" name="tower" /></td>
</tr>
<tr>
<td>Seige Equipment</td>
<td><?php echo number_format($building['seige']); ?></td>
<td>1000 gold</td>
<td><input type="text" name="seige" /></td>
</tr>
<tr>
<td>Wizard's Guilds</td>
<td><?php echo number_format($building['wizguild']); ?></td>
<td>1500 gold</td>
<td><input type="text" name="wizguild" /></td>
</tr>
<tr>
<td>Granaries</td>
<td><?php echo number_format($building['granary']); ?></td>
<td>750 gold</td>
<td><input type="text" name="granary" /></td>
</tr>
<tr>
<td>Tax Houses</td>
<td><?php echo number_format($building['taxhouse']); ?></td>
<td>750 gold</td>
<td><input type="text" name="taxhouse" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><input type="submit" name="build" value="Build"/></td>
</tr>
</table>
</form>
<hr />
<form action="buildings.php" method="post">
<table cellpadding="5" cellspacing="5">
<tr>
<td><b>Building Type</b></td>
<td><b>Number of Buildings</b></td>
<td><b>Salvaging Profit</b></td>
<td><b>Deconstruct Buildings</b></td>
</tr>
<tr>
<td>Tower</td>
<td><?php echo number_format($building['tower']); ?></td>
<td>500 gold</td>
<td><input type="text" name="tower" /></td>
</tr>
<tr>
<td>Seige Equipment</td>
<td><?php echo number_format($building['seige']); ?></td>
<td>500 gold</td>
<td><input type="text" name="seige" /></td>
</tr>
<tr>
<td>Wizard Guilds</td>
<td><?php echo number_format($building['wizguild']); ?></td>
<td>750 gold</td>
<td><input type="text" name="wizguild" /></td>
</tr>
<tr>
<td>Granaries</td>
<td><?php echo number_format($building['granary']); ?></td>
<td>400 gold</td>
<td><input type="text" name="granary" /></td>
</tr>
<tr>
<td>Tax Houses</td>
<td><?php echo number_format($building['taxhouse']); ?></td>
<td>400 gold</td>
<td><input type="text" name="taxhouse" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><input type="submit" name="destroy" value="Destroy"/></td>
</tr>
</table>
</form>
<?php
}
include("footer.php");
?>