-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.php
109 lines (94 loc) · 3.07 KB
/
resources.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
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
<html>
<head>
</head>
<body>
<!-- Add maximum 16? characters in username -->
<?php
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$showresources = $mysqli->prepare("SELECT user_name, title, level, exp, wood, food, stone, gold, iron, diamonds, house, tower, citizen, warrior1, warrior2, warrior1level, warrior2level, hunters, dogs, shield, shieldtime, townlevel FROM users WHERE user_name = '" . $_SESSION['user_name'] . "';");
$showresources->execute();
$showresources->bind_result($username, $title, $level, $exp, $wood, $food, $stone, $gold, $iron, $diamonds, $house, $tower, $citizen, $warrior1, $warrior2, $warrior1level, $warrior2level, $hunters, $dogs, $shield, $shieldtime, $townlevel);
$showresources->fetch();
$showresources->close();
// need to start with level 1 and title 1
$expneeded = pow($level, 3) + $level * 100 + 100;
$zero = 0;
if ($exp >= $expneeded)
{
$level = $level + 1;
$exp = $exp - $expneeded;
$expneeded = pow($level, 3) + $level * 100 + 100;
if ($level == 1) {
$title = "Beginner";
}
if ($level == 5) { // activate pvp.
$activatepvp = $mysqli->prepare("UPDATE users SET shield = ?,
shieldtime = ?
WHERE user_name = ?");
$activatepvp->bind_param('iis',
$zero,
$zero,
$_SESSION['user_name']);
$activatepvp->execute();
$activatepvp->close();
}
else if ($level == 10) {
$title = "Climber";
}
else if ($level == 20) {
$title = "Pro";
}
else if ($level == 60) {
$title = "King";
}
// governour
// chief
// high-chief
// soldier
// elite-soldier
$levelup = $mysqli->prepare("UPDATE users SET level = ?,
exp = ?,
title = ?
WHERE user_name = ?");
$levelup->bind_param('iiss',
$level,
$exp,
$title,
$_SESSION['user_name']);
$levelup->execute();
$levelup->close();
echo "<b>Congratulations!<br>You just leveled up!</b><br>";
}
$mysqli->close();
$attack = $warrior1 * (5+$warrior1level) + $warrior2 * (4+$warrior2level);
$population = $house * 5;
$defence = $warrior1 * (1+$warrior1level) + $warrior2 * (4+$warrior2level) + ($tower * 10);
$currentpop = $citizen + $warrior1 + $warrior2 + $hunters + $dogs;
$townlevel = $townlevel + 1;
$bunkerspace = $townlevel * 5;
?>
<!-- show a "Level up" page? displaying what u can do new in that level -->
<?php
echo "<a href='index.php?logout'>Logout</a>";
echo "<br><h2><u>$username</u></h2>";
echo "$title<br>";
echo "
Level:   $level<br><br>
<b><u>Exp</u></b><br> $exp / $expneeded<br><br>
<b><u>Resources</u></b><br>
Wood:    $wood<br>
Food:    $food<br>
Stone:    $stone<br>
Gold:    $gold<br>
Iron:    $iron<br>
Diamonds:    $diamonds<br><br>
<b><u>City</u></b><br>
Pop:    $currentpop / $population<br>
Citizens:    $citizen<br>
Attack:    $attack<br>
Defence:    $defence<br>
Bunker:    0 / $bunkerspace
";
?>
</body>
</html>