Exemplo n.º 1
0
 public static function computerMove($user, $fight, $computer, $otherFight)
 {
     $computerMoves = FightItemModel::findWhere(["user_id" => $computer->user_id, "type" => "move", "deleted" => 0]);
     if ($computerMoves->size() === 0) {
         $move = FightItemModel::build(["user_id" => $computer->user_id, "name" => "splash", "stats" => ["physical" => 0], "type" => "move"]);
         $move->save();
         return FightItemController::useMove($move, $computer, $otherFight, $user, $fight);
     }
     return FightItemController::useMove($computerMoves->at(mt_rand(0, $computerMoves->size() - 1)), $computer, $otherFight, $user, $fight);
 }
Exemplo n.º 2
0
 public static function useItem($user, $fight, $action)
 {
     if (strtolower($action) === "taunt") {
         FightActionController::registerAction($user, $fight->fight_id, $user->tag() . " uses Taunt!");
         return [new FightMessage("good", [$user->tag() . " uses Taunt!", "What an insult!"]), new FightReaction($fight->channel_id)];
     }
     $move = FightItemController::getMove($user, $action);
     if (!$move) {
         $result = [$action . " not available! Options:"];
         $moves = FightItemModel::findWhere(["user_id" => $user->user_id, "type" => "move", "deleted" => 0]);
         foreach ($moves->objects as $move) {
             $result[] = "`" . $move->name . "`";
         }
         return new FightMessage("danger", $result);
     } else {
         $action = FightItemController::useMove($move, $user, $fight);
         if (!is_array($action)) {
             $action = [$action];
         }
         $action[] = new FightReaction($fight->channel_id);
         return $action;
     }
 }
Exemplo n.º 3
0
 public static function equip_($argc, $argv, $user, $fight, $params)
 {
     $itemName = implode(" ", array_slice($argv, 2));
     if ($argv[1] !== "weapon" && $argv[1] !== "armor") {
         return new FightInfoMessage("Usage: `equip (weapon|armor) " . $argv[1] . "`");
     }
     $item = FightItemController::getItem($user, $itemName);
     if ($item) {
         if ($fight) {
             self::requireTurn($user, $fight);
         }
         $user->update([$argv[1] => $item->item_id]);
         if ($fight) {
             FightActionController::registerAction($user, $fight->fight_id, $user->tag() . "equipped `" . $itemName . "`!");
             return new FightMessage("good", "You equipped `" . $itemName . "`! (yes, it used your turn)");
         } else {
             return new FightMessage("good", "You equipped `" . $itemName . "`!");
         }
     } else {
         return new FightMessage("warning", "Sorry, you don't have an item named `" . $itemName . "`");
     }
 }