Exemplo n.º 1
0
function newTown($id, $townFile, $slotFile, $townDtls)
{
    global $defaultBlockSize, $gameSlot, $pGameID, $startLocation, $gamePath;
    $townData = array_fill(1, 100, 0);
    $townData[1] = $townDtls[0];
    // X loc
    $townData[2] = $townDtls[1];
    // Y Loc
    $townData[3] = 1;
    $townData[4] = 1;
    $townData[5] = $townDtls[2];
    // pgameId
    $townData[6] = $townDtls[2];
    // pgameID
    $townData[7] = 1;
    $townData[8] = $townDtls[3];
    // Culture
    $townData[25] = $townDtls[4];
    // Culture
    $townData[27] = time();
    // Create a credential list for the town and record this player as having full cred.
    $credListSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    $townData[19] = $credListSlot;
    echo 'credintial slot:' . $credListSlot . '<br>';
    writeBlocktoSlot($gamePath . "/gameSlots.slt", $credListSlot, pack('i*', -9, $pGameID), $slotFile, 40);
    // ($slotHandle, $checkSlot, $addData, $slotFile, $slotSize)
    // Make a chars slot for the new town and record the player's faction leader as the town's leader
    $townCharSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town Char Slot is ' . $townCharSlot . '<br>';
    $townData[13] = $townCharSlot;
    // Make a units slot for the new town
    $townUnitSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town Unit Slot is ' . $townUnitSlot . '<br>';
    $townData[18] = $townUnitSlot;
    // Make a resource slot for the new town
    $rscSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town RSC Slot is ' . $rscSlot . '<br>';
    $townData[11] = $rscSlot;
    // Make a task slot for the new town
    $taskSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town task Slot is ' . $taskSlot . '<br>';
    $townData[21] = $taskSlot;
    echo 'Final town data:';
    print_r($townData);
    echo '<p>';
    fseek($townFile, $id * $defaultBlockSize);
    for ($i = 1; $i <= sizeof($townData); $i++) {
        fwrite($townFile, pack('i', $townData[$i]));
    }
    return $townData;
}
Exemplo n.º 2
0
    //$trgArmy = new army($workingUnit->unitDat[15], $unitFile, 400);
    $capacity = $trgArmy->get('carryCap');
    if ($trgArmy->get('carrySlot') == 0) {
        $newSlot = startASlot($unitSlotFile, "../users/userSlots.slt");
        $trgArmy->set('carrySlot', $newSlot);
        $trgArmy->saveAll($unitFile);
        $useRscSlot = $newSlot;
    } else {
        $useRscSlot = $trgArmy->get('carrySlot');
    }
} else {
    $capacity = $workingUnit->get('carryCap');
    echo 'Working unit stuff:';
    print_r($workingUnit->unitDat);
    if ($workingUnit->get('carrySlot') == 0) {
        $newSlot = startASlot($unitSlotFile, "../users/userSlots.slt");
        $workingUnit->set('carrySlot', $newSlot);
        $workingUnit->saveAll($unitFile);
        $useRscSlot = $newSlot;
    } else {
        $useRscSlot = $workingUnit->get('carrySlot');
    }
}
$unitRSC = new blockSlot($useRscSlot, $unitSlotFile, 40);
echo 'List of carried resources (Slot ' . $useRscSlot . ')';
print_r($unitRSC->slotData);
$rscStart = [0, 0, 0];
for ($i = 1; $i < sizeof($unitRSC->slotData); $i += 2) {
    if ($unitRSC->slotData[$i] == $rscPoint[10]) {
        $rscStart[0] = $i;
        $rscStart[1] = $unitRSC->slotData[$i + 1];
Exemplo n.º 3
0
Arquivo: 1039.php Projeto: rwruss/ib3
 $newBldg->unitDat[18] = 100;
 $newBldg->unitDat[19] = 1;
 $newBldg->unitDat[20] = 100;
 $newBldg->unitDat[22] = 10000;
 $newBldg->unitDat[23] = 10000;
 $newBldg->unitDat[24] = 100;
 $newBldg->unitDat[27] = time();
 $newBldg->saveAll($unitFile);
 //fseek($unitFile, $newID*$defaultBlockSize);
 //fwrite($unitFile, pack('i*', intval($postVals[1]/2)*2, intval($postVals[2]/2)*2, 0, 2, 0, 0, 0, 1, 1, $bldgTypeInfo[11], 0, 0, 0, 0, $cityID, 0, 0, 100, 1, 0, 0));
 // add the building to the town as an "in progress" building
 // Verify that slot exists and create one if needed. -> use resource point list for resource points
 echo 'City resource point is - ' . $cityDat[10];
 if ($cityDat[10] == 0) {
     // Need to create a new slot
     $cityDat[10] = startASlot($slotFile, $gamePath . '/gameSlots.slt');
     //startASlot($slot_file, $slot_handle)
     fseek($unitFile, $cityID * $defaultBlockSize + 36);
     fwrite($unitFile, pack('i', $cityDat[10]));
     echo 'created new slot ' . $cityDat[10];
     // Save new slot to city information
     fseek($unitFile, $cityID * $defaultBlockSize + 36);
     fwrite($unitFile, pack('i', $cityDat[10]));
 }
 addDataToSlot($gamePath . '/gameSlots.slt', $cityDat[10], pack('i', $newID), $slotFile);
 echo '<p>New unit ID is ' . $newID . '<br>';
 // add a task to the town as an "in progress" task
 // Create a new task to be processed.
 $taskFile = fopen($gamePath . '/tasks.tdt', 'r+b');
 $parameters = pack('i*', intval($postVals[1] / 2) * 2, intval($postVals[2] / 2) * 2, 1, time(), $buildPts[0], 0, 2, $cityID, 0, $cityID, $newID, $postVals[3]);
 $newTask = createTask($taskFile, $parameters);
Exemplo n.º 4
0
Arquivo: 1082.php Projeto: rwruss/ib3
echo 'Char slot for plot is ' . $plotDat[11] . '<br>';
$plotChars = new blockSlot($plotDat[11], $slotFile, 40);
$loc = sizeof($plotChars->slotData);
for ($i = 1; $i <= $plotChars->slotData; $i += 2) {
    if ($plotChars->slotData[$i] == 0) {
        $loc = $i;
        break;
    }
}
// Record plot in list of plaayer plots
fseek($unitFile, $_SESSION['selectedItem'] * $defaultBlockSize);
$unitDat = unpack('i*', fread($unitFile, 200));
//$plotChars->addItem($slotFile, pack('i*', $_SESSION['selectedItem'], 1), $loc);
$plotChars->addItem($slotFile, pack('i*', $pGameID, 1), $loc);
//echo 'Added character to plot at slot '.$plotDat[11];
fseek($unitFile, $unitDat[6] * $defaultBlockSize);
$controllerDat = unpack('i*', fread($unitFile, 200));
echo 'Record plot in slot ' . $unitDat[35] . ' for the unit';
if ($controllerDat[20] == 0) {
    $controllerDat[20] = startASlot($slotFile, $gamePath . '/gameSlots.slt');
    fseek($unitFile, $_SESSION['selectedItem'] * $defaultBlockSize + 136);
    fwrite($unitFile, pack('i', $controllerDat[20]));
}
$charPlots = new itemSlot($controllerDat[20], $slotFile, 40);
$charPlots->addItem($postVals[1], $slotFile);
// Send a message to the player that he has a char invited to a new plot
$trgList[] = $unitDat[6];
sendMessage([$pGameId, $unitDat[6], time(), 1, 0, $postVals[1], $_SESSION['selectedItem']], "", $trgList);
fclose($slotFile);
fclose($unitFile);
fclose($taskFile);
Exemplo n.º 5
0
Arquivo: 1079.php Projeto: rwruss/ib3
<?php

include './unitClass.php';
include "./slotFunctions.php";
include "./taskFunctions.php";
$unitFile = fopen($gamePath . '/unitDat.dat', 'r+b');
// Create a new plot task and save the parameters
$taskFile = fopen($gamePath . '/tasks.tdt', 'r+b');
$taskIndex = fopen($gamePath . '/tasks.tix', 'r+b');
$parameters = pack('i*', 0, 0, 1, time(), 0, 0, 6, $_SESSION['selectedItem'], $pGameID, 2);
$newTask = createTask($taskFile, $parameters);
//createTask($taskFile, $taskIndex, $duration, $parameters, $gamePath, $slotFile)
fclose($taskFile);
fclose($taskIndex);
// Add the new plot to the player's list of ongoing plots
fseek($unitFile, $pGameID * $defaultBlockSize);
$playerDat = unpack('i*', fread($unitFile, 200));
$slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
if ($playerDat[20] == 0) {
    $newSlot = startASlot($slotFile, $gamePath . '/gameSlots.slt');
    fseek($unitFile, $pGameID * $defaultBlockSize + 76);
    fwrite($unitFile, pack('i', $newSlot));
    $playerDat[20] = $newSlot;
}
$plotSlot = new itemSlot($playerDat[20], $slotFile, 40);
//$targetUnit = new unit($_SESSION['selectedUnit'], $unitFile);
$plotSlot->addItem($newTask, $slotFile);
fclose($slotFile);
echo 'Record this task';
print_r($postVals);
fclose($unitFile);
Exemplo n.º 6
0
Arquivo: 1011.php Projeto: rwruss/ib3
fseek($gameSlotFile, 39);
fwrite($gameSlotFile, pack("C", 0));
fseek($gameSlotFile, 0);
//Create list of players in game
$pGameID = 1;
$newFile = fopen("../games/" . $newGameId . "/players.Dat", "wb");
fwrite($newFile, pack("i*", $_SESSION['playerId'], -1));
fclose($newFile);
// Update parameters file
$paramFile = fopen("../games/" . $newGameId . "/params.ini", "r+b");
fwrite($paramFile, pack("N", time()));
fseek($paramFile, 199);
fwrite($paramFile, pack("C", 0));
fclose($paramFile);
// add Game ID to player game list
if ($gameSlot[1] == 0) {
    echo "get new Slot";
    $uSlot = fopen("../users/userSlots.slt", "r+b");
    $newSlot = startASlot($uSlot, "../users/userSlots.slt");
    fseek($uDatFile, $_SESSION['playerId'] * 500 + 8);
    fwrite($uDatFile, pack("N", $newSlot));
    addDataToSlot("../users/userSlots.slt", $newSlot, pack("N", $newGameId), $uSlot);
    fclose($uSlot);
} else {
    echo "Add game to slot";
    $uSlot = fopen("../users/userSlots.slt", "r+b");
    addDataToSlot("../users/userSlots.slt", $gameSlot[1], pack("N", $newGameId), $uSlot);
    fclose($uSlot);
}
fclose($gameSlotFile);
fclose($uDatFile);
Exemplo n.º 7
0
Arquivo: 1004.php Projeto: rwruss/ib3
     // Record first city location in a new settlments slot
     $townSlot = startASlot($gameSlot, $gamePath . "/gameSlots.slt");
     $mLoc = sizeof($mapSlot->slotData);
     for ($i = 1; $i <= sizeof($mapSlot->slotData); $i += 2) {
         if ($mapSlot->slotData[$i] == 0) {
             $mLoc = $i;
             break;
         }
     }
     $mapSlot->addItem($mapSlotFile, pack('i*', $townID, 1), $mLoc);
     // file, bin value, loc
 } else {
     // Create a new army unit for the items to be grouped into
     $armyID = $unitIndex;
     $unitIndex += 4;
     $armySlot = startASlot($gameSlot, $gamePath . "/gameSlots.slt");
     fseek($unitFile, $armyID * $defaultBlockSize);
     fwrite($unitFile, pack('i*', $startLocation[0], $startLocation[1], 1, 3, $pGameID, $pGameID, 1, $postVals[1], 0));
     fseek($unitFile, $armyID * $defaultBlockSize + 52);
     fwrite($unitFile, pack('i', $armySlot));
     $mLoc = sizeof($mapSlot->slotData);
     for ($i = 1; $i <= sizeof($mapSlot->slotData); $i += 2) {
         if ($mapSlot->slotData[$i] == 0) {
             $mLoc = $i;
             break;
         }
     }
     $mapSlot->addItem($mapSlotFile, pack('i*', $armyID, 0), $mLoc);
     // file, bin value, loc
     $armyObj = new itemSlot($armySlot, $gameSlot, 40);
     $unitList->addItem($armyID, $gameSlot);