} else { $personagem = new Personagem(); } } $vantagens = array(); foreach (Vantagem::listar() as $vantagem) { $item = new stdClass(); $item->slug = $vantagem->getSlug(); $item->nome = $vantagem->getNome(); $item->obs = $vantagem->getObservacao(); $item->nivel = $vantagem->getNivel(); $item->ponto = $vantagem->getPonto(); $vantagens[] = $item; } $pericias = array(); foreach (Pericia::listar() as $pericia) { $item = new stdClass(); $item->slug = $pericia->getSlug(); $item->nome = $pericia->getNome(); $item->base = $pericia->getBase(); $item->dif = $pericia->getDificuldade(); //$item->obs = $pericia->getObservacao(); //$item->nivel = $pericia->getNivel(); $pericias[] = $item; } require 'header.php'; ?> <script src="<?php echo WEB_PATH; ?> /js/jquery.ui.widget.js"></script>
function ficha_exibir_pericia($slug) { $pericias = array(); $categoria = Pericia::listarCategoria(); foreach (Pericia::listar() as $pericia) { if (!is_array($pericias[$pericia->getCategoria()])) { $pericias[$pericia->getCategoria()] = array(); } $pericias[$pericia->getCategoria()][$pericia->getSlug()] = $pericia; } echo "<select name=\"pericia[]\">\n"; echo "<option value=\"\">--Selecione--</option>"; foreach ($pericias as $id_categoria => $subpericias) { echo "<optgroup label=\"" . $categoria[$id_categoria] . "\">\n"; foreach ($subpericias as $pericia) { $texto = $pericia->getNome(); $texto .= $pericia->getBase() == FISICA ? " F/" : " M/"; switch ($pericia->getDificuldade()) { case FACIL: $texto .= 'F'; break; case MEDIA: $texto .= 'M'; break; case DIFICIL: $texto .= 'D'; break; case MUITO_DIFICIL: $texto .= 'MD'; break; } echo "<option value=\"" . $pericia->getSlug() . "\""; if ($slug == $pericia->getSlug()) { echo ' selected="selected"'; } echo ">{$texto}</option>\n"; } echo "</optgroup>\n"; } echo "</select>\n"; }