<?php

if (!$player->getSector()->hasLocation($var['LocationID'])) {
    create_error('That location does not exist in this sector');
}
$weapon =& SmrWeapon::getWeapon($player->getGameID(), $var['WeaponTypeID']);
// Are we buying?
if (!isset($var['OrderID'])) {
    $location =& SmrLocation::getLocation($var['LocationID']);
    if (!$location->isWeaponSold($var['WeaponTypeID'])) {
        create_error('We do not sell that weapon here!');
    }
    if ($weapon->getRaceID() != RACE_NEUTRAL && $player->getRelation($weapon->getRaceID()) < 300) {
        create_error('We are at WAR!!! Do you really think I\'m gonna sell you that weapon?');
    }
    // do we have enough cash?
    if ($player->getCredits() < $weapon->getCost()) {
        create_error('You do not have enough cash to purchase this weapon!');
    }
    // can we load such a weapon (power_level)
    if (!$ship->checkPowerLevel($weapon->getPowerLevel())) {
        create_error('Your ship doesn\'t have enough power to support that weapon!');
    }
    if ($ship->getOpenWeaponSlots() < 1) {
        create_error('You can\'t buy any more weapons!');
    }
    if ($weapon->getBuyerRestriction() == 2 && $player->getAlignment() > -100) {
        create_error('You can\'t buy evil weapons!');
    } else {
        if ($weapon->getBuyerRestriction() == 1 && $player->getAlignment() < 100) {
            create_error('You can\'t buy good weapons!');
Beispiel #2
0
            $Ships =& AbstractSmrShip::getAllBaseShips(Globals::getGameType($ThisPlayer->getGameID()));
            Sorter::sortByNumElement($Ships, 'Name');
            foreach ($Ships as &$Ship) {
                ?>
<option value="<?php 
                echo $Ship['ShipTypeID'];
                ?>
"><?php 
                echo $Ship['Name'];
                ?>
</option><?php 
            }
            unset($Ship);
            break;
        case 'Weapons':
            $Weapons =& SmrWeapon::getAllWeapons(Globals::getGameType($ThisPlayer->getGameID()));
            Sorter::sortByNumMethod($Weapons, 'getName');
            foreach ($Weapons as &$Weapon) {
                ?>
<option value="<?php 
                echo $Weapon->getWeaponTypeID();
                ?>
"><?php 
                echo $Weapon->getName();
                ?>
</option><?php 
            }
            unset($Weapon);
            break;
        case 'Locations':
            ?>
Beispiel #3
0
<?php

$template->assign('PageTopic', 'Edit Dummys');
require_once get_file_loc('DummyPlayer.class.inc');
require_once get_file_loc('DummyShip.class.inc');
require_once get_file_loc('SmrWeapon.class.inc');
//TODO add game type id
$template->assign('CombatSimLink', SmrSession::getNewHREF(create_container('skeleton.php', 'combat_simulator.php')));
$template->assignByRef('BaseShips', AbstractSmrShip::getAllBaseShips(0));
$template->assignByRef('Weapons', SmrWeapon::getAllWeapons(0));
$template->assign('EditDummysLink', SmrSession::getNewHREF(create_container('skeleton.php', 'edit_dummys.php')));
$dummyPlayer =& DummyPlayer::getCachedDummyPlayer($_REQUEST['dummy_name']);
$dummyShip =& $dummyPlayer->getShip();
if (isset($_REQUEST['save_dummy'])) {
    $dummyPlayer->setPlayerName($_REQUEST['dummy_name']);
    $dummyPlayer->setExperience($_REQUEST['level']);
    $dummyPlayer->setShipTypeID($_REQUEST['ship_id']);
    $dummyShip->regenerate($dummyPlayer);
    if (isset($_REQUEST['weapons']) && is_array($_REQUEST['weapons'])) {
        $dummyShip->removeAllWeapons();
        foreach ($_REQUEST['weapons'] as $weaponTypeID) {
            if ($weaponTypeID != 0) {
                $dummyShip->addWeapon($weaponTypeID);
            }
        }
    }
    $dummyPlayer->cacheDummyPlayer();
}
$template->assignByRef('DummyPlayer', $dummyPlayer);
$template->assignByRef('DummyShip', $dummyShip);
$template->assignByRef('ShipWeapons', $dummyShip->getWeapons());
Beispiel #4
0
foreach ($races as &$race) {
    $file .= inify($race['Race Name']) . '=' . $race['Race ID'] . EOL;
}
unset($race);
$file .= '[Goods]
; ID = Name, BasePrice' . EOL;
$goods =& Globals::getGoods();
foreach ($goods as &$good) {
    $file .= $good['ID'] . '=' . inify($good['Name']) . ',' . $good['BasePrice'] . EOL;
}
unset($good);
$file .= '[Weapons]
; Weapon = Race,Cost,Shield,Armour,Accuracy,Power level,EMP (%),Align Restriction,Attack Restriction
; Align: 0=none, 1=good, 2=evil, 3=newbie
; Attack: 0=none, 1=raid' . EOL;
$weapons =& SmrWeapon::getAllWeapons(Globals::getGameType($gameID));
foreach ($weapons as &$weapon) {
    $file .= inify($weapon->getName()) . '=' . inify($weapon->getRaceName()) . ',' . $weapon->getCost() . ',' . $weapon->getShieldDamage() . ',' . $weapon->getArmourDamage() . ',' . $weapon->getBaseAccuracy() . ',' . $weapon->getPowerLevel() . ',' . $weapon->getEmpDamage() . ',' . $weapon->getBuyerRestriction() . ',' . ($weapon->isRaidWeapon() ? '1' : '0') . EOL;
}
unset($weapon);
$file .= '[ShipEquipment]
; Name = Cost' . EOL;
$hardwares =& Globals::getHardwareTypes();
foreach ($hardwares as &$hardware) {
    $file .= inify($hardware['Name']) . '=' . $hardware['Cost'] . EOL;
}
unset($hardware);
$file .= '[Ships]
; Name = Race,Cost,TPH,Hardpoints,Power,+Equipment (Optional),+Restrictions(Optional)
; Restrictions:Align(Integer)' . EOL;
$ships =& AbstractSmrShip::getAllBaseShips($gameID);
Beispiel #5
0
                $location->removeShipSold($shipTypeID);
            }
        }
        if (isset($_REQUEST['remove_weapons']) && is_array($_REQUEST['remove_weapons'])) {
            foreach ($_REQUEST['remove_weapons'] as $weaponTypeID) {
                $location->removeWeaponSold($weaponTypeID);
            }
        }
        if (isset($_REQUEST['remove_hardware']) && is_array($_REQUEST['remove_hardware'])) {
            foreach ($_REQUEST['remove_hardware'] as $hardwareTypeID) {
                $location->removeHardwareSold($hardwareTypeID);
            }
        }
        $location->setFed(isset($_REQUEST['fed']));
        $location->setBar(isset($_REQUEST['bar']));
        $location->setBank(isset($_REQUEST['bank']));
        $location->setHQ(isset($_REQUEST['hq']));
        $location->setUG(isset($_REQUEST['ug']));
    }
    $template->assignByRef('Location', $location);
    $template->assignByRef('Ships', AbstractSmrShip::getAllBaseShips($var['game_type_id']));
    $template->assignByRef('Weapons', SmrWeapon::getAllWeapons($var['game_type_id']));
    $db->query('SELECT * FROM hardware_type');
    $hardware = array();
    while ($db->nextRecord()) {
        $hardware[$db->getField('hardware_type_id')] = array('ID' => $db->getField('hardware_type_id'), 'Name' => $db->getField('hardware_name'));
    }
    $template->assignByRef('AllHardware', $hardware);
} else {
    $template->assignByRef('Locations', SmrLocation::getAllLocations());
}