-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgym.php
117 lines (116 loc) · 3.93 KB
/
gym.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
110
111
112
113
114
115
116
117
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
$macropage = 'gym.php';
global $db, $ir, $userid, $h;
require_once('globals.php');
if ($ir['hospital'])
{
die('This page cannot be accessed while in hospital.');
}
$statnames =
['Strength' => 'strength', 'Agility' => 'agility',
'Guard' => 'guard', 'Labour' => 'labour'];
if (!isset($_POST['amnt']))
{
$_POST['amnt'] = 0;
}
$_POST['amnt'] = abs((int) $_POST['amnt']);
if ($ir['jail'] <= 0)
{
echo '<h3>Gym</h3><hr />';
}
else
{
echo '<h3>Jail Gym</h3><hr />';
}
if (isset($_POST['stat']) && $_POST['amnt'])
{
if (!isset($statnames[$_POST['stat']]))
{
die('This stat cannot be trained.');
}
$stat = $statnames[$_POST['stat']];
if ($_POST['amnt'] > $ir['energy'])
{
print('You do not have enough energy to train that much.<hr />');
}
else
{
$gain = 0;
for ($i = 0; $i < $_POST['amnt']; $i++)
{
$gain +=
rand(1, 3) / rand(800, 1000) * rand(800, 1000)
* (($ir['will'] + 20) / 150);
$ir['will'] -= rand(1, 3);
if ($ir['will'] < 0)
{
$ir['will'] = 0;
}
}
if ($ir['jail'] > 0)
{
$gain /= 2;
}
$db->query(
"UPDATE `userstats`
SET `{$stat}` = `{$stat}` + $gain
WHERE `userid` = $userid");
$db->query(
"UPDATE `users`
SET `will` = {$ir['will']},
`energy` = `energy` - {$_POST['amnt']}
WHERE `userid` = $userid");
$inc = $ir[$stat] + $gain;
$inc2 = $ir['energy'] - $_POST['amnt'];
if ($stat == 'strength')
{
echo "You begin lifting some weights.<br />
You have gained {$gain} strength by doing {$_POST['amnt']} sets of weights.<br />
You now have {$inc} strength and {$inc2} energy left.";
}
elseif ($stat == 'agility')
{
echo "You begin running on a treadmill.<br />
You have gained {$gain} agility by doing {$_POST['amnt']} minutes of running.<br />
You now have {$inc} agility and {$inc2} energy left.";
}
elseif ($stat == 'guard')
{
echo "You jump into the pool and begin swimming.<br />
You have gained {$gain} guard by doing {$_POST['amnt']} minutes of swimming.<br />
You now have {$inc} guard and {$inc2} energy left.";
}
elseif ($stat == 'labour')
{
echo "You walk over to some boxes filled with gym equipment and start moving them.<br />
You have gained {$gain} labour by moving {$_POST['amnt']} boxes.<br />
You now have {$inc} labour and {$inc2} energy left.";
}
echo '<hr />';
$ir['energy'] -= $_POST['amnt'];
$ir[$stat] += $gain;
}
}
$ir['strank'] = get_rank($ir['strength'], 'strength');
$ir['agirank'] = get_rank($ir['agility'], 'agility');
$ir['guarank'] = get_rank($ir['guard'], 'guard');
$ir['labrank'] = get_rank($ir['labour'], 'labour');
echo "Choose the stat you want to train and the times you want to train it.<br />
You can train up to {$ir['energy']} times.<hr />
<form action='gym.php' method='post'>
Stat: <select type='dropdown' name='stat'>
<option style='color:red;' value='Strength'>Strength (Have {$ir['strength']}, Ranked {$ir['strank']})
<option style='color:blue;' value='Agility'>Agility (Have {$ir['agility']}, Ranked {$ir['agirank']})
<option style='color:green;' value='Guard'>Guard (Have {$ir['guard']}, Ranked {$ir['guarank']})
<option style='color:brown;' value='Labour'>Labour (Have {$ir['labour']}, Ranked {$ir['labrank']})
</select><br />
Times to train: <input type='text' name='amnt' value='{$ir['energy']}' /><br />
<input type='submit' value='Train' /></form>";
$h->endpage();