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: /**
  6:  * Authors: 
  7:  *  - Tyrence (RK2)
  8:  *
  9:  * @Instance
 10:  *
 11:  * Commands this controller contains:
 12:  *  @DefineCommand(
 13:  *      command     = 'trickle', 
 14:  *      accessLevel = 'all', 
 15:  *      description = 'Shows how much skills you will gain by increasing an ability', 
 16:  *      help        = 'trickle.txt'
 17:  *  )
 18:  */
 19: class TrickleController {
 20: 
 21:     /**
 22:      * Name of the module.
 23:      * Set automatically by module loader.
 24:      */
 25:     public $moduleName;
 26: 
 27:     /** @Inject */
 28:     public $text;
 29:     
 30:     /** @Inject */
 31:     public $util;
 32:     
 33:     /** @Inject */
 34:     public $db;
 35:     
 36:     /**
 37:      * This handler is called on bot startup.
 38:      * @Setup
 39:      */
 40:     public function setup() {
 41:         $this->db->loadSQLFile($this->moduleName, 'trickle');
 42:     }
 43: 
 44:     /**
 45:      * View trickle skills
 46:      *
 47:      * @HandlesCommand("trickle")
 48:      * @Matches("/^trickle( ([a-zA-Z]+) ([0-9]+)){1,6}$/i")
 49:      */
 50:     public function trickle1Command($message, $channel, $sender, $sendto, $args) {
 51:         $abilities = array('agi' => 0, 'int' => 0, 'psy' => 0, 'sta' => 0, 'str' => 0, 'sen' => 0);
 52: 
 53:         $array = explode(" ", $message);
 54:         array_shift($array);
 55:         for ($i = 0; isset($array[$i]); $i += 2) {
 56:             $ability = $this->util->getAbility($array[$i]);
 57:             if ($ability == null) {
 58:                 return false;
 59:             }
 60: 
 61:             $abilities[$ability] += $array[1 + $i];
 62:         }
 63: 
 64:         $msg = $this->processAbilities($abilities);
 65:         $sendto->reply($msg);
 66:     }
 67:     
 68:     /**
 69:      * View trickle skills
 70:      *
 71:      * @HandlesCommand("trickle")
 72:      * @Matches("/^trickle( ([0-9]+) ([a-zA-Z]+)){1,6}$/i")
 73:      */
 74:     public function trickle2Command($message, $channel, $sender, $sendto, $args) {
 75:         $abilities = array('agi' => 0, 'int' => 0, 'psy' => 0, 'sta' => 0, 'str' => 0, 'sen' => 0);
 76: 
 77:         $array = explode(" ", $message);
 78:         array_shift($array);
 79:         for ($i = 0; isset($array[$i]); $i += 2) {
 80:             $ability = $this->util->getAbility($array[1 + $i]);
 81:             if ($ability == null) {
 82:                 return false;
 83:             }
 84: 
 85:             $abilities[$ability] += $array[$i];
 86:         }
 87: 
 88:         $msg = $this->processAbilities($abilities);
 89:         $sendto->reply($msg);
 90:     }
 91: 
 92:     /**
 93:      * @HandlesCommand("trickle")
 94:      * @Matches("/^trickle (.+)$/i")
 95:      */
 96:     public function trickleSkillCommand($message, $channel, $sender, $sendto, $args) {
 97:         $search = $args[1];
 98: 
 99:         $data = $this->db->query("SELECT * FROM trickle WHERE name LIKE ?", "%" . str_replace(" ", "%", $search) . "%");
100:         $count = count($data);
101:         if ($count == 0) {
102:             $msg = "Could not find any skills for search '$search'";
103:         } else if ($count == 1) { 
104:             $row = $data[0];
105:             $msg = $this->getTrickleAmounts($row);
106:         } else {
107:             $blob = "";
108:             forEach ($data as $row) {
109:                 $blob .= $this->getTrickleAmounts($row) . "\n";
110:             }
111:             $msg = $this->text->makeBlob("Trickle Info: $search", $blob);
112:         }
113: 
114:         $sendto->reply($msg);
115:     }
116: 
117:     public function getTrickleAmounts($row) {
118:         $arr = ['agi', 'int', 'psy', 'sta', 'str', 'sen'];
119:         $msg = "<highlight>$row->name<end> ";
120:         forEach ($arr as $ability) {
121:             $fieldName = "amount" . ucfirst($ability);
122:             if ($row->$fieldName > 0) {
123:                 $abilityName = $this->util->getAbility($ability, true);
124:                 $value = round(4 / ($row->$fieldName), 2);
125:                 $msg .= "($abilityName: ${value}) ";
126:             }
127:         }
128:         return $msg;
129:     }
130:     
131:     private function processAbilities($abilities) {
132:         $msg = "";
133: 
134:         
135:         $that = $this;
136:         $abilitiesHeader = $this->util->mapFilterCombine($abilities, ", ", function($ability, $value) use ($that) {
137:             if ($value == 0) {
138:                 return null;
139:             } else {
140:                 return $that->util->getAbility($ability, true) . " <highlight>" . $value . "<end>";
141:             }
142:         }); 
143: 
144:         $results = $this->getTrickleResults($abilities);
145:         $blob .= $this->formatOutput($results, $amount, $abilities);
146:         $blob .= "\nBy Tyrence (RK2), inspired by the Bebot command of the same name";
147:         return $this->text->makeBlob("Trickle Results: $abilitiesHeader", $blob);
148:     }
149:     
150:     function getTrickleResults($abilities) {
151:         $sql = "
152:             SELECT
153:                 groupName,
154:                 name,
155:                 amountAgi,
156:                 amountInt,
157:                 amountPsy,
158:                 amountSta,
159:                 amountStr,
160:                 amountSen,
161:                 (amountAgi * {$abilities['agi']}
162:                     + amountInt * {$abilities['int']}
163:                     + amountPsy * {$abilities['psy']}
164:                     + amountSta * {$abilities['sta']}
165:                     + amountStr * {$abilities['str']}
166:                     + amountSen * {$abilities['sen']}) AS amount
167:             FROM
168:                 trickle
169:             GROUP BY
170:                 groupName,
171:                 name,
172:                 amountAgi,
173:                 amountInt,
174:                 amountPsy,
175:                 amountSta,
176:                 amountStr,
177:                 amountSen
178:             HAVING
179:                 amount > 0
180:             ORDER BY
181:                 id";
182: 
183:         return $this->db->query($sql);
184:     }
185:     
186:     function formatOutput($results, $amount, $abilities) {
187:         $msg = "";
188:         $groupName = "";
189:         forEach($results as $result) {
190: 
191:             if ($result->groupName != $groupName) {
192:                 $groupName = $result->groupName;
193:                 $msg .= "\n<header2>$groupName<end>\n";
194:             }
195: 
196:             $amount = $result->amount / 4;
197:             $msg .= "$result->name <highlight>$amount<end>";
198: 
199:             /*
200:             forEach ($abilities as $ability => $value) {
201:                 $ability = ucfirst($ability);
202:                 $abilityField = "amount" . $ability;
203:                 $abilityAmount = $result->$abilityField * 100;
204:                 if ($abilityAmount != 0) {
205:                     $msg .= " (" . $ability . " " . $abilityAmount . "%)";
206:                 }
207:             }
208:             */
209: 
210:             $msg .= "\n";
211:         }
212: 
213:         return $msg;
214:     }
215: }
216: 
Budabot 4 Docs API documentation generated by ApiGen