1: <?php
2:
3: namespace Budabot\User\Modules;
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: class BosslootController {
31:
32: 33: 34: 35:
36: public $moduleName;
37:
38:
39: public $db;
40:
41:
42: public $text;
43:
44:
45: public $util;
46:
47:
48: public function setup() {
49: $this->db->loadSQLFile($this->moduleName, "boss_namedb");
50: $this->db->loadSQLFile($this->moduleName, "boss_lootdb");
51: }
52:
53: 54: 55: 56: 57: 58:
59: public function bossCommand($message, $channel, $sender, $sendto, $args) {
60: $search = strtolower($args[1]);
61:
62: list($query, $params) = $this->util->generateQueryFromParams(explode(' ', $search), 'bossname');
63:
64: $bosses = $this->db->query("SELECT bossid, bossname, w.answer
65: FROM boss_namedb b LEFT JOIN whereis w ON b.bossname = w.name
66: WHERE $query", $params);
67: $count = count($bosses);
68:
69: if ($count > 1) {
70: $blob = "Results of Search for '$search'\n\n";
71:
72: forEach ($bosses as $row) {
73: $blob .= $this->getBossLootOutput($row);
74: }
75: $output = $this->text->makeBlob("Boss Search Results ($count)", $blob);
76: } else if ($count == 1) {
77:
78: $row = $bosses[0];
79:
80: $blob .= "Location: <highlight>{$row->answer}<end>\n\n";
81: $blob .= "Loot:\n\n";
82:
83: $data = $this->db->query("SELECT * FROM boss_lootdb b LEFT JOIN
84: aodb a ON (b.itemname = a.name)
85: WHERE b.bossid = ?", $row->bossid);
86: forEach ($data as $row2) {
87: $blob .= $this->text->makeImage($row2->icon) . "\n";
88: $blob .= $this->text->makeItem($row2->lowid, $row2->highid, $row2->highql, $row2->itemname) . "\n\n";
89: }
90: $output = $this->text->makeBlob($row->bossname, $blob);
91: } else {
92: $output = "There were no matches for your search.";
93: }
94: $sendto->reply($output);
95: }
96:
97: 98: 99: 100: 101: 102:
103: public function bosslootCommand($message, $channel, $sender, $sendto, $args) {
104: $search = strtolower($args[1]);
105:
106: $blob = "Bosses that drop items matching '$search':\n\n";
107:
108: list($query, $params) = $this->util->generateQueryFromParams(explode(' ', $search), 'b1.itemname');
109:
110: $loot = $this->db->query("SELECT DISTINCT b2.bossid, b2.bossname, w.answer
111: FROM boss_lootdb b1 JOIN boss_namedb b2 ON b2.bossid = b1.bossid
112: LEFT JOIN whereis w ON w.name = b2.bossname WHERE $query", $params);
113: $count = count($loot);
114:
115: if ($count != 0) {
116: forEach ($loot as $row) {
117: $blob .= $this->getBossLootOutput($row);
118: }
119: $output = $this->text->makeBlob("Bossloot Search Results ($count)", $blob);
120: } else {
121: $output .= "There were no matches for your search.";
122: }
123: $sendto->reply($output);
124: }
125:
126: public function getBossLootOutput($row) {
127: $data = $this->db->query("SELECT * FROM boss_lootdb b LEFT JOIN
128: aodb a ON (b.itemname = a.name)
129: WHERE b.bossid = ?", $row->bossid);
130:
131: $blob = '<pagebreak>' . $this->text->makeChatcmd($row->bossname, "/tell <myname> boss $row->bossname") . "\n";
132: $blob .= "Location: <highlight>{$row->answer}<end>\n";
133: $blob .= "Loot: ";
134: forEach ($data as $row2) {
135: $blob .= $this->text->makeItem($row2->lowid, $row2->highid, $row2->highql, $row2->itemname) . ', ';
136: }
137: $blob .= "\n\n";
138: return $blob;
139: }
140: }
141:
142: