Ejemplo n.º 1
0
/**
 * Gibt eine Fehlerseite aus (anzuwenden bei schwerwiegenden
 * Fehlern wie Templatefehler o.ä.)
 * @param $errorMessage Anzuzeigende Fehlermeldung (für Admins)
 * @return void
 */
function displayErrorPage($errorMessage, $longErrorMessage = false)
{
    global $template;
    if ($longErrorMessage == false) {
        $longErrorMessage = $errorMessage;
    }
    // Loggen
    World_Base::$LOG->write((string) $longErrorMessage . ' (' . __FILE__ . ')', Error::FATAL);
    // Meldung ausgeben
    $templateErrorMessage = '[' . date('Y-m-d H:i:s') . '] ' . $errorMessage . ' (der Fehler wurde in die <a href="' . buildSiteUrl('logViewer') . '"' . ' title="Log Viewer öffnen">Log-Datei</a> geschrieben).';
    // Versuch Error-Template zu laden
    try {
        $template->templateFile = 'error.html';
        $template->templateMacro = 'error';
        $template->contentTitle = 'Oops...';
        $template->errorMessage = $templateErrorMessage;
        echo $template->execute();
    } catch (Exception $e) {
        // Fehlgeschlagen, Ausgabe als String
        World_Base::$LOG->write((string) $e . ' (' . __FILE__ . ')', Error::FATAL);
        $templateErrorMessage .= '<br />Das Fehlertemplate konnte nicht geladen werden.';
        echo '<p>' . $templateErrorMessage . '</p>';
    }
}
Ejemplo n.º 2
0
    // Pokemon auslesen
    $boxPokemon = array();
    for ($i = 0; $i < World_StoreBox::MAX_SLOTS; $i++) {
        if (!$storeBox->storeBoxes[$currentBoxNr]->slotIsFree($i)) {
            $pokemon = $storeBox->storeBoxes[$boxNr]->getPokemonAtSlot($i);
            $boxPokemon[$i] = array('displayName' => $pokemon->getDisplayName(), 'spritePos' => getSpritePosition($spriteImg, $pokemon->getPokedexNumber()), 'maxKp' => $pokemon->getMaxKp(), 'restKp' => $pokemon->getKp(), 'level' => $pokemon->getLevel(), 'ep' => $pokemon->getExperiencePoints(), 'levelUpEp' => $pokemon->getLevelUpEp());
        } else {
            $boxPokemon[$i] = false;
            continue;
        }
    }
    // Speichern
    $box = array();
    $box['boxPokemon'] = $boxPokemon;
    $box['currentBoxNr'] = $currentBoxNr;
    $box['box'] = $storeBoxes[$currentBoxNr];
    $box['index'] = $boxIndex;
    $boxes[] = $box;
    $javascriptContent[] = 'initializeStoragePc(storagePcContainerIdBase + ' . $boxIndex . ');';
}
$template->bigSprite = $spriteImgBig;
$template->sprite = $spriteImg;
$template->maxBoxes = count($storeBoxes);
$template->storeBoxes = $storeBoxes;
$template->boxes = $boxes;
$template->box = $boxes[0];
// für singlebox-View
$javascriptContent[] = '
// Team öffnen und Lagerbox initialisieren
loadSideBoxContent("' . buildSiteUrl('team', '', 'noSortable=true') . '", initializeStoragePcPokemonTeam);
';
Ejemplo n.º 3
0
<?php

$user = World_Base::$USER;
$inventoryObject = $user->getInventory();
$userItems = array();
// Vorhandene Itemgruppen ermitteln
$itemGroups = $inventoryObject->getItemGroups();
$itemGroup = 1;
foreach ($itemGroups as $key => $iG) {
    $itemGroups[$key] += array('link' => buildSiteUrl('inventory', '', 'itemGroup=' . $iG['id']));
}
// Gewählte Itemgruppe überprüfen und verwenden
if (isset($_GET['itemGroup'])) {
    if (isset($itemGroups[$_GET['itemGroup']])) {
        $itemGroup = intval($_GET['itemGroup']);
    }
}
// Items auslesen
foreach ($inventoryObject->getItemStacks() as $itemStack) {
    if ($itemStack->getItemGroup() == $itemGroup) {
        $userItems[] = array('name' => $itemStack->getName(), 'quantity' => $itemStack->getQuantity(), 'spriteCoords' => getSpritePosition(IMG_ITEMS_NORMAL_SPRITE, $itemStack->getItem()->getId()));
    }
}
// Template aufbauen
$template->templateFile = 'inventory.html';
$template->templateMacro = 'inventory';
$template->contentTitle = 'Beutel';
$template->items = $userItems;
$template->itemGroups = $itemGroups;
$template->selectedItemGroup = $itemGroup;
$template->sprite = IMG_ITEMS_NORMAL_SPRITE;
Ejemplo n.º 4
0
 /**
  * konvertiert Code in ein LayerObjekt
  * @param $codeLine string
  * @return string
  */
 function compileLine($codeLine)
 {
     $layerObject = false;
     // feststellen, ob Zeile ein Tag enthält
     // '<', '>' und sonstige Zeichen ausserhalb des Tags entfernen
     $lineRegex = '@.*<([a-z]+) .*>.*@i';
     if (preg_match($lineRegex, $codeLine, $lineMatch)) {
         $tagName = $lineMatch[1];
         $attributes = $this->readAttributesFromLine($codeLine);
         // Attribute überprüfen
         if ($this->hasAllAttributes(array_keys($attributes), $tagName)) {
             switch ($tagName) {
                 case 'pfeil':
                     $graphic = GAME_GRAPHICS_ABSOLUTE_PATH . 'pfeil_' . $attributes['richtung'] . '.png';
                     if (file_exists($graphic)) {
                         $dimensions = getimagesize($graphic);
                         $layerObject = new World_Map_LayerObject('pfeil_' . $attributes['richtung'], $attributes['left'], $attributes['top'], $dimensions[0], $dimensions[1], $attributes['hover'], buildSiteUrl('map', 'changemap', 'map=' . World_Map::getIdFromName($attributes['to'])));
                         $this->drawOnImage($graphic, $attributes['left'], $attributes['top']);
                     }
                     break;
                 case 'olink':
                     $layerObject = new World_Map_LayerObject('olink', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('map', 'changemap', 'map=' . World_Map::getIdFromName($attributes['to'])));
                     break;
                 case 'umove':
                     // $layerObject = new World_Map_LayerObject('umove', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], '?site=attack&id=' . urlencode($attributes['move']));
                     // break;
                 // $layerObject = new World_Map_LayerObject('umove', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], '?site=attack&id=' . urlencode($attributes['move']));
                 // break;
                 case 'hover':
                     $layerObject = new World_Map_LayerObject('hover', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover']);
                     break;
                 case 'plink':
                     $layerObject = new World_Map_LayerObject('plink', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], '...', buildSiteUrl('fight', '', 'field=' . $attributes['field']));
                     break;
                 case 'plinka':
                     $layerObject = new World_Map_LayerObject('plinka', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], '...', buildSiteUrl('fight', '', 'field=' . $attributes['field']));
                     break;
                 case 'pokebox':
                     $layerObject = new World_Map_LayerObject('pokebox', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('storagePc'));
                     break;
                 case 'heal':
                     $layerObject = new World_Map_LayerObject('heal', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('map', 'heal'));
                     break;
                 case 'shop':
                     $layerObject = new World_Map_LayerObject('shop', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('shop', '', 'id=' . $attributes['shopid']));
                     break;
                 case 'pokeshop':
                     $layerObject = new World_Map_LayerObject('pokeshop', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('pokeshop', '', 'id=' . $attributes['shopid']));
                     break;
                 case 'tkampf':
                     $layerObject = new World_Map_LayerObject('tkampf', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('trainerFight'));
                     break;
                 case 'tausch':
                     $layerObject = new World_Map_LayerObject('trade', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('trade'));
                     break;
                 case 'giveitem':
                     $layerObject = new World_Map_LayerObject('giveitem', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('map', 'giveItem', 'id=' . $attributes['itemid']), $attributes['itemdid']);
                     break;
                 case 'img':
                     $graphic = GAME_GRAPHICS_ABSOLUTE_PATH . $attributes['src'];
                     if (file_exists($attributes['src'])) {
                         $dimensions = getimagesize($attributes['src']);
                         $layerObject = new World_Map_LayerObject('img', $attributes['left'], $attributes['top'], $dimensions[0], $dimensions[1], $attributes['hover']);
                         $this->drawOnImage($attributes['src'], $attributes['left'], $attributes['top']);
                     }
                     break;
                 case 'npc':
                     $layerObject = new World_Map_LayerObject('npc', $attributes['left'], $attributes['top'], $attributes['width'], $attributes['height'], $attributes['hover'], buildSiteUrl('npc', 'id=' . $attributes['id']));
                     break;
                 default:
                     $layerObject = false;
             }
             if ($layerObject !== false) {
                 // optionale Attribute verarbeiten
                 $optionalAttributes = $this->_tags[$tagName]->getOptionalAttributes();
                 foreach ($optionalAttributes as $optAttr) {
                     if (isset($attributes[$optAttr])) {
                         $attributeValue = $attributes[$optAttr];
                         switch ($optAttr) {
                             case 'condition_attack':
                                 $layerObject->addCondition('attack', $attributeValue);
                                 break;
                             case 'condition_item':
                                 $layerObject->addCondition('item', $attributeValue);
                                 break;
                         }
                     }
                 }
             }
         }
     }
     return $layerObject;
 }