Exemplo n.º 1
0
/**
 * Created by PhpStorm.
 * User: babenoff
 * Date: 24.12.2015
 * Time: 21:26
 */
$player = $playerHelper->getPlayer();
if ($_GET["go"] and $_GET["go"] != $player["loc"]) {
    $oldLoc = $ld->locations->findOne(["lid" => $player["loc"]]);
    $oldLocHelper = new \Likedimion\Helper\LocationHelper($oldLoc);
    $oldLocHelper->setCollection($ld->locations);
    $newLoc = $ld->locations->findOne(["lid" => $_GET["go"]]);
    if ($newLoc) {
        $newLocHelper = new \Likedimion\Helper\LocationHelper($newLoc);
        $oldLocHelper->removePlayer($player["_id"]);
        $newLocHelper->addPlayer($player["_id"]);
        $newLocHelper->setCollection($ld->locations);
        $playerHelper->move($_GET["go"]);
        $playerHelper->update();
        if ($oldLoc["terr"] == \Likedimion\Helper\LocationHelper::TERRITORY_GUARD and $newLoc["terr"] == \Likedimion\Helper\LocationHelper::TERRITORY_UNGUARD) {
            $playerHelper->addJournal("Вы покунули охраняемую территорию.");
        } elseif ($oldLoc["terr"] == \Likedimion\Helper\LocationHelper::TERRITORY_UNGUARD and $newLoc["terr"] == \Likedimion\Helper\LocationHelper::TERRITORY_GUARD) {
            $playerHelper->addJournal("Вы на охраняемой территории.");
        }
        $outmsg = $player["title"] . ($player["sex"] == "m" ? " ушел " : " ушла ") . $oldLocHelper->getDoorName($_GET["go"]);
        $inmsg = ($player["sex"] == "m" ? " пришел " : " пришла ") . $player["title"];
        $oldLocHelper->addJournal($outmsg, $ld->players, $player["_id"]);
        $newLocHelper->addJournal($inmsg, $ld->players, $player["_id"]);
        $oldLocHelper->update();
        $newLocHelper->update();
        $comeEvent = new \Likedimion\Events\MoveEvent();
Exemplo n.º 2
0
    header("Location: /?");
}
/**
 * Created by PhpStorm.
 * User: babenoff
 * Date: 06.12.2015
 * Time: 23:56
 */
if (isset($_GET["pid"])) {
    $player = $ld->players->findOne(["_id" => new MongoId($_GET["pid"])]);
    if ($player and $player["aid"] = $_SESSION["aid"]) {
        $_SESSION["pid"] = $player["_id"];
        $playerHelper = new \Likedimion\Helper\PlayerHelper($player);
        $playerHelper->addTimer("online", $config["online_time"]);
        $playerHelper->setCollection($ld->players);
        $playerHelper->update();
        $loc = $ld->locations->findOne(["lid" => $player["loc"]]);
        $lHelper = new \Likedimion\Helper\LocationHelper($loc);
        $lHelper->addPlayer($player["_id"]);
        $msg = ($player["sex"] == "m" ? " появился " : " появилась ") . $player["title"];
        $lHelper->addJournal($msg, $ld->players, $player["_id"]);
        try {
            $ld->locations->update(["_id" => new MongoId($lHelper->getLoc()["_id"])], $lHelper->getLoc());
            header("Location: /?");
        } catch (MongoException $e) {
            die($e->getMessage());
        }
    } else {
        require ROOT . "/404.php";
    }
}