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: 31: 32:
33: class HelpbotController {
34:
35: 36: 37: 38:
39: public $moduleName;
40:
41:
42: public $db;
43:
44:
45: public $text;
46:
47:
48: public $util;
49:
50: 51: 52: 53:
54: public function setup() {
55: $this->db->loadSQLFile($this->moduleName, 'dyna');
56: }
57:
58: 59: 60: 61:
62: public function dynaLevelCommand($message, $channel, $sender, $sendto, $args) {
63: $search = $args[1];
64: $range1 = $search - 25;
65: $range2 = $search + 25;
66: $data = $this->db->query("SELECT * FROM dynadb d JOIN playfields p ON d.playfield_id = p.id WHERE minQl > ? AND minQl < ? ORDER BY `minQl`", $range1, $range2);
67: $count = count($data);
68:
69: $blob = "Results of Dynacamp Search for '$search'\n\n";
70:
71: $blob .= $this->formatResults($data);
72:
73: $blob .= "Dyna camp information taken from CSP help files: http://creativestudent.com/ao/files-helpfiles.html";
74:
75: $msg = $this->text->makeBlob("Dynacamps ($count)", $blob);
76: $sendto->reply($msg);
77: }
78:
79: 80: 81: 82:
83: public function dynaNameCommand($message, $channel, $sender, $sendto, $args) {
84: $search = str_replace(" ", "%", $args[1]);
85: $data = $this->db->query("SELECT * FROM dynadb d JOIN playfields p ON d.playfield_id = p.id WHERE long_name LIKE ? OR short_name LIKE ? OR mob LIKE ? ORDER BY `minQl`", "%{$search}%", "%{$search}%", "%{$search}%");
86: $count = count($data);
87:
88: $blob = "Results of Dynacamp Search for '$search'\n\n";
89:
90: $blob .= $this->formatResults($data);
91:
92: $blob .= "Dyna camp information taken from CSP help files: http://creativestudent.com/ao/files-helpfiles.html";
93:
94: $msg = $this->text->makeBlob("Dynacamps ($count)", $blob);
95: $sendto->reply($msg);
96: }
97:
98: private function formatResults($data) {
99: $blob = '';
100: forEach($data as $row) {
101: $coordLink = $this->text->makeChatcmd("{$row->long_name} {$row->cX}x{$row->cY}", "/waypoint $row->cX $row->cY $row->playfield_id");
102: $blob .="<pagebreak>$coordLink\n";
103: $blob .="$row->mob - Level <highlight>{$row->minQl}-{$row->maxQl}<end>\n\n";
104: }
105: return $blob;
106: }
107:
108: 109: 110: 111:
112: public function oeCommand($message, $channel, $sender, $sendto, $args) {
113: $oe = $args[1];
114: $oe100 = (int)floor($oe / 0.8);
115: $lowoe100 = (int)floor($oe * 0.8);
116: $oe75 = (int)floor($oe / 0.6);
117: $lowoe75 = (int)floor($oe * 0.6);
118: $oe50 = (int)floor($oe / 0.4);
119: $lowoe50 = (int)floor($oe * 0.4);
120: $oe25 = (int)floor($oe / 0.2);
121: $lowoe25 = (int)floor($oe * 0.2);
122:
123: $blob = "With a skill requirement of <highlight>$oe<end>, you will be\n".
124: "Out of OE: <highlight>$lowoe100<end> or higher\n".
125: "75%: <highlight>$lowoe75<end> - <highlight>" .($lowoe100 - 1). "<end>\n".
126: "50%: <highlight>" .($lowoe50 + 1). "<end> - <highlight>" .($lowoe75 - 1). "<end>\n".
127: "25%: <highlight>" .($lowoe25 + 1). "<end> - <highlight>$lowoe50<end>\n".
128: "0%: <highlight>$lowoe25<end> or lower\n\n".
129: "With a personal skill of <highlight>$oe<end>, you can use up to and be\n".
130: "Out of OE: <highlight>$oe100<end> or lower\n".
131: "75%: <highlight>" .($oe100 + 1). "<end> - <highlight>$oe75<end>\n".
132: "50%: <highlight>" .($oe75 + 1). "<end> - <highlight>" .($oe50 - 1). "<end>\n".
133: "25%: <highlight>$oe50<end> - <highlight>" .($oe25 - 1). "<end>\n".
134: "0%: <highlight>$oe25<end> or higher\n\n".
135: "WARNING: May be plus/minus 1 point!";
136:
137: $msg = "<highlight>{$lowoe100}<end> - {$oe} - <highlight>{$oe100}<end> " . $this->text->makeBlob('More info', $blob, 'Over-equipped Calculation');
138:
139: $sendto->reply($msg);
140: }
141:
142: 143: 144: 145:
146: public function calcCommand($message, $channel, $sender, $sendto, $args) {
147: $calc = strtolower($args[1]);
148:
149:
150: $calc_check = strspn($calc, "0123456789.,+-*x%()/\\ ");
151:
152:
153: if ($calc_check == strlen($calc)) {
154: $result = "";
155:
156: $calc = "\$result = ".$calc.";";
157: eval($calc);
158:
159: if (is_numeric($result)) {
160: $result = round($result, 4);
161: $msg = $args[1]." = <highlight>".$result."<end>";
162: $sendto->reply($msg);
163: } else {
164: return false;
165: }
166: } else {
167: return false;
168: }
169: }
170: }
171: