/** * Reference: * ## Impassable wood * @1 Hero number 1 * [] Tavern * $- Gold mine (neutral) * $1 Gold mine (belonging to hero 1) * * @param string $chars * @return Tile */ private static function readTile(Position $pos, $chars) { static $TILE_CLASSES = array(' ' => 'Vindinium\\Board\\EmptyTile', '##' => 'Vindinium\\Board\\Wood', '[]' => 'Vindinium\\Board\\Tavern', '$-' => 'Vindinium\\Board\\GoldMine'); if ($Tile = Arrays::get($TILE_CLASSES, $chars)) { return new $Tile($pos); } $heroId = (int) substr($chars, 1); if ('@' === $chars[0]) { return new Avatar($pos, $heroId); } if ('$' === $chars[0]) { return new GoldMine($pos, $heroId); } throw new \InvalidArgumentException("Invalid tile: '{$chars}'"); }
/** * @internal */ protected function init(array $data) { $this->userId = Arrays::get($data, 'userId'); $this->elo = (int) Arrays::get($data, 'elo'); }