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: use Exception;
  7: 
  8: /**
  9:  * Authors: 
 10:  *  - Funkman (RK2)
 11:  *  - Tyrence (RK2)
 12:  *
 13:  * @Instance
 14:  *
 15:  * Commands this class contains:
 16:  *  @DefineCommand(
 17:  *      command     = 'citywave',
 18:  *      accessLevel = 'guild',
 19:  *      description = 'Shows/Starts/Stops the current city wave',
 20:  *      help        = 'wavecounter.txt'
 21:  *  )
 22:  */
 23: class CityWaveController {
 24: 
 25:     /**
 26:      * Name of the module.
 27:      * Set automatically by module loader.
 28:      */
 29:     public $moduleName;
 30:     
 31:     /** @Inject */
 32:     public $chatBot;
 33:     
 34:     /** @Inject */
 35:     public $commandAlias;
 36:     
 37:     /** @Inject */
 38:     public $timerController;
 39:     
 40:     /** @Inject */
 41:     public $settingManager;
 42:     
 43:     /** @Inject */
 44:     public $setting;
 45:     
 46:     /** @Inject */
 47:     public $util;
 48:     
 49:     const TIMER_NAME = "City Raid";
 50:     
 51:     /**
 52:      * @Setup
 53:      */
 54:     public function setup() {
 55:         $this->commandAlias->register($this->moduleName, "citywave start", "startwave");
 56:         $this->commandAlias->register($this->moduleName, "citywave stop", "stopwave");
 57:         
 58:         $this->settingManager->add($this->moduleName, 'city_wave_times', 'Times to display timer alerts', 'edit', 'text', '105s 150s 90s 120s 120s 120s 120s 120s 120s', '105s 150s 90s 120s 120s 120s 120s 120s 120s', '', 'mod', 'city_wave_times.txt');
 59:         $this->settingManager->registerChangeListener('city_wave_times', array($this, 'changeWaveTimes'));
 60:     }
 61:     
 62:     public function changeWaveTimes($settingName, $oldValue, $newValue, $data)  {
 63:         $alertTimes = explode(' ', $newValue);
 64:         if (count($alertTimes) != 9) {
 65:             throw new Exception("Error saving setting: must have 9 spawn times. For more info type !help city_wave_times.");
 66:         }
 67:         forEach ($alertTimes as $alertTime) {
 68:             $time = $this->util->parseTime($alertTime);
 69:             if ($time == 0) {
 70:                 // invalid time
 71:                 throw new Exception("Error saving setting: invalid alert time('$alertTime'). For more info type !help city_wave_times.");
 72:             }
 73:         }
 74:     }
 75:     
 76:     /**
 77:      * @HandlesCommand("citywave")
 78:      * @Matches("/^citywave start$/i")
 79:      */
 80:     public function citywaveStartCommand($message, $channel, $sender, $sendto, $args) {
 81:         $wave = $this->getWave();
 82:         if ($wave !== null) {
 83:             $sendto->reply("A raid is already in progress.");
 84:         } else {
 85:             $this->startWaveCounter($sender);
 86:         }
 87:     }
 88: 
 89:     /**
 90:      * @HandlesCommand("citywave")
 91:      * @Matches("/^citywave stop$/i")
 92:      */
 93:     public function citywaveStopCommand($message, $channel, $sender, $sendto, $args) {
 94:         $wave = $this->getWave();
 95:         if ($wave === null) {
 96:             $msg = "There is no raid in progress at this time.";
 97:         } else {
 98:             $this->timerController->remove(self::TIMER_NAME);
 99:             $msg = "Wave counter stopped by $sender.";
100:         }
101:         $sendto->reply($msg);
102:     }
103:     
104:     /**
105:      * @HandlesCommand("citywave")
106:      * @Matches("/^citywave$/i")
107:      */
108:     public function citywaveCommand($message, $channel, $sender, $sendto, $args) {
109:         $wave = $this->getWave();
110:         if ($wave === null) {
111:             $msg = "There is no raid in progress at this time.";
112:         } else if ($wave == 9) {
113:             $msg = "Waiting for General.";
114:         } else {
115:             $msg = "Waiting for wave $wave.";
116:         }
117:         $sendto->reply($msg);
118:     }
119:     
120:     /**
121:      * @Event("guild")
122:      * @Description("Starts a wave counter when cloak is lowered")
123:      */
124:     public function autoStartWaveCounterEvent($eventObj) {
125:         if (preg_match("/^Your city in (.+) has been targeted by hostile forces.$/i", $eventObj->message)) {
126:             $this->startWaveCounter();
127:         }
128:     }
129:     
130:     public function getWave() {
131:         $timer = $this->timerController->get(self::TIMER_NAME);
132:         if ($timer === null) {
133:             return null;
134:         } else {
135:             return $timer->alerts[0]->wave;
136:         }
137:     }
138:     
139:     public function startWaveCounter($name = null) {
140:         if ($name === null) {
141:             $this->chatBot->sendGuild("Wave counter started.");
142:         } else {
143:             $this->chatBot->sendGuild("Wave counter started by $name.");
144:         }
145:         $lastTime = time();
146:         $wave = 1;
147:         $alerts = array();
148:         $alertTimes = explode(' ', $this->setting->city_wave_times);
149:         forEach ($alertTimes as $alertTime) {
150:             $time = $this->util->parseTime($alertTime);
151:             $lastTime += $time;
152: 
153:             $alert = new stdClass;
154:             if ($wave == 9) {
155:                 $alert->message = "General Incoming.";
156:             } else {
157:                 $alert->message = "Wave $wave incoming.";
158:             }
159:             $alert->time = $lastTime;
160:             $alert->wave = $wave;
161:             $alerts []= $alert;
162: 
163:             $wave++;
164:         }
165:         $this->timerController->remove(self::TIMER_NAME);
166:         $this->timerController->add(self::TIMER_NAME, $this->chatBot->vars['name'], "guild", $alerts, 'timercontroller.timerCallback');
167:     }
168: }
169: 
Budabot 4 Docs API documentation generated by ApiGen