-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadhero.php
120 lines (100 loc) · 5.29 KB
/
loadhero.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
118
119
120
<?php
// if not logged in, redirect to login page
require_once('Classes/Login.php');
if (\Classes\Login::isLoggedIn() === false) header('Location: login.php');
require_once('/Includes/common.php');
require_once('/Classes/Hero.php');
require_once('/Includes/menu.php');
use \Classes\Hero as Hero;
use \Classes\Item as Item;
if(!array_key_exists('name', $_GET)) { // show form if no hero has been selected to be shown
echo "<form name='herosearch' action='loadhero.php' method='GET'><input type='text' name='name'><input type='submit' value='Submit'></form>";
} else { // if hero has been selected to be shown...
$heroName = $_GET['name'];
if (!Hero::doesHeroExist($heroName)) { echo "Hero does not exist!"; exit(); }
// get hero information from the database
$hero = Hero::getHeroByName($heroName);
// cache hero information for ease of use
$heroName = $hero->getName();
$heroRace = $hero->getRace();
$heroProf = $hero->getProfession();
$heroXp = $hero->getXp();
$heroParty = $hero->getParty();
$heroStr = $hero->getStrength();
$heroCon = $hero->getConstitution();
$heroAgi = $hero->getAgility();
$heroDex = $hero->getDexterity();
$heroInt = $hero->getIntelligence();
$heroWis = $hero->getWisdom();
$heroCha = $hero->getCharisma();
$heroAct = $hero->getActions();
$heroPer = $hero->getPerception();
$heroGold = $hero->getGold();
$heroMaxHp = $hero->getMaxHp();
$heroMaxMp = $hero->getMaxMp();
// cache inventory stats
$heroHpRegen = $hero->getInventory()->getTotalHpRegen();
$heroMpRegen = $hero->getInventory()->getTotalMpRegen();
$heroSDAM = $hero->getInventory()->getTotalSDAM();
$heroPDAM = $hero->getInventory()->getTotalPDAM();
$heroBDAM = $hero->getInventory()->getTotalBDAM();
$heroSARM = $hero->getInventory()->getTotalSARM();
$heroPARM = $hero->getInventory()->getTotalPARM();
$heroBARM = $hero->getInventory()->getTotalBARM();
// cache equipment slots
$heroMainHand = $hero->getInventory()->where(function($item) { return $item->getItem()->getSlot() === Item::SLOT_HAND AND $item->getEquip() === 1; });
$heroMainHandName = count($heroMainHand) === 0 ? 'None' : $heroMainHand[0]->getItem()->getFullName();
$heroOffHand = $hero->getInventory()->where(function($item) { return $item->getItem()->getSlot() === Item::SLOT_HAND AND $item->getEquip() === 2; });
$heroOffHandName = count($heroOffHand) === 0 ? 'None' : $heroOffHand[0]->getItem()->getFullName();
$heroHead = $hero->getInventory()->where(function($item) { return $item->getItem()->getSlot() === Item::SLOT_HEAD; });
$heroHeadName = count($heroHead) === 0 ? 'None' : $heroHead[0]->getItem()->getFullName();
$heroTorso = $hero->getInventory()->where(function($item) { return $item->getItem()->getSlot() === Item::SLOT_TORSO; });
$heroTorsoName = count($heroTorso) === 0 ? 'None' : $heroTorso[0]->getItem()->getFullName();
$heroArms = $hero->getInventory()->where(function($item) { return $item->getItem()->getSlot() === Item::SLOT_ARMS; });
$heroArmsName = count($heroArms) === 0 ? 'None' : $heroArms[0]->getItem()->getFullName();
$heroLegs = $hero->getInventory()->where(function($item) { return $item->getItem()->getSlot() === Item::SLOT_LEGS; });
$heroLegsName = count($heroLegs) === 0 ? 'None' : $heroLegs[0]->getItem()->getFullName();
$heroFeet = $hero->getInventory()->where(function($item) { return $item->getItem()->getSlot() === Item::SLOT_FEET; });
$heroFeetName = count($heroFeet) === 0 ? 'None' : $heroFeet[0]->getItem()->getFullName();
echo "Hero:<br />\n";
echo "<table><tr><th>Name</th><th>Race</th><th>Profession</th><th>Experience</th><th>Party</th><th>Strength</th><th>Intelligence</th><th>Dexterity</th><th>Agility</th><th>Wisdom</th><th>Perception</th><th>Action</th><th>Constitution</th><th>Charisma</th><th>Gold</th></tr>";
echo "<tr>\n";
echo "<td><a href=\"loadhero.php?name=$heroName\">$heroName</a></td>\n";
echo "<td>$heroRace</td>\n";
echo "<td>$heroProf</td>\n";
echo "<td>$heroXp</td>\n";
echo "<td>$heroParty</td>\n";
echo "<td>$heroStr</td>\n";
echo "<td>$heroInt</td>\n";
echo "<td>$heroDex</td>\n";
echo "<td>$heroAgi</td>\n";
echo "<td>$heroWis</td>\n";
echo "<td>$heroPer</td>\n";
echo "<td>$heroAct</td>\n";
echo "<td>$heroCon</td>\n";
echo "<td>$heroCha</td>\n";
echo "<td>$heroGold</td>\n";
echo "</td>\n";
echo "</table>\n";
echo "<br><a href='sendmessage.php?to=$heroName' target='_blank'>Send a message</a><br>\n";
echo "<br/>HP: $heroMaxHp\n";
echo "<br/>MP: $heroMaxMp\n";
echo "<br/>HP Regen: $heroHpRegen\n";
echo "<br/>MP Regen: $heroMpRegen\n";
echo "<br>\n";
echo "<br/>Slashing damage: $heroSDAM\n";
echo "<br/>Piercing damage: $heroPDAM\n";
echo "<br/>Bludgeoning damage: $heroBDAM\n";
echo "<br/><br/>\n";
echo "<br/>Slashing armor: $heroSARM\n";
echo "<br/>Piercing armor: $heroPARM\n";
echo "<br/>Bludgeoning armor: $heroBARM\n";
echo "<br/>Items:<br/>\n";
echo "<br/>Main Hand: $heroMainHandName\n";
echo "<br/>Off Hand: $heroOffHandName\n";
echo "<br/>Head: $heroHeadName\n";
echo "<br/>Torso: $heroTorsoName\n";
echo "<br/>Arms: $heroArmsName\n";
echo "<br/>Legs: $heroLegsName\n";
echo "<br/>Feet: $heroFeetName\n";
}