Overview

Namespaces

  • Budabot
    • Core
      • Modules
    • User
      • Modules
  • None
  • Tyrence
    • Modules

Classes

  • AccessLevel
  • Budabot\Core\AccessManager
  • Budabot\Core\AdminManager
  • Budabot\Core\AOChat
  • Budabot\Core\AOChatPacket
  • Budabot\Core\AOChatQueue
  • Budabot\Core\AOExtMsg
  • Budabot\Core\AsyncHttp
  • Budabot\Core\AutoInject
  • Budabot\Core\BotRunner
  • Budabot\Core\Budabot
  • Budabot\Core\BuddylistManager
  • Budabot\Core\CacheManager
  • Budabot\Core\CacheResult
  • Budabot\Core\ClassLoader
  • Budabot\Core\ColorSettingHandler
  • Budabot\Core\CommandAlias
  • Budabot\Core\CommandManager
  • Budabot\Core\ConfigFile
  • Budabot\Core\DB
  • Budabot\Core\DBRow
  • Budabot\Core\EventLoop
  • Budabot\Core\EventManager
  • Budabot\Core\GuildChannelCommandReply
  • Budabot\Core\GuildManager
  • Budabot\Core\HelpManager
  • Budabot\Core\Http
  • Budabot\Core\HttpRequest
  • Budabot\Core\LegacyLogger
  • Budabot\Core\LimitsController
  • Budabot\Core\LoggerWrapper
  • Budabot\Core\MMDBParser
  • Budabot\Core\Modules\AdminController
  • Budabot\Core\Modules\AliasController
  • Budabot\Core\Modules\AltInfo
  • Budabot\Core\Modules\AltsController
  • Budabot\Core\Modules\BanController
  • Budabot\Core\Modules\BuddylistController
  • Budabot\Core\Modules\ColorsController
  • Budabot\Core\Modules\CommandlistController
  • Budabot\Core\Modules\CommandSearchController
  • Budabot\Core\Modules\ConfigController
  • Budabot\Core\Modules\EventlistController
  • Budabot\Core\Modules\HelpController
  • Budabot\Core\Modules\LogsController
  • Budabot\Core\Modules\PlayerLookupController
  • Budabot\Core\Modules\ProfileCommandReply
  • Budabot\Core\Modules\ProfileController
  • Budabot\Core\Modules\SettingsController
  • Budabot\Core\Modules\SQLController
  • Budabot\Core\Modules\SystemController
  • Budabot\Core\Modules\UsageController
  • Budabot\Core\Modules\WhitelistController
  • Budabot\Core\NumberSettingHandler
  • Budabot\Core\OptionsSettingHandler
  • Budabot\Core\PlayerHistory
  • Budabot\Core\PlayerHistoryManager
  • Budabot\Core\PlayerManager
  • Budabot\Core\Preferences
  • Budabot\Core\PrivateChannelCommandReply
  • Budabot\Core\PrivateMessageCommandReply
  • Budabot\Core\Registry
  • Budabot\Core\SettingHandler
  • Budabot\Core\SettingManager
  • Budabot\Core\SettingObject
  • Budabot\Core\SocketManager
  • Budabot\Core\SocketNotifier
  • Budabot\Core\SubcommandManager
  • Budabot\Core\Text
  • Budabot\Core\TextSettingHandler
  • Budabot\Core\Timer
  • Budabot\Core\TimerEvent
  • Budabot\Core\TimeSettingHandler
  • Budabot\Core\Util
  • Budabot\Core\xml
  • Budabot\User\Modules\AlienArmorController
  • Budabot\User\Modules\AlienBioController
  • Budabot\User\Modules\AlienMiscController
  • Budabot\User\Modules\AOSpeakController
  • Budabot\User\Modules\AOUController
  • Budabot\User\Modules\AXPController
  • Budabot\User\Modules\BankController
  • Budabot\User\Modules\BosslootController
  • Budabot\User\Modules\BroadcastController
  • Budabot\User\Modules\BuffPerksController
  • Budabot\User\Modules\CacheController
  • Budabot\User\Modules\ChatAssistController
  • Budabot\User\Modules\ChatCheckController
  • Budabot\User\Modules\ChatLeaderController
  • Budabot\User\Modules\ChatRallyController
  • Budabot\User\Modules\ChatSayController
  • Budabot\User\Modules\ChatTopicController
  • Budabot\User\Modules\CityWaveController
  • Budabot\User\Modules\CloakController
  • Budabot\User\Modules\ClusterController
  • Budabot\User\Modules\CountdownController
  • Budabot\User\Modules\DevController
  • Budabot\User\Modules\DingController
  • Budabot\User\Modules\EventsController
  • Budabot\User\Modules\FightController
  • Budabot\User\Modules\FindOrgController
  • Budabot\User\Modules\FindPlayerController
  • Budabot\User\Modules\FunController
  • Budabot\User\Modules\GitController
  • Budabot\User\Modules\GuideController
  • Budabot\User\Modules\GuildController
  • Budabot\User\Modules\HelpbotController
  • Budabot\User\Modules\HtmlDecodeController
  • Budabot\User\Modules\ImplantController
  • Budabot\User\Modules\ImplantDesignerController
  • Budabot\User\Modules\InactiveMemberController
  • Budabot\User\Modules\ItemsController
  • Budabot\User\Modules\KillOnSightController
  • Budabot\User\Modules\LevelController
  • Budabot\User\Modules\LinksController
  • Budabot\User\Modules\LootListsController
  • Budabot\User\Modules\MdbController
  • Budabot\User\Modules\MessageInfoCommandReply
  • Budabot\User\Modules\MockCommandReply
  • Budabot\User\Modules\NanoController
  • Budabot\User\Modules\NewsController
  • Budabot\User\Modules\NotesController
  • Budabot\User\Modules\OnlineController
  • Budabot\User\Modules\OrgHistoryController
  • Budabot\User\Modules\OrglistController
  • Budabot\User\Modules\OrgMembersController
  • Budabot\User\Modules\OSController
  • Budabot\User\Modules\PlayerHistoryController
  • Budabot\User\Modules\PlayfieldController
  • Budabot\User\Modules\PocketbossController
  • Budabot\User\Modules\PremadeImplantController
  • Budabot\User\Modules\PrivateChannelController
  • Budabot\User\Modules\QuoteController
  • Budabot\User\Modules\RaffleController
  • Budabot\User\Modules\RaidController
  • Budabot\User\Modules\RandomController
  • Budabot\User\Modules\RecipeController
  • Budabot\User\Modules\RelayController
  • Budabot\User\Modules\ReputationController
  • Budabot\User\Modules\ResearchController
  • Budabot\User\Modules\RunAsController
  • Budabot\User\Modules\SendTellController
  • Budabot\User\Modules\ShoppingController
  • Budabot\User\Modules\SilenceController
  • Budabot\User\Modules\SkillsController
  • Budabot\User\Modules\SpiritsController
  • Budabot\User\Modules\StopwatchController
  • Budabot\User\Modules\Teamspeak3
  • Budabot\User\Modules\TeamspeakController
  • Budabot\User\Modules\TestController
  • Budabot\User\Modules\TimeController
  • Budabot\User\Modules\TimerController
  • Budabot\User\Modules\TimezoneController
  • Budabot\User\Modules\TowerController
  • Budabot\User\Modules\TrackerController
  • Budabot\User\Modules\TrickleController
  • Budabot\User\Modules\UnixtimeController
  • Budabot\User\Modules\VoteController
  • Budabot\User\Modules\WeatherController
  • Budabot\User\Modules\WhatBuffsController
  • Budabot\User\Modules\WhereisController
  • Budabot\User\Modules\WhoisController
  • Budabot\User\Modules\WhoisOrgController
  • Budabot\User\Modules\WhompahController
  • Command
  • DefaultStatus
  • DefineCommand
  • Description
  • Event
  • HandlesCommand
  • Help
  • Inject
  • Instance
  • Intoptions
  • Matches
  • Options
  • Setting
  • Setup
  • Type
  • Tyrence\Modules\DemoResponseCommandReply
  • Tyrence\Modules\SameChannelResponseController
  • Visibility

Interfaces

  • Budabot\Core\CommandReply

Exceptions

  • Budabot\Core\InvalidHttpRequest
  • Budabot\Core\SQLException
  • Budabot\Core\StopExecutionException

Functions

  • Budabot\Core\isWindows
  • Budabot\Core\Modules\read_input
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Budabot\User\Modules;
  4: 
  5: use stdClass;
  6: 
  7: /**
  8:  * Authors: 
  9:  *  - Tyrence (RK2)
 10:  *
 11:  * @Instance
 12:  *
 13:  * Commands this controller contains:
 14:  *  @DefineCommand(
 15:  *      command     = 'perks',
 16:  *      accessLevel = 'all',
 17:  *      description = 'Show buff perks',
 18:  *      help        = 'perks.txt'
 19:  *  )
 20:  */
 21: class BuffPerksController {
 22:     /**
 23:      * Name of the module.
 24:      * Set automatically by module loader.
 25:      */
 26:     public $moduleName;
 27:     
 28:     /** @Inject */
 29:     public $text;
 30:     
 31:     /** @Inject */
 32:     public $util;
 33:     
 34:     /** @Inject */
 35:     public $db;
 36:     
 37:     /** @Inject */
 38:     public $playerManager;
 39:     
 40:     /** @Setup */
 41:     public function setup() {
 42:         $this->db->loadSQLFile($this->moduleName, "perks");
 43:         
 44:         $perkInfo = $this->getPerkInfo();
 45:         
 46:         $this->db->exec("DELETE FROM perk");
 47:         $this->db->exec("DELETE FROM perk_level");
 48:         $this->db->exec("DELETE FROM perk_level_prof");
 49:         $this->db->exec("DELETE FROM perk_level_buffs");
 50: 
 51:         $perkId = 1;
 52:         $perkLevelId = 1;
 53:         forEach ($perkInfo as $perk) {
 54:             $this->db->exec("INSERT INTO perk (id, name) VALUES (?, ?)", $perkId, $perk->name);
 55:             
 56:             forEach ($perk->levels as $level) {
 57:                 $this->db->exec("INSERT INTO perk_level (id, perk_id, number, min_level) VALUES (?, ?, ?, ?)", $perkLevelId, $perkId, $level->perkLevel, $level->minLevel);
 58:                 
 59:                 forEach ($level->professions as $profession) {
 60:                     $this->db->exec("INSERT INTO perk_level_prof (perk_level_id, profession) VALUES (?, ?)", $perkLevelId, $profession);
 61:                 }
 62: 
 63:                 forEach ($level->buffs as $buff => $amount) {
 64:                     $this->db->exec("INSERT INTO perk_level_buffs (perk_level_id, skill, amount) VALUES (?, ?, ?)", $perkLevelId, $buff, $amount);
 65:                 }
 66:                 
 67:                 $perkLevelId++;
 68:             }
 69: 
 70:             $perkId++;
 71:         }
 72:     }
 73:     
 74:     /**
 75:      * @HandlesCommand("perks")
 76:      * @Matches("/^perks$/i")
 77:      * @Matches("/^perks ([a-z-]*) (\d+)$/i")
 78:      * @Matches("/^perks ([a-z-]*) (\d+) (.*)$/i")
 79:      * @Matches("/^perks (\d+) ([a-z-]*)$/i")
 80:      * @Matches("/^perks (\d+) ([a-z-]*) (.*)$/i")
 81:      */
 82:     public function buffPerksCommand($message, $channel, $sender, $sendto, $args) {
 83:         if (count($args) == 1) {
 84:             $whois = $this->playerManager->getByName($sender);
 85:             if (empty($whois)) {
 86:                 $msg = "Could not retrieve whois info for you.";
 87:                 $sendto->reply($msg);
 88:                 return;
 89:             } else {
 90:                 $profession = $whois->profession;
 91:                 $minLevel = $whois->level;
 92:             }
 93:         } else {
 94:             $first = $this->util->getProfessionName($args[1]);
 95:             $second = $this->util->getProfessionName($args[2]);
 96:             if (!empty($first)) {
 97:                 $profession = $first;
 98:                 $minLevel = $args[2];
 99:             } else if (!empty($second)) {
100:                 $profession = $second;
101:                 $minLevel = $args[1];
102:             } else {
103:                 return false;
104:             }
105:         }
106:         
107:         $params = array ($profession, $minLevel);
108:         
109:         if (count($args) == 4) {
110:             $tmp = explode(" ", $args[3]);
111:             list($skillQuery, $newParams) = $this->util->generateQueryFromParams($tmp, 'plb.skill');
112:             $params = array_merge($params, $newParams);
113:             $skillQuery = "AND " . $skillQuery;
114:         }
115:         
116:         $sql = "SELECT
117:                 p.name AS perk_name,
118:                 MAX(pl.number) AS max_perk_level,
119:                 SUM(plb.amount) AS buff_amount,
120:                 plb.skill
121:             FROM
122:                 perk_level_prof plp
123:                 JOIN perk_level pl ON plp.perk_level_id = pl.id
124:                 JOIN perk_level_buffs plb ON pl.id = plb.perk_level_id
125:                 JOIN perk p ON pl.perk_id = p.id
126:             WHERE
127:                 plp.profession = ?
128:                 AND pl.min_level <= ?
129:                 $skillQuery
130:             GROUP BY
131:                 p.name,
132:                 plb.skill
133:             ORDER BY
134:                 p.name";
135: 
136:         $data = $this->db->query($sql, $params);
137:         
138:         if (empty($data)) {
139:             $msg = "Could not find any perks for level $minLevel $profession.";
140:         } else {
141:             $currentPerk = '';
142:             $buffs = array();
143:             $blob = '';
144:             $numPerks = 0;
145:             forEach ($data as $row) {
146:                 if ($row->perk_name != $currentPerk) {
147:                     $blob .= "\n<header2>$row->perk_name {$row->max_perk_level}<end>\n";
148:                     $currentPerk = $row->perk_name;
149:                     $numPerks += $row->max_perk_level;
150:                 }
151:                 
152:                 $blob .= "$row->skill <highlight>$row->buff_amount<end>\n";
153:                 $buffs[$row->skill] += $row->buff_amount;
154:             }
155:             
156:             $msg = $this->text->makeBlob("Buff Perks for $minLevel $profession", $blob);
157:         }
158:         $sendto->reply($msg);
159:     }
160:     
161:     public function getPerkInfo() {
162:         $path = getcwd() . "/modules/" . $this->moduleName . "/perks.csv";
163:         $lines = explode("\n", file_get_contents($path));
164:         $perks = array();
165:         forEach ($lines as $line) {
166:             $line = trim($line);
167:             
168:             if (empty($line)) {
169:                 continue;
170:             }
171:             
172:             list($name, $perkLevel, $minLevel, $profs, $buffs) = explode("|", $line);
173:             $perk = $perks[$name];
174:             if (empty($perk)) {
175:                 $perk = new stdClass;
176:                 $perks[$name] = $perk;
177:                 $perk->name = $name;
178:             }
179:             
180:             $level = new stdClass;
181:             $perk->levels[$perkLevel] = $level;
182: 
183:             $level->perkLevel = $perkLevel;
184:             $level->minLevel = $minLevel;
185:             
186:             $level->professions = array();
187:             $professions = explode(",", $profs);
188:             forEach ($professions as $prof) {
189:                 $profession = $this->util->getProfessionName(trim($prof));
190:                 if (empty($profession)) {
191:                     echo "Error parsing profession: '$prof'\n";
192:                 } else {
193:                     $level->professions []= $profession;
194:                 }
195:             }
196:             
197:             $level->buffs = array();
198:             $buffs = explode(",", $buffs);
199:             forEach ($buffs as $buff) {
200:                 $buff = trim($buff);
201:                 $pos = strrpos($buff, " ");
202: 
203:                 $skill = substr($buff, 0, $pos + 1);
204:                 $amount = substr($buff, $pos + 1);
205: 
206:                 $level->buffs[$skill] = $amount;
207:             }
208:         }
209:         
210:         return $perks;
211:     }
212: }
Budabot 4 Docs API documentation generated by ApiGen