Exemplo n.º 1
0
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();
        $comeEvent->addObject($playerHelper->getPlayerId(), $player);
        $comeEvent->setLocHelper($newLocHelper);
        \Likedimion\Game::init()->getDispatcher()->dispatch('come_player', $comeEvent);
    } else {
        $playerHelper->addJournal("Некуда идти.");
    }
}
Exemplo n.º 2
0
 $locHelper->setCollection($ld->locations);
 if ($_GET["to"]) {
     $toPlayer = $playerHelper->getCollection()->findOne(["_id" => new MongoId($_GET["to"])]);
     if ($toPlayer) {
         //$msg = $player["title"] . " говорит <b>" . $toPlayer["title"] . "</b> ";
         $toPlayerHelper = new \Likedimion\Helper\PlayerHelper($toPlayer);
         $toPlayerHelper->setCollection($ld->players);
         if ($_POST["private"]) {
             $msgTo = "<b>[П!]</b><span class='text-underline'>" . $player["title"] . "</span> шепчет <b>вам</b>: " . $_POST["speak_msg"];
             $msgFrom = "Вы шепчете <span style='text-decoration: underline;'>" . $toPlayer["title"] . "</span> " . $_POST["speak_msg"];
             $msgAll = "<span class='text-underline'>" . $player["title"] . "</span> что-то шепчет <span class='text-underline'>" . $toPlayer["title"] . "</span>";
             $playerHelper->addJournal($msgFrom);
             $toPlayerHelper->addJournal($msgTo);
             $toPlayerHelper->update();
             $locHelper->addJournal($msgAll, $ld->players, $player["_id"], $toPlayer["_id"]);
             $locHelper->update();
         } else {
             $msgTo = "<span class='text-underline'>" . $player["title"] . "</span> говорит <b>вам</b>: " . $_POST["speak_msg"];
             $msgFrom = "Вы говорите <span style='text-decoration: underline;'>" . $toPlayer["title"] . "</span> " . $_POST["speak_msg"];
             $msgAll = $player["title"] . " говорит " . $toPlayer["title"] . ": " . $_POST["speak_msg"];
             $playerHelper->addJournal($msgFrom)->update();
             $toPlayerHelper->addJournal($msgTo)->update();
             $locHelper->addJournal($msgAll, $ld->players, $player["_id"], $toPlayer["_id"])->update();
         }
     } else {
         $playerHelper->addJournal('Некому говорить.')->update();
     }
 } else {
     $msgAll = "<span class='text-underline'>" . $player["title"] . "</span> говорит: " . $_POST["speak_msg"];
     $msgPlayer = "Вы говорите: " . $_POST["speak_msg"];
     $locHelper->addJournal($msgAll, $ld->players, $player["_id"])->update();