-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.php
119 lines (118 loc) · 3.22 KB
/
item.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
<?php
class Item{
public $category;
public $itemclass;
public $name;
public $strrep;
public $affects;
public $carryable;
public function __construct($itemclass,$name){
$this->name=$name;
$this->itemclass=$itemclass;
if ($itemclass=="corpse"){
$this->category="corpse";
$this->affects=NULL;
$this->carryable=false;
$this->strrep=$name." ".$itemclass;
if ($name=="orcslave"||$name=="orcsoldier"||$name=="orcshaman"||$name=="orccaptain") {
$this->name="orc";
}
if ($name=="goblinsoldier"||$name=="goblinshaman") {
$this->name="goblin";
}
} else if ($itemclass=="none"){
$info=array("category"=>"none","affects"=>false,"carryable"=>false);
foreach ($info as $key => $val){
$this->$key=$val;
}
$this->strrep="nothing";
} else {
$info=$this->findinfo($itemclass,$name);
foreach ($info as $key => $val){
if ($key=="affects") {
$this->$key=json_decode($val,true);
} else $this->$key=$val;
}
$this->carryable=true;
if ($this->category=="consumable"||$this->itemclass=="ring"){
$this->strrep=$this->itemclass." of ".$this->name;
} else if ($this->itemclass=="weapon"||$this->name=="robes"){
$this->strrep=$this->name;
} else {
$this->strrep=$this->name." ".$this->itemclass;
}
}
}
public function findinfo($itemclass,$name){
//query the creatures database
global $mysqli;
$query="SELECT * FROM items WHERE name='".$name."'";
if ($mysqli->query($query)) {
$info=$mysqli->query($query)->fetch_assoc();
}
return $info;
}
public function setquality(){
$quality=false;
if ($this->itemclass=="weapon"){
$rn=rand(1,6);
if ($rn==6) {
$quality=true;
$this->affects["acc"]+=1;
$this->strrep="well balanced ".$this->strrep;
}
} else if ($this->itemclass=="armour"){
$rn=rand(1,5);
if ($rn==5) {
$quality=true;
$this->affects["armour"]+=1;
$this->strrep="thick ".$this->strrep;
}
}
return $quality;
}
public function setenchant($floor){
$enchant=false;
if ($this->itemclass=="weapon"){
$rn=rand(1,5);
if ($rn==5) {
$enchant=rand(1,ceil($floor/3));
for ($i=0;$i<$enchant;$i++){
$rn2=rand(0,2);
if ($rn2==2) $rn2=rand(0,2);
$weaponattr=array("bash","slash","pierce");
$this->affects[$weaponattr[$rn2]]++;
}
$this->strrep="+".$enchant." enchanted ".$this->strrep;
}
} else if ($this->itemclass=="armour"){
$rn=rand(1,5);
if ($rn==5) {
$enchant=rand(1,min(floor($floor/3)+1,4));
$this->affects["block"]+=$enchant;
$this->strrep="+".$enchant." enchanted ".$this->strrep;
}
} else if ($this->name=="dexterity"){
$enchant=rand(0,$floor);
$this->affects["dexterity"]+=$enchant;
$this->strrep="+".($enchant+1)." ".$this->strrep;
} else if ($this->name=="strength"){
$enchant=rand(0,$floor);
$this->affects["strength"]+=$enchant;
$this->strrep="+".($enchant+1)." ".$this->strrep;
} else if ($this->name=="magic"){
$enchant=rand(0,$floor);
$this->affects["maxmana"]+=$enchant;
$this->strrep="+".($enchant+1)." ".$this->strrep;
}
return $enchant;
}
public function setbrand(){
$rn=rand(1,5);
if ($rn==5&&$this->itemclass=="weapon") {
$this->strrep=$this->strrep." of possibility";
}
}
public function setego(){
}
}