コード例 #1
0
 /**
  * Техническая функция осмотра комнаты
  * @param \Rottenwood\UtopiaMudBundle\Entity\Room         $room
  * @param                                         integer $charId
  * @internal param \Rottenwood\UtopiaMudBundle\Entity\Player $char
  * @return mixed
  */
 public function techLook($room, $charId)
 {
     $roomId = $room->getId();
     $result = array();
     // осмотр комнаты
     $result["roomname"] = $room->getName();
     $result["roomdesc"] = $room->getRoomdesc();
     if ($exits = $this->techLookExits($room)) {
         $result["exits"] = $exits;
     } else {
         $result["exits"] = "no";
     }
     // персонажи
     $playersOnline = $this->container->get('datachannel')->getOnlineIds($charId);
     $playersInRoom = $this->roomRepository->findPlayersInRoom($roomId, $playersOnline);
     if ($playersInRoom) {
         foreach ($playersInRoom as $player) {
             $playerSex = $player->getSex();
             if ($playerSex == 2) {
                 $getNameFunction = "getNamef";
             } else {
                 $getNameFunction = "getName";
             }
             $result["players"][$player->getUsername()]["race"] = $player->getRace()->{$getNameFunction}();
         }
     }
     // мобы
     $mobsInRoom = $this->livemobRepository->findMobsInRoom($room);
     if ($mobsInRoom) {
         foreach ($mobsInRoom as $mob) {
             /** @var Livemob $mob */
             $mobName1 = $mob->getMob()->getName1();
             $mobName1 = mb_strtolower($mobName1, 'UTF-8');
             $mobShort = $mob->getMob()->getShortdesc();
             $result["mobs"][] = array("name" => $mobName1, "short" => $mobShort);
         }
     }
     // предметы
     $itemsInRoom = $this->roomitemRepository->findItemsInRoom($room);
     if ($itemsInRoom) {
         foreach ($itemsInRoom as $itemInRoom) {
             /** @var Roomitem $itemInRoom */
             $itemName1 = $itemInRoom->getItem()->getName1();
             $itemName1 = mb_strtolower($itemName1, 'UTF-8');
             $itemShort = $itemInRoom->getItem()->getShortdesc();
             $result["items"][] = array("item" => $itemName1, "short" => $itemShort);
         }
     }
     return $result;
 }