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:  *  - Derroylo (RK2)
 10:  *  - Marinerecon (RK2)
 11:  *  - Tyrence (RK2)
 12:  *
 13:  * @Instance
 14:  *
 15:  * Commands this class contains:
 16:  *  @DefineCommand(
 17:  *      command     = 'loot',
 18:  *      accessLevel = 'all',
 19:  *      description = 'Show the loot list',
 20:  *      help        = 'flatroll.txt'
 21:  *  )
 22:  *  @DefineCommand(
 23:  *      command     = 'loot .+',
 24:  *      accessLevel = 'rl',
 25:  *      description = 'Modify the loot list',
 26:  *      help        = 'flatroll.txt'
 27:  *  )
 28:  *  @DefineCommand(
 29:  *      command     = 'reroll',
 30:  *      accessLevel = 'rl',
 31:  *      description = 'Reroll the residual loot list',
 32:  *      help        = 'flatroll.txt'
 33:  *  )
 34:  *  @DefineCommand(
 35:  *      command     = 'flatroll',
 36:  *      accessLevel = 'rl',
 37:  *      description = 'Roll the loot list',
 38:  *      help        = 'flatroll.txt'
 39:  *  )
 40:  *  @DefineCommand(
 41:  *      command     = 'add',
 42:  *      accessLevel = 'all',
 43:  *      description = 'Add a player to a roll slot',
 44:  *      help        = 'add_rem.txt'
 45:  *  )
 46:  *  @DefineCommand(
 47:  *      command     = 'rem',
 48:  *      accessLevel = 'all',
 49:  *      description = 'Remove a player from a roll slot',
 50:  *      help        = 'add_rem.txt'
 51:  *  )
 52:  */
 53: class RaidController {
 54: 
 55:     /**
 56:      * Name of the module.
 57:      * Set automatically by module loader.
 58:      */
 59:     public $moduleName;
 60:     
 61:     /** @Inject */
 62:     public $db;
 63:     
 64:     /** @Inject */
 65:     public $chatBot;
 66:     
 67:     /** @Inject */
 68:     public $settingManager;
 69:     
 70:     /** @Inject */
 71:     public $commandAlias;
 72:     
 73:     /** @Inject */
 74:     public $text;
 75: 
 76:     /** @Inject */
 77:     public $chatLeaderController;
 78:     
 79:     private $loot = array();
 80:     private $residual = array();
 81:     
 82:     /**
 83:      * @Setup
 84:      */
 85:     public function setup() {
 86:         $this->settingManager->add($this->moduleName, "add_on_loot", "Adding to loot show on", "edit", "options", "2", "tells;privatechat;privatechat and tells", '1;2;3', "mod");
 87:         
 88:         $this->commandAlias->register($this->moduleName, "flatroll", "rollloot");
 89:         $this->commandAlias->register($this->moduleName, "flatroll", "result");
 90:         $this->commandAlias->register($this->moduleName, "flatroll", "win");
 91:         $this->commandAlias->register($this->moduleName, "loot addmulti", "multiloot");
 92:         
 93:         $this->commandAlias->register($this->moduleName, "loot", "list");
 94:     }
 95:     
 96:     /**
 97:      * @HandlesCommand("loot")
 98:      * @Matches("/^loot$/i")
 99:      */
100:     public function lootCommand($message, $channel, $sender, $sendto, $args) {
101:         $msg = $this->getCurrentLootList();
102:         $sendto->reply($msg);
103:     }
104:     
105:     /**
106:      * @HandlesCommand("loot .+")
107:      * @Matches("/^loot clear$/i")
108:      */
109:     public function lootClearCommand($message, $channel, $sender, $sendto, $args) {
110:         if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
111:             $sendto->reply("You must be Raid Leader to use this command.");
112:             return;
113:         }
114: 
115:         $this->loot = array();
116:         $this->residual = array();
117:         $msg = "Loot has been cleared by <highlight>$sender<end>.";
118:         $this->chatBot->sendPrivate($msg);
119: 
120:         if ($channel != 'priv') {
121:             $sendto->reply($msg);
122:         }
123:     }
124:     
125:     /**
126:      * @HandlesCommand("loot .+")
127:      * @Matches("/^loot add ([0-9]+)$/i")
128:      */
129:     public function lootAddByIdCommand($message, $channel, $sender, $sendto, $args) {
130:         if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
131:             $sendto->reply("You must be Raid Leader to use this command.");
132:             return;
133:         }
134: 
135:         $id = $args[1];
136: 
137:         $sql =
138:             "SELECT *, COALESCE(a.name, r.name) AS name
139:             FROM raid_loot r LEFT JOIN aodb a ON (r.name = a.name AND r.ql >= a.lowql AND r.ql <= a.highql)
140:             WHERE id = ?";
141:         $row = $this->db->queryRow($sql, $id);
142: 
143:         if ($row === null) {
144:             $msg = "Could not find item with id <highlight>$id<end> to add.";
145:             $sendto->reply($msg);
146:             return;
147:         }
148: 
149:         $key = $this->getLootItem($row->name);
150:         if ($key !== null) {
151:             $item = $this->loot[$key];
152:             $item->multiloot += $row->multiloot;
153:         } else {
154:             if (!empty($this->loot)) {
155:                 $key = count($this->loot) + 1;
156:             } else {
157:                 $key = 1;
158:             }
159:             
160:             $item = new stdClass;
161:             
162:             $item->name = $row->name;
163:             $item->icon = $row->icon;
164:             $item->added_by = $sender;
165:             $item->display = $this->text->makeItem($row->lowid, $row->highid, $row->ql, $row->name);
166:             $item->multiloot = $row->multiloot;
167:             $item->users = array();
168:             
169:             $this->loot[$key] = $item;
170:         }
171: 
172:         $msg = "$sender added <highlight>{$item->name}<end> (x$item->multiloot). To add use <symbol>add $key.";
173:         $this->chatBot->sendPrivate($msg);
174:     }
175: 
176:     /**
177:      * @HandlesCommand("loot .+")
178:      * @Matches("/^loot add (.+)$/i")
179:      */
180:     public function lootAddCommand($message, $channel, $sender, $sendto, $args) {
181:         if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
182:             $sendto->reply("You must be Raid Leader to use this command.");
183:             return;
184:         }
185: 
186:         $input = $args[1];
187:         $this->addLootItem($input, 1, $sender);
188:     }
189:     
190:     /**
191:      * @HandlesCommand("loot .+")
192:      * @Matches("/^loot addmulti ([0-9]+)x? (.+)$/i")
193:      * @Matches("/^loot multiadd ([0-9]+)x? (.+)$/i")
194:      */
195:     public function multilootCommand($message, $channel, $sender, $sendto, $args) {
196:         if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
197:             $sendto->reply("You must be Raid Leader to use this command.");
198:             return;
199:         }
200: 
201:         $multiloot = $args[1];
202:         $input = $args[2];
203:         $this->addLootItem($input, $multiloot, $sender);
204:     }
205:     
206:     public function addLootItem($input, $multiloot, $sender) {
207:         //Check if the item is a link
208:         if (preg_match("|^<a href=\"itemref://(\\d+)/(\\d+)/(\\d+)\">(.+)</a>(.*)$|i", $input, $arr)) {
209:             $item_ql = $arr[3];
210:             $item_highid = $arr[1];
211:             $item_lowid = $arr[2];
212:             $item_name = $arr[4];
213:         } else if (preg_match("|^(.+)<a href=\"itemref://(\\d+)/(\\d+)/(\\d+)\">(.+)</a>(.*)$|i", $input, $arr)){
214:             $item_ql = $arr[4];
215:             $item_highid = $arr[2];
216:             $item_lowid = $arr[3];
217:             $item_name = $arr[5];
218:         } else {
219:             $item_name = $input;
220:         }
221:         
222:         // check if there is an icon available
223:         $row = $this->db->queryRow("SELECT * FROM aodb WHERE `name` LIKE ?", $item_name);
224:         if ($row !== null) {
225:             $item_name = $row->name;
226: 
227:             //Save the icon
228:             $looticon = $row->icon;
229:             
230:             //Save the aoid and ql if not set yet
231:             if (!isset($item_highid)) {
232:                 $item_lowid = $row->lowid;
233:                 $item_highid = $row->highid;
234:                 $item_ql = $row->highql;
235:             }
236:         }
237: 
238:         // check if the item is already on the list
239:         $key = $this->getLootItem($item_name);
240:         if ($key !== null) {
241:             $item = $this->loot[$key];
242:             $item->multiloot += $multiloot;
243:         } else {
244:             // get a slot for the item
245:             if (!empty($this->loot)) {
246:                 $key = count($this->loot) + 1;
247:             } else {
248:                 $key = 1;
249:             }
250:             
251:             $item = new stdClass;
252:             
253:             $item->name = $item_name;
254:             $item->icon = $looticon;
255:             $item->added_by = $sender;
256:             $item->multiloot = $multiloot;
257:             $item->users = array();
258: 
259:             if (isset($item_highid)) {
260:                 $item->display = $this->text->makeItem($item_lowid, $item_highid, $item_ql, $item_name);
261:             } else {
262:                 $item->display = $item_name;
263:             }
264:             $this->loot[$key] = $item;
265:         }
266: 
267:         $msg = "$sender added <highlight>{$item->name}<end> (x$item->multiloot) to Slot <highlight>#$key<end>.";
268:         $msg .= " To add use <symbol>add $key, or <symbol>rem to remove yourself.";
269:         $this->chatBot->sendPrivate($msg);
270:     }
271:     
272:     /**
273:      * @HandlesCommand("loot .+")
274:      * @Matches("/^loot rem ([0-9]+)$/i")
275:      */
276:     public function lootRemCommand($message, $channel, $sender, $sendto, $args) {
277:         if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
278:             $sendto->reply("You must be Raid Leader to use this command.");
279:             return;
280:         }
281: 
282:         $key = $args[1];
283:         // validate item existance on loot list
284:         if ($key > 0 && $key <= count($this->loot)) {
285:             // if removing this item empties the list, clear the loot list properly
286:             if (count($this->loot) <= 1) {
287:                 $this->loot = array();
288:                 $this->chatBot->sendPrivate("Item in slot <highlight>#".$key."<end> was the last item in the list. The list has been cleared.");
289:             } else {
290:                 // remove the item by shifting lower items up one slot and remove last slot
291:                 $loop = $key;
292:                 while($loop < count($this->loot)){
293:                     $this->loot[$loop] = $this->loot[$loop+1];
294:                     $loop++;
295:                 }
296:                 unset($this->loot[count($this->loot)]);
297:                 $this->chatBot->sendPrivate("Removing item in slot <highlight>#".$key."<end>");
298:             }
299:         } else {
300:             $this->chatBot->sendPrivate("There is no item at slot <highlight>#".$key."<end>");
301:         }
302:     }
303:     
304:     /**
305:      * @HandlesCommand("reroll")
306:      * @Matches("/^reroll$/i")
307:      */
308:     public function rerollCommand($message, $channel, $sender, $sendto, $args) {
309:         if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
310:             $sendto->reply("You must be Raid Leader to use this command.");
311:             return;
312:         }
313: 
314:         //Check if a residual list exits
315:         if (empty($this->residual)) {
316:             $msg = "There are no remaining items to re-add.";
317:             $sendto->reply($msg);
318:             return;
319:         }
320: 
321:         // Readd remaining loot
322:         forEach ($this->residual as $key => $item) {
323:             $this->loot[$key] = $item;
324:             $this->loot[$key]->added_by = $sender;
325:         }
326: 
327:         //Reset residual list
328:         $this->residual = array();
329:         //Show winner list
330:         $msg = "All remaining items have been re-added by <highlight>$sender<end>. Check <symbol>loot.";
331:         $this->chatBot->sendPrivate($msg);
332:         if ($channel != 'priv') {
333:             $sendto->reply($msg);
334:         }
335: 
336:         $msg = $this->getCurrentLootList();
337:         $sendto->reply($msg);
338:     }
339:     
340:     /**
341:      * @HandlesCommand("flatroll")
342:      * @Matches("/^flatroll$/i")
343:      */
344:     public function flatrollCommand($message, $channel, $sender, $sendto, $args) {
345:         if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
346:             $sendto->reply("You must be Raid Leader to use this command.");
347:             return;
348:         }
349: 
350:         global $loot_winners;
351:         //Check if a loot list exits
352:         if (empty($this->loot)) {
353:             $msg = "There is nothing to roll atm.";
354:             $sendto->reply($msg);
355:             return;
356:         }
357: 
358:         srand(((int)((double)microtime() * 1000003))); // get a good seed
359: 
360:         $list = '';
361:         //Roll the loot
362:         $resnum = 1;
363:         forEach ($this->loot as $key => $item) {
364:             $list .= "Item: <orange>{$item->name}<end>\n";
365:             $list .= "Winner(s): ";
366:             $users = count($item->users);
367:             if ($users == 0) {
368:                 $list .= "<highlight>None added.<end>\n\n";
369:                 $this->residual[$resnum] = $item;
370:                 $resnum++;
371:             } else {
372:                 if ($item->multiloot > 1) {
373:                     if ($item->multiloot > count($item->users)) {
374:                         $arrolnum = count($item->users);
375:                     } else {
376:                         $arrolnum = $item->multiloot;
377:                     }
378: 
379:                     for ($i = 0; $i < $arrolnum; $i++) {
380:                         $winner = array_rand($item->users, 1);
381:                         unset($item->users[$winner]);
382:                         $list .= "<red>$winner<end> ";
383:                     }
384: 
385:                     if ($arrolnum < $item->multiloot) {
386:                         $newmultiloot = $item->multiloot - $arrolnum;
387:                         $this->residual[$resnum] = $item;
388:                         $this->residual[$resnum]->multiloot = $newmultiloot;
389:                         $resnum++;
390:                     }
391:                 } else {
392:                     $winner = array_rand($item->users, 1);
393:                     $list .= "<red>$winner<end>";
394:                 }
395:                 $list .= "\n\n";
396:             }
397:         }
398: 
399:         //Reset loot
400:         $this->loot = array();
401: 
402:         //Show winner list
403:         $msg = $this->text->makeBlob("Winner List", $list);
404:         if (!empty($this->residual)) {
405:             $msg .= " (There are item(s) left to be rolled. To re-add, type <symbol>reroll)";
406:         }
407: 
408:         $this->chatBot->sendPrivate($msg);
409:         if ($channel != 'priv') {
410:             $sendto->reply($msg);
411:         }
412:     }
413:     
414:     /**
415:      * @HandlesCommand("add")
416:      * @Matches("/^add ([0-9]+)$/i")
417:      */
418:     public function addCommand($message, $channel, $sender, $sendto, $args) {
419:         $slot = $args[1];
420:         $found = false;
421:         if (count($this->loot) > 0) {
422:             //Check if the slot exists
423:             if (!isset($this->loot[$slot])) {
424:                 $msg = "The slot you are trying to add in does not exist.";
425:                 $this->chatBot->sendTell($msg, $sender);
426:                 return;
427:             }
428: 
429:             //Remove the player from other slots if set
430:             $found = false;
431:             forEach ($this->loot as $key => $item) {
432:                 if ($this->loot[$key]->users[$sender] == true) {
433:                     unset($this->loot[$key]->users[$sender]);
434:                     $found = true;
435:                 }
436:             }
437: 
438:             //Add the player to the choosen slot
439:             $this->loot[$slot]->users[$sender] = true;
440: 
441:             if ($found == false) {
442:                 $msg = "$sender has added to <highlight>\"{$this->loot[$slot]->name}\"<end>.";
443:             } else {
444:                 $msg = "$sender has moved to <highlight>\"{$this->loot[$slot]->name}\"<end>.";
445:             }
446: 
447:             $this->chatBot->sendPrivate($msg);
448:         } else {
449:             $this->chatBot->sendTell("No loot list available.", $sender);
450:         }
451:     }
452:     
453:     /**
454:      * @HandlesCommand("rem")
455:      * @Matches("/^rem$/i")
456:      */
457:     public function remCommand($message, $channel, $sender, $sendto, $args) {
458:         if (count($this->loot) > 0) {
459:             forEach ($this->loot as $key => $item) {
460:                 if ($this->loot[$key]->users[$sender] == true) {
461:                     unset($this->loot[$key]->users[$sender]);
462:                 }
463:             }
464: 
465:             $msg = "$sender has been removed from all rolls.";
466:             $this->chatBot->sendPrivate($msg);
467:         } else {
468:             $this->chatBot->sendTell("There is nothing to remove you from.", $sender);
469:         }
470:     }
471:     
472:     public function getCurrentLootList() {
473:         if (!empty($this->loot)) {
474:             $list = "Use <symbol>flatroll to roll.\n\n";
475:             $players = 0;
476:             $items = count($this->loot);
477:             forEach ($this->loot as $key => $item) {
478:                 $add = $this->text->makeChatcmd("Add", "/tell <myname> add $key");
479:                 $rem = $this->text->makeChatcmd("Remove", "/tell <myname> rem");
480:                 $added_players = count($item->users);
481:                 $players += $added_players;
482: 
483:                 if ($item->icon != "") {
484:                     $list .= $this->text->makeImage($item->icon) . "\n";
485:                 }
486: 
487:                 if ($item->multiloot > 1) {
488:                     $ml = " <highlight>(x".$item->multiloot.")<end>";
489:                 } else {
490:                     $ml = "";
491:                 }
492: 
493:                 $list .= "\n{$item->display}".$ml."";
494:                 $list .= "\n<header2>Slot #$key<end> $add / $rem";
495:                 $list .= "\nPlayers added (<highlight>$added_players<end>):";
496:                 if (count($item->users) > 0) {
497:                     forEach ($item->users as $key => $value) {
498:                         $list .= " [<yellow>$key<end>]";
499:                     }
500:                 }
501: 
502:                 $list .= "\n\n\n";
503:             }
504:             $msg = $this->text->makeBlob("Loot List (Items: $items, Players: $players)", $list);
505:         } else {
506:             $msg = "No loot list exists yet.";
507:         }
508: 
509:         return $msg;
510:     }
511: 
512:     public function addRaidToLootList($raid, $category) {
513:         // clear current loot list
514:         $this->loot = array();
515:         $count = 1;
516: 
517:         $sql = "SELECT * FROM raid_loot r LEFT JOIN aodb a ON (r.name = a.name AND r.ql >= a.lowql AND r.ql <= a.highql) WHERE raid = ? AND category = ?";
518:         $data = $this->db->query($sql, $raid, $category);
519: 
520:         if (count($data) == 0) {
521:             return false;
522:         }
523: 
524:         forEach ($data as $row) {
525:             $item = $this->text->makeItem($row->lowid, $row->highid, $row->ql, $row->name);
526:             if (empty($row->comment)) {
527:                 $row->display = $item;
528:             } else {
529:                 $row->display = $item . " ($row->comment)";
530:             }
531:             $row->users = array();
532:             $this->loot[$count] = $row;
533:             $count++;
534:         }
535: 
536:         return true;
537:     }
538:     
539:     public function getLootItem($name) {
540:         forEach ($this->loot as $key => $item) {
541:             if ($item->name == $name){
542:                 return $key;
543:             }
544:         }
545:         return null;
546:     }
547: }
548: 
Budabot 4 Docs API documentation generated by ApiGen