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); }
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; } }
public static function craft_($argc, $argv, $user, $fight, $params) { $argS = implode(" ", array_slice($argv, 1)); if (!$fight) { $itemCount = FightItemModel::findWhere(["user_id", $user->user_id]); if ($itemCount->size() >= 10) { return new FightDangerMessage("Sorry, you may not have more than 10 items. Type `item drop XXX` to drop an old item"); } return FightCraftController::startCrafting($user, $params["channel_id"], $argS); } else { list($otherFight, $opponent) = self::getOpponent($fight); return FightCraftController::craft($fight, $user, $otherFight, $opponent, $argS); } }