/** * Generates picture. * * @return Bengine_Game_Planet_Creator */ protected function setPicture() { $planetTypes = new Map(); $meta = Application::getMeta(); foreach ($meta["config"]["planet"]["type"] as $name => $planetType) { if ($this->position >= $planetType["from"] && $this->position <= $planetType["to"]) { $planetTypes->push(array("name" => $name, "number" => $planetType["number"])); } } $randomPlanet = $planetTypes->getRandomElement(); $this->picture = sprintf("%s%02d", $randomPlanet["name"], mt_rand(1, $randomPlanet["number"])); return $this; }
/** * Returns a random map index. * * @return mixed Key */ public function getRandomIndex() { $keys = new Map(array_keys($this->map)); return $keys->getRandomElement(); }