public function _createMobInsideArea() { $k = Types::getKindFromString($this->kind); $pos = $this->_getRandomPositionInsideArea(); $mob = new Mob('1' . $this->id . '' . $k . '' . count($this->entities), $k, $pos['x'], $pos['y']); // @todo bind $mob->onMove(array($this->world, 'onMobMoveCallback')); return $mob; }
public function getDroppedItem($mob) { $kind = Types::getKindAsString($mob->kind); $drops = Properties::$properties[$kind]['drops']; $v = rand(0, 100); $p = 0; foreach ($drops as $itemName => $percentage) { $p += $percentage; if ($v <= $p) { $item = $this->addItem($this->createItem(Types::getKindFromString($itemName), $mob->x, $mob->y)); return $item; } } }
public function equipItem($item) { if ($item) { if (Types::isArmor($item->kind)) { $this->equipArmor($item->kind); $this->updateHitPoints(); $obj = new Messages\HitPoints($this->maxHitPoints); $data = $obj->serialize(); $this->send(json_encode($data)); } else { if (Types::isWeapon($item->kind)) { $this->equipWeapon($item->kind); } } } }