Ejemplo n.º 1
0
function giveWeapon($monster, &$charData)
{
    //---------------------------------------
    // Barbarian trait: :D
    //
    global $traitMap;
    $isBarbarian = $traitMap->ClassHasTrait($charData, TraitName::DualWield);
    //---------------------------------------
    $textOutput = "";
    $monsterLevel = $monster->level;
    $weaponName = NameGenerator::Weapon($monsterLevel);
    $weaponLvl = lootLevel($monsterLevel);
    $currentWpnVal = $charData->weaponVal;
    // Only equip weapons that are better.
    if ($weaponLvl > $currentWpnVal) {
        $article = NameGenerator::GetArticle($weaponName);
        $textOutput = "You find {$article} {$weaponName} and equip it immediately";
        if ($isBarbarian && $charData->weaponVal > $charData->weapon2Val) {
            $textOutput .= ", moving your {$charData->weapon} to your off-hand";
            $charData->weapon2 = $charData->weapon;
            $charData->weapon2Val = $charData->weaponVal;
        }
        $textOutput .= "! ";
        $charData->weapon = $weaponName;
        $charData->weaponVal = $weaponLvl;
    } else {
        if ($isBarbarian && $weaponLvl > $charData->weapon2Val) {
            $article = NameGenerator::GetArticle($weaponName);
            $textOutput = "You find {$article} {$weaponName} and equip it immediately in your off-hand! ";
            $charData->weapon2 = $weaponName;
            $charData->weapon2Val = $weaponLvl;
        } else {
            $textOutput = giveGold($monster, $charData);
        }
    }
    return $textOutput;
}
Ejemplo n.º 2
0
function moveToRoom($x, $y, $xDelta, $yDelta, $mapData, $charData, $moveText)
{
    global $procGen;
    $newX = $x + $xDelta;
    $newY = $y + $yDelta;
    if (!checkBounds($newX, $newY)) {
        echo "Looks like there's nothing that way...\n";
        return;
    }
    // Cache the current position, for running away.
    $mapData->lastPlayerX = $mapData->playerX;
    $mapData->lastPlayerY = $mapData->playerY;
    $mapData->playerX = $newX;
    $mapData->playerY = $newY;
    $room = $mapData->map->GetRoom($newX, $newY);
    $seenBefore = isset($room);
    if (!$seenBefore) {
        $room = $procGen->GenerateRoomForMap($mapData->map, $mapData->playerX, $mapData->playerY, $charData->level);
    }
    $containsMonster = isset($room->occupant) && get_class($room->occupant) == "Monster";
    $containsShop = isset($room->occupant) && get_class($room->occupant) == "Shop";
    if ($containsMonster) {
        $monster = $room->occupant;
        $monsterName = $monster->name;
        $article = NameGenerator::GetArticle($monsterName);
        $connedName = $monster->getConnedNameStr($charData->level);
        if (!$seenBefore) {
            $moveText .= "and encounter a Level {$monster->level} {$connedName}! It attacks!\n";
            // Combat!
            StateManager::ChangeState($charData, GameStates::Combat);
        } else {
            $moveText .= "and encounter the Level {$monster->level} {$connedName} again! It attacks again!\n";
            // Combat!
            StateManager::ChangeState($charData, GameStates::Combat);
        }
    } else {
        if ($containsShop) {
            $moveText .= "and discover a small shop. \"Feel free to br(o)wse!\", the shopkeeper yells.\n";
        } else {
            $moveText .= "but this room appears to be empty.\n";
        }
    }
    echo $moveText;
}