-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartifactfactory.php
More file actions
59 lines (54 loc) · 2.67 KB
/
artifactfactory.php
File metadata and controls
59 lines (54 loc) · 2.67 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
<?php
require "dbobject.php";
require "artifact.php";
class ArtifactFactory extends DBObject {
public $levels = array("Uncommon", "Rare", "Epic", "Legendary", "Mythic");
public $colors = array("Uncommon"=>"rgba(0, 153, 51, 0.6)", "Rare"=>"rgba(0, 64, 255, 0.6)", "Epic"=>"rgba(153, 51, 255, 0.6)", "Legendary"=>"rgba(255, 153, 51, 0.6)", "Mythic"=>"rgba(67, 244, 244, 0.6)");
public $textsafecolors = array("Uncommon"=>"green", "Rare"=>"blue", "Epic"=>"purple", "Legendary"=>"orange", "Mythic"=>"aqua");
public function __construct() {
parent::__construct("SELECT * FROM Artifacts");
}
public function getArtifact($name, $level) {
$artifact = "";
foreach($this->arrayresult as $tempartifact) {
if($tempartifact["Name"] == $name)
$artifact = $tempartifact;
}
if($artifact != "") {
$returnedartifact = new Artifact($level, $artifact["Name"], $artifact[$level. " Stat"],
$artifact[$level. " Use"], $artifact["Equipment Set"],
$artifact["Set Bonus"], $artifact["Picture"],
$artifact["Type"]);
}
else
$returnedartifact = null;
return $returnedartifact;
}
public function filterArtifacts(...$filters) {
$resultartifacts = array();
foreach($this->arrayresult as $artifact) {
if(is_array($filters[0])) {
$required = count($filters[0]);
$met = array();
$metlevels = array();
for($x = 0; $x < $required; $x++) {
//var_dump($astat);
foreach($this->levels as $lvl) {
if(isset($artifact[$lvl." Stat"]) && strpos($artifact[$lvl." Stat"], $filters[0][$x]) !== false) {
if(!isset($met[$x]))
$met[$x] = 1;
if(!in_array($lvl, $metlevels))
array_push($metlevels, $lvl);
//$resultartifacts[$artifact["Name"]] = $resultartifacts[$artifact["Name"]].", ".$lvl;
}
}
}
if(count($met) == $required)
$resultartifacts[$artifact["Name"]] = implode(",", $metlevels);
}
}
ksort($resultartifacts);
return $resultartifacts;
}
}
?>