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:  * Author:
  9:  *  - Tyrence (RK2)
 10:  *  - Mdkdoc420 (RK2)
 11:  *
 12:  * @Instance
 13:  *
 14:  * Commands this controller contains:
 15:  *  @DefineCommand(
 16:  *      command     = 'fight',
 17:  *      accessLevel = 'all',
 18:  *      description = 'Let two people fight against each other',
 19:  *      help        = 'fun_module.txt'
 20:  *  )
 21:  */
 22: class FightController {
 23: 
 24:     /**
 25:      * Name of the module.
 26:      * Set automatically by module loader.
 27:      */
 28:     public $moduleName;
 29:     
 30:     /** @Inject */
 31:     public $text;
 32:     
 33:     /** @Inject */
 34:     public $util;
 35:     
 36:     /**
 37:      * @HandlesCommand("fight")
 38:      * @Matches("/^fight (.+) vs (.+)$/i")
 39:      * @Matches("/^fight (.+) (.+)$/i")
 40:      */
 41:     public function fightCommand($message, $channel, $sender, $sendto, $args) {
 42:         $player1 = $args[1];
 43:         $player2 = $args[2];
 44: 
 45:         // Checks if user is trying to get Chuck Norris to fight another Chuck Norris
 46:         if ($this->isChuckNorris($player1) && $this->isChuckNorris($player2)) {
 47:             $msg = "Theres only enough room in this world for one Chuck Norris!";
 48:             $sendto->reply($msg);
 49:             return;
 50:         }
 51: 
 52:         // This checks if the user is trying to get two of the same people fighting each other
 53:         if (strcasecmp($player1, $player2) == 0) {
 54:             $twin = array(
 55:                 "Dejavu?",
 56:                 "$player1 can't fight $player2, it may break the voids of space and time!",
 57:                 "As much as I'd love to see $player1 punching himself/herself in the face, it just isn't theoretical...");
 58: 
 59:             $sendto->reply($this->util->randomArrayValue($twin));
 60:             return;
 61:         }
 62: 
 63:         $fighter1 = $this->getFighter($player1);
 64:         $fighter2 = $this->getFighter($player2);
 65: 
 66:         $list = "Fight <highlight>$player1<end> VS <highlight>$player2<end> \n\n";
 67:         while ($fighter1->hp > 0 && $fighter2->hp > 0) {
 68:             $list .= $this->doAttack($fighter1, $fighter2);
 69:             $list .= $this->doAttack($fighter2, $fighter1);
 70:             $list .= "\n";
 71:         }
 72: 
 73:         if ($fighter1->hp > $fighter2->hp) {
 74:             $list .= "\nAnd the winner is ..... <highlight>$player1!<end>";
 75:             $msg = $this->text->makeBlob("$player1 vs $player2....$player1 wins!", $list);
 76:         } else if ($fighter2->hp > $fighter1->hp) {
 77:             $list .= "\nAnd the winner is ..... <highlight>$player2!<end>";
 78:             $msg = $this->text->makeBlob("$player1 vs $player2....$player2 wins!", $list);
 79:         } else {
 80:             $list .= "\nIt's a tie!!";
 81:             $msg = $this->text->makeBlob("$player1 vs $player2....It's a tie!", $list);
 82:         }
 83: 
 84:         $sendto->reply($msg);
 85:     }
 86: 
 87:     public function getFighter($name) {
 88:         $fighter = new stdClass;
 89:         $fighter->name = $name;
 90:         if ($this->util->startsWith(strtolower($name), "tyrence")) {
 91:             $fighter->weapon = "bot";
 92:             $fighter->minDamage = 6001;
 93:             $fighter->maxDamage = 7000;
 94:             $fighter->hp = 20000;
 95:         } else if ($this->isChuckNorris($name)) {
 96:             $fighter->weapon = "round house kick";
 97:             $fighter->minDamage = 4001;
 98:             $fighter->maxDamage = 6000;
 99:             $fighter->hp = 20000;
100:         } else {
101:             $fighter->weapon = "nerfstick";
102:             $fighter->minDamage = 1000;
103:             $fighter->maxDamage = 4000;
104:             $fighter->hp = 20000;
105:         }
106:         return $fighter;
107:     }
108: 
109:     public function doAttack($attacker, $defender) {
110:         $dmg = rand($attacker->minDamage, $attacker->maxDamage);
111:         if ($this->isCriticalHit($attacker, $dmg)) {
112:             $crit = " <red>Critical Hit!<end>";
113:         } else {
114:             $crit = "";
115:         }
116: 
117:         $defender->hp -= $dmg;
118:         return "<highlight>{$attacker->name}<end> hit <highlight>{$defender->name}<end> for $dmg of {$attacker->weapon} dmg.$crit\n";
119:     }
120: 
121:     public function isCriticalHit($fighter, $dmg) {
122:         return ($dmg / $fighter->maxDamage) > 0.9;
123:     }
124: 
125:     public function isChuckNorris($name) {
126:         $name = strtolower($name);
127:         return $name == "chuck" || $name == "chuck norris" || $name == "chucknorris";
128:     }
129: }
130: 
Budabot 4 Docs API documentation generated by ApiGen