コード例 #1
0
ファイル: 1088.php プロジェクト: rwruss/ib3
<?php

echo 'Leave a plot #' . $postVals[1];
// Remove plot from players list of plots
include './slotFunctions.php';
//$slotFile = fopen($gamePath.'/gameSlots.slt', 'rb');
$slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
fseek($unitFile, $pGameID * $defaultBlockSize);
$playerDat = unpack('i*', fread($unitFile, 200));
$plotSlot = new itemSlot($playerDat[20], $slotFile, 40);
print_r($plotSlot->slotData);
$loc = array_search($postVals[1], $plotSlot->slotData);
echo "Delete at " . $loc;
if ($loc) {
    $plotSlot->deleteItem($loc, $slotFile);
}
fclose($unitFile);
fclose($slotFile);
コード例 #2
0
ファイル: 1066.php プロジェクト: rwruss/ib3
$unitFile = fopen($gamePath . '/unitDat.dat', 'r+b');
fseek($unitFile, $_SESSION['selectedItem'] * $defaultblocksize);
$subCityDat = unpack('i*', fread($unitFile, 400));
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
$credList = array_filter(unpack("i*", readSlotData($slotFile, $subCityDat[19], 40)));
$approved = array_search($pGameID, $credList);
echo 'Approved level ' . $approved . '<br>';
if ($approved) {
    if ($subCityDat[29] > 0) {
        fseek($unitFile, $subCityDat[29] * $defaultblocksize);
        $parCityDat = unpack('i*', fread($unitFile, 400));
        // Remove from the list of child citys for the parent city
        $childCityList = new itemSlot($parCityDat[30], $slotFile);
        $target = array_search($_SESSION['selectedItem'], $childCityList->slotData);
        if ($target) {
            $childCityList->deleteItem($target, $slotFile);
        }
    }
    // Change the child city to a resource cart/moving group object
    /// Save location of the unit to match that of the city and adjust unit types
    fseek($unitFile, $_SESSION['selectedItem'] * $defaultblocksize);
    fwrite($unitFile, pack('i*', $parCityDat[1], $parCityDat[2], 10, 10, $pGameID, $pGameID, 1, 1, 1));
    /// Update last change time
    fseek($unitFile, $_SESSION['selectedItem'] * $defaultblocksize + 104);
    fwrite($unitFile, pack('i', time()));
    /// Add to list of military units for this player
    fseek($unitFile, $pGameID * $defaultblocksize);
    $playerDat = unpack('i*', fread($unitFile, 400));
    $unitList = new itemSlot($playerDat[22], $slotFile, 40);
    // start, file, size
    $unitList->addItem($_SESSION['selectedItem'], $slotFile);
コード例 #3
0
ファイル: 1072.php プロジェクト: rwruss/ib3
<?php

include './slotFunctions.php';
include './unitClass.php';
echo 'Join battle ' . $postVals[1] . ' on side ' . $postVals[2];
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
$slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
$mapSlotFile = fopen($gamePath . '/mapSlotFile.slt', 'r+b');
$baseUnit = new warband($_SESSION['selectedUnit'], $unitFile, 400);
$thisBattle = new battle($postVals[1], $unitFile, 100);
// Verify that unit can join battle
// Update unit status and save the battle ID to the unit
$baseUnit->set('status', 2);
$baseUnit->set('battleID', $postVals[1]);
// Remove the unit from the map
$mapSlotNum = floor($baseUnit->get('yLoc') / 120) * 120 + floor($baseUnit->get('xLoc') / 120);
$mapSlotItem = new itemSlot($mapSlotNum, $mapSlotFile, 404);
$location = array_search($_SESSION['selectedUnit'], $mapSlotItem->slotData);
if ($location) {
    $mapSlotItem->deleteItem($location, $mapSlotFile);
}
// Add the unit to the battle list for the selected side
$battleList = new itemSlot($thisBattle->get('sideList_1'), $slotFile, 40);
$battleList->addItem($_SESSION['selectedUnit'], $slotFile);
fclose($unitFile);
fclose($slotFile);
fclose($mapSlotFile);
コード例 #4
0
ファイル: itemSlotTest.php プロジェクト: rwruss/ib3
<?php

include 'c:/websites/ib3/public_html/slotFunctions.php';
$testFile = fopen('itemSlot.slt', 'r+b');
fseek($testFile, 40 * 10 - 4);
fwrite($testFile, pack('i', 0));
$testSlot = new itemSlot(5, $testFile, 40);
print_r($testSlot->slotData);
echo '<p>';
//$testSlot->addItem(7, $testFile);
$deleteLoc = array_search(7, $testSlot->slotData);
if ($deleteLoc) {
    $testSlot->deleteItem($deleteLoc, $testFile);
}
/*
$addTarget = sizeof($testSlot->slotData);
echo 'Add target os '.$addTarget.'<br>';
$testSlot->addItem($testFile, $sendData, $addTarget);
print_r($testSlot->slotData);
*/
$checkSlot = new itemSlot(5, $testFile, 40);
print_r($checkSlot->slotData);
fclose($testFile);
コード例 #5
0
ファイル: 1067.php プロジェクト: rwruss/ib3
    flock($unitFile, LOCK_UN);
    // release the lock  on the player File
}
// Add the parent city ID to the current city
fseek($unitFile, $_SESSION['selectedItem'] * $defaultBlockSize + 112);
fwrite($unitFile, pack('i', $newCityId));
// Remove the unit cart / other items from the map and change the mapslot to display the new city
$mapSlotFile = fopen($gamePath . '/mapSlotFile.slt', 'r+b');
$mapSlotNum = floor($unitDat[2] / 120) * 120 + floor($unitDat[1] / 120);
echo 'Mapo slot number is ' . $mapSlotNum . '<br>';
$mapSlot = new itemSlot($mapSlotNum, $mapSlotFile, 404);
print_r($mapSlot->slotData);
$currentPos = array_search($_SESSION['selectedItem'], $mapSlot->slotData);
echo 'Current Pos: ' . $currentPos . '<br>';
if ($currentPos) {
    $mapSlot->deleteItem($currentPos, $mapSlotFile);
}
echo 'Add new city to map item List<br>';
$mapSlot->addItem($newCityId, $mapSlotFile);
// Add this player to the credential list for the city
echo 'Open city ' . $newCityId . '<br>';
$thisCity = new city($newCityId, $unitFile);
$cityCredentials = new blockSlot($thisCity->cityData[19], $slotFile, 40);
$addLoc = array_search(0, $cityCredentials->slotData);
echo 'Add credintials to slot (' . $thisCity->cityData[19] . ')';
print_r($cityCredentials->slotData);
$cityCredentials->addItem($slotFile, pack('i*', -9, $pGameID), $addLoc);
// Change this cart object to a city object
fseek($unitFile, $_SESSION['selectedItem'] * $defaultBlockSize + 12);
fwrite($unitFile, pack('i', 1));
// Remove the cart from the list of military units the player controls