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 Exception;
  6: 
  7: /**
  8:  * Authors: 
  9:  *  - Tyrence (RK2)
 10:  *  - Imoutochan (RK1)
 11:  *
 12:  * @Instance
 13:  *
 14:  * Commands this class contains:
 15:  *  @DefineCommand(
 16:  *      command     = 'implant',
 17:  *      accessLevel = 'all',
 18:  *      description = 'Shows info about implants given a QL or stats',
 19:  *      help        = 'implant.txt'
 20:  *  )
 21:  *  @DefineCommand(
 22:  *      command     = 'ladder',
 23:  *      accessLevel = 'all',
 24:  *      description = 'Show sequence of laddering implants for maximum ability or treatment',
 25:  *      help        = 'ladder.txt'
 26:  *  )
 27:  */
 28: class ImplantController {
 29: 
 30:     /**
 31:      * Name of the module.
 32:      * Set automatically by module loader.
 33:      */
 34:     public $moduleName;
 35:     
 36:     /** @Inject */
 37:     public $db;
 38: 
 39:     /** @Inject */
 40:     public $text;
 41: 
 42:     /** @Inject */
 43:     public $util;
 44:     
 45:     private $slots = array('head', 'eye', 'ear', 'rarm', 'chest', 'larm', 'rwrist', 'waist', 'lwrist', 'rhand', 'legs', 'lhand', 'feet');
 46:     
 47:     /**
 48:      * @Setup
 49:      */
 50:     public function setup() {
 51:         $this->db->loadSQLFile($this->moduleName, "implant_requirements");
 52:         $this->db->loadSQLFile($this->moduleName, "premade_implant");
 53:     }
 54:     
 55:     /**
 56:      * @HandlesCommand("implant")
 57:      * @Matches("/^implant ([0-9]+)$/i")
 58:      */
 59:     public function implantQlCommand($message, $channel, $sender, $sendto, $args) {
 60:         $ql = $args[1];
 61: 
 62:         // make sure the $ql is an integer between 1 and 300
 63:         if (($ql < 1) || ($ql > 300)) {
 64:             $msg = "You must enter a value between 1 and 300.";
 65:         } else {
 66:             $obj = $this->getRequirements($ql);
 67:             $clusterInfo = $this->formatClusterBonuses($obj);
 68:             $link = $this->text->makeBlob("QL$obj->ql", $clusterInfo, "Implant Info (QL $obj->ql)");
 69:             $msg = "QL $ql implants--Ability: {$obj->ability}, Treatment: {$obj->treatment} $link";
 70: 
 71:             $msg = "$link: <highlight>$obj->ability<end> Ability, <highlight>$obj->treatment<end> Treatment";
 72:         }
 73: 
 74:         $sendto->reply($msg);
 75:     }
 76: 
 77:     /**
 78:      * @HandlesCommand("implant")
 79:      * @Matches("/^implant ([0-9]+) ([0-9]+)$/i")
 80:      */
 81:     public function implantRequirementsCommand($message, $channel, $sender, $sendto, $args) {
 82:         $ability = $args[1];
 83:         $treatment = $args[2];
 84: 
 85:         if ($treatment < 11 || $ability < 6) {
 86:             $msg = "You do not have enough treatment or ability to wear an implant.";
 87:         } else {
 88:             $obj = $this->findMaxImplantQlByReqs($ability, $treatment);
 89:             $clusterInfo = $this->formatClusterBonuses($obj);
 90:             $link = $this->text->makeBlob("QL$obj->ql", $clusterInfo, "Implant Info (QL $obj->ql)");
 91: 
 92:             $msg = "$link: <highlight>$obj->ability<end> Ability, <highlight>$obj->treatment<end> Treatment";
 93:         }
 94:         $sendto->reply($msg);
 95:     }
 96:     
 97:     /**
 98:      * @HandlesCommand("ladder")
 99:      * @Matches("/^ladder (.+) (\d+)$/i")
100:      */
101:     public function ladderCommand($message, $channel, $sender, $sendto, $args) {
102:         $type = strtolower($args[1]);
103:         $startingValue = $args[2];
104:         
105:         if ($type == 'treat') {
106:             $type = 'treatment';
107:         }
108:         
109:         // allow treatment, ability, or any of the 6 abilities
110:         if ($type != 'treatment' && $type != 'ability') {
111:             $type = $this->util->getAbility($type, true);
112:             if ($type === null) {
113:                 return false;
114:             }
115:             $type = strtolower($type);
116:         }
117: 
118:         $value = $startingValue;
119:         $prefix = $type == 'treatment' ? 'skill' : 'ability';
120:         
121:         $blob = "Starting $type: $value\n\n-------------------\n\n";
122:         
123:         $that = $this;
124:         if ($type == 'treatment') {
125:             if ($value < 11) {
126:                 $sendto->reply("Base treatment must be at least <highlight>11<end>.");
127:                 return;
128:             }
129:         
130:             $getMax = function($value) use ($that) {
131:                 return $that->findMaxImplantQlByReqs(10000, $value);
132:             };
133:         } else {
134:             if ($value < 6) {
135:                 $sendto->reply("Base ability must be at least <highlight>6<end>.");
136:                 return;
137:             }
138:         
139:             $getMax = function($value) use ($that) {
140:                 return $that->findMaxImplantQlByReqs($value, 10000);
141:             };
142:         }
143: 
144:         $shiny = null;
145:         $bright = null;
146:         $faded = null;
147:         $added = true;
148: 
149:         // will continue to loop as long as at least one implant is added each loop
150:         while ($added) {
151:             $added = false;
152:             
153:             // add shiny
154:             $tempValue = $shiny === null ? $value : $value - $shiny->{$prefix . 'Shiny'};
155:             $newShiny = $getMax($tempValue);
156:             if ($shiny === null || $newShiny->{$prefix . 'Shiny'} > $shiny->{$prefix . 'Shiny'}) {
157:                 $added = true;
158:                 if ($shiny !== null) {
159:                     $value -= $shiny->{$prefix . 'Shiny'};
160:                     $blob .= "Remove shiny QL $shiny->ql\n\n";
161:                 }
162:                 $shiny = $newShiny;
163:                 $value += $shiny->{$prefix . 'Shiny'};
164:                 $lowest = $shiny->{'lowest' . ucfirst($prefix) . 'Shiny'};
165:                 $blob .= "<highlight>Add shiny QL $shiny->ql<end> ($lowest) - Treatment: {$shiny->treatment}, Ability: {$shiny->ability}\n\n";
166:             }
167:             
168:             // add bright
169:             $tempValue = $bright === null ? $value : $value - $bright->{$prefix . 'Bright'};
170:             $newBright = $getMax($tempValue);
171:             if ($bright === null || $newBright->{$prefix . 'Bright'} > $bright->{$prefix . 'Bright'}) {
172:                 $added = true;
173:                 if ($bright !== null) {
174:                     $value -= $bright->{$prefix . 'Bright'};
175:                     $blob .= "Remove bright QL $bright->ql\n\n";
176:                 }
177:                 $bright = $newBright;
178:                 $value += $bright->{$prefix . 'Bright'};
179:                 $lowest = $bright->{'lowest' . ucfirst($prefix) . 'Bright'};
180:                 $blob .= "<highlight>Add bright QL $bright->ql<end> ($lowest) - Treatment: {$bright->treatment}, Ability: {$bright->ability}\n\n";
181:             }
182:             
183:             // add faded
184:             $tempValue = $faded === null ? $value : $value - $faded->{$prefix . 'Faded'};
185:             $newFaded = $getMax($tempValue);
186:             if ($faded === null || $newFaded->{$prefix . 'Faded'} > $faded->{$prefix . 'Faded'}) {
187:                 $added = true;
188:                 if ($faded !== null) {
189:                     $value -= $faded->{$prefix . 'Faded'};
190:                     $blob .= "Remove faded QL $faded->ql\n\n";
191:                 }
192:                 $faded = $newFaded;
193:                 $value += $faded->{$prefix . 'Faded'};
194:                 $lowest = $faded->{'lowest' . ucfirst($prefix) . 'Faded'};
195:                 $blob .= "<highlight>Add faded QL $faded->ql<end> ($lowest) - Treatment: {$faded->treatment}, Ability: {$faded->ability}\n\n";
196:             }
197:         }
198:         
199:         $blob .= "-------------------\n\nEnding $type: $value";
200:         $blob .= "\n\n<highlight>Inspired by a command written by Lucier of the same name<end>";
201:         $msg = $this->text->makeBlob("Laddering from $startingValue to $value " . ucfirst(strtolower($type)), $blob);
202:         
203:         $sendto->reply($msg);
204:     }
205: 
206:     // implant functions
207:     public function getRequirements($ql) {
208:         $sql = "SELECT * FROM implant_requirements WHERE ql = ?";
209: 
210:         $row = $this->db->queryRow($sql, $ql);
211: 
212:         $this->addClusterInfo($row);
213: 
214:         return $row;
215:     }
216: 
217:     public function findMaxImplantQlByReqs($ability, $treatment) {
218:         $sql = "SELECT * FROM implant_requirements WHERE ability <= ? AND treatment <= ? ORDER BY ql DESC LIMIT 1";
219: 
220:         $row = $this->db->queryRow($sql, $ability, $treatment);
221: 
222:         $this->addClusterInfo($row);
223: 
224:         return $row;
225:     }
226: 
227:     public function formatClusterBonuses($obj) {
228:         $msg .= "You will gain for most skills:\n" .
229:             "<tab>Shiny    <highlight>$obj->skillShiny<end> ($obj->lowestSkillShiny - $obj->highestSkillShiny)\n" .
230:             "<tab>Bright    <highlight>$obj->skillBright<end> ($obj->lowestSkillBright - $obj->highestSkillBright)\n" .
231:             "<tab>Faded   <highlight>$obj->skillFaded<end> ($obj->lowestSkillFaded - $obj->highestSkillFaded)\n" .
232:             "-----------------------\n" .
233:             "<tab>Total   $obj->skillTotal\n";
234: 
235:         $msg .= "\n\n";
236: 
237:         $msg .= "You will gain for abilities:\n" .
238:             "<tab>Shiny    <highlight>$obj->abilityShiny<end> ($obj->lowestAbilityShiny - $obj->highestAbilityShiny)\n" .
239:             "<tab>Bright    <highlight>$obj->abilityBright<end> ($obj->lowestAbilityBright - $obj->highestAbilityBright)\n" .
240:             "<tab>Faded   <highlight>$obj->abilityFaded<end> ($obj->lowestAbilityFaded - $obj->highestAbilityFaded)\n" .
241:             "-----------------------\n" .
242:             "<tab>Total   $obj->abilityTotal\n";
243: 
244: 
245:         if ($obj->ql > 250) {
246: 
247:             $msg .= "\n\nRequires Title Level 6";
248: 
249:         } else if ($obj->ql > 200) {
250: 
251:             $msg .= "\n\nRequires Title Level 5";
252:         }
253: 
254:         $msg .= "\n\nMinimum QL for clusters:\n" .
255:             "<tab>Shiny: $obj->minShinyClusterQl\n" .
256:             "<tab>Bright: $obj->minBrightClusterQl\n" .
257:             "<tab>Faded: $obj->minFadedClusterQl\n";
258: 
259:         $msg .= "\n\nWritten by Tyrence (RK2)";
260: 
261:         return $msg;
262:     }
263: 
264:     public function addClusterInfo($obj) {
265:         if ($obj === null) {
266:             return;
267:         }
268: 
269:         $this->setHighestAndLowestQls($obj, 'abilityShiny');
270:         $this->setHighestAndLowestQls($obj, 'abilityBright');
271:         $this->setHighestAndLowestQls($obj, 'abilityFaded');
272:         $this->setHighestAndLowestQls($obj, 'skillShiny');
273:         $this->setHighestAndLowestQls($obj, 'skillBright');
274:         $this->setHighestAndLowestQls($obj, 'skillFaded');
275: 
276:         $obj->abilityTotal = $obj->abilityShiny + $obj->abilityBright + $obj->abilityFaded;
277:         $obj->skillTotal = $obj->skillShiny + $obj->skillBright + $obj->skillFaded;
278: 
279:         $obj->minShinyClusterQl = $this->getClusterMinQl($obj->ql, 'shiny');
280:         $obj->minBrightClusterQl = $this->getClusterMinQl($obj->ql, 'bright');
281:         $obj->minFadedClusterQl = $this->getClusterMinQl($obj->ql, 'faded');
282: 
283:         // if implant QL is 201+, then clusters must be refined and must be QL 201+ also
284:         if ($obj->ql >= 201) {
285:             if ($obj->minShinyClusterQl < 201) {
286:                 $obj->minShinyClusterQl = 201;
287:             }
288:             if ($obj->minBrightClusterQl < 201) {
289:                 $obj->minBrightClusterQl = 201;
290:             }
291:             if ($obj->minFadedClusterQl < 201) {
292:                 $obj->minFadedClusterQl = 201;
293:             }
294:         }
295:     }
296:     
297:     public function getClusterMinQl($ql, $grade) {
298:         if ($grade == 'shiny') {
299:             return floor($ql * 0.86);
300:         } else if ($grade == 'bright') {
301:             return floor($ql * 0.84);
302:         } else if ($grade == 'faded') {
303:             return floor($ql * 0.82);
304:         } else {
305:             throw new Exception("Invalid grade: '$grade'.  Must be one of: 'shiny', 'bright', 'faded'");
306:         }
307:     }
308: 
309:     public function setHighestAndLowestQls($obj, $var) {
310:         $varValue = $obj->$var;
311: 
312:         $sql = "SELECT MAX(ql) as max, MIN(ql) as min FROM implant_requirements WHERE $var = ?";
313:         $row = $this->db->queryRow($sql, $varValue);
314: 
315:         // camel case var name
316:         $tempNameVar = ucfirst($var);
317:         $tempHighestName = "highest$tempNameVar";
318:         $tempLowestName = "lowest$tempNameVar";
319: 
320:         $obj->$tempLowestName = $row->min;
321:         $obj->$tempHighestName = $row->max;
322:     }
323: }
324: 
Budabot 4 Docs API documentation generated by ApiGen