Example #1
0
File: 1001.php Project: rwruss/ib3
<?php

include "./slotFunctions.php";
// look up player information to get slot IDS
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
fseek($unitFile, $pGameID * $defaultBlockSize);
$playerDat = unpack('i*', fread($unitFile, $unitBlockSize));
// Read the character slot for the player
//echo 'Check slot '.$playerDat[19].'<br>';
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
$unitList = array_filter(unpack("i*", readSlotData($slotFile, $playerDat[19], 40)));
//print_r($unitList);
echo '<script>
useDeskTop.newPane("characters");
thisDiv = useDeskTop.getPane("characters");';
foreach ($unitList as $unitID) {
    fseek($unitFile, $unitID * $defaultBlockSize);
    $unitDat = unpack('i*', fread($unitFile, $unitBlockSize));
    echo '

		unitList.newUnit({unitType:"character", unitID:' . $unitID . ', unitName:"char name", actionPoints:1000, strength:75});
		unitList.renderSum(' . $unitID . ', thisDiv);';
}
echo '</script>';
fclose($slotFile);
fclose($unitFile);
Example #2
0
File: 1031.php Project: rwruss/ib3
$cityID = $_SESSION['selectedItem'];
$charID = $_SESSION['selectedChar'];
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
fseek($unitFile, $cityID * $defaultBlockSize);
$cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
// Verify that player has credentials to view this info
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
$credList = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[19], 40)));
$approved = array_search($pGameID, $credList);
if ($approved != false) {
    $credLevel = $credList[$approved - 1] * -1;
} else {
    $credLevel = 0;
}
//// // Get list of characters for this town
$townLeaders = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[13], 40)));
$numLeaders = sizeof($townLeaders);
$rankList[0] = array();
$rankList[1] = array();
$rankList[2] = array();
$rankList[3] = array();
$rankList[4] = array();
$rankList[5] = array();
$rankList[6] = array();
$rankList[7] = array();
$rankList[8] = array();
$rankList[9] = array();
for ($i = 0; $i < $numLeaders; $i++) {
    if ($townLeaders[$i] < 0) {
        $trgRank = -$townLeaders[$i];
    } else {
Example #3
0
File: 1105.php Project: rwruss/ib3
var selectHead = addDiv("abcded", "stdContainer", "rtPnl");
';
// Look for nearby settlements that you can drop resources in
$mapSlot = floor($selectedUnit->get('yLoc') / 120) * 120 + floor($selectedUnit->get('xLoc') / 120);
//echo 'Mapslot is '.$mapSlot.' from '.$selectedUnit->get('xLoc').', '.$selectedUnit->get('yLoc');
$mapSlotFile = fopen($gamePath . '/mapSlotFile.slt', 'rb');
$gridList = new itemSlot($mapSlot, $mapSlotFile, 404);
//print_r($gridList->slotData);
for ($i = 1; $i <= sizeof($gridList->slotData); $i += 2) {
    if ($gridList->slotData[$i] > 0) {
        //echo 'Load unit ('.$gridList->slotData[$i].')';
        $checkObj = loadUnit($gridList->slotData[$i], $unitFile, 400);
        // Check to see if unit is a city
        if ($checkObj->get('uType') == 1) {
            // Check to get city permissions
            $credList = array_filter(unpack("i*", readSlotData($slotFile, $checkObj->unitDat[19], 40)));
            $approved = checkCred($pGameID, $credList);
            if ($approved) {
                // display the place as an option to drop the stuff
                echo 'unitList.newUnit({unitType:"town", unitID:' . $gridList->slotData[$i] . ', unitName:"Town ' . $gridList->slotData[$i] . '", actionPoints:"0", strength:75, tNum:"0"});
				var objContain = addDiv("", "selectContain", rtPnl);
				unitList.renderSum(' . $gridList->slotData[$i] . ', objContain);
				selectButton(objContain, "hai", ' . $gridList->slotData[$i] . ', [selectHead]);';
            }
        }
    }
}
fclose($mapSlotFile);
// Load what the unit/army is carrying and display slider bars for deposit amounts
echo 'groupList = [];';
$carryDat = new blockSlot($selectedUnit->get('carrySlot'), $slotFile, 40);
Example #4
0
File: 1030.php Project: rwruss/ib3
<?php

include './taskFunctions.php';
include "./slotFunctions.php";
echo 'Start construction of building ' . $postVals[1] . ' at city ' . $postVals[2] . ' from player ' . $pGameID . '<br>';
// Verify that player has a character that can control this place
//// // Load city Dat
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
fseek($unitFile, $postVals[2] * $defaultBlockSize);
$cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
//// // Get list of characters for this town
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
$townLeaders = unpack("i*", readSlotData($slotFile, $cityDat[13], 40));
echo 'Town leader slot: ' . $cityDat[13] . '<br>';
$numLeaders = sizeof($townLeaders);
$rankList[0] = array();
$rankList[1] = array();
$rankList[2] = array();
$rankList[3] = array();
$rankList[4] = array();
$rankList[5] = array();
$rankList[6] = array();
$rankList[7] = array();
$rankList[8] = array();
$rankList[9] = array();
print_r($townLeaders);
for ($i = 1; $i <= $numLeaders; $i++) {
    if ($townLeaders[$i] < 0) {
        $trgRank = -$townLeaders[$i];
    } else {
        $rankList[$trgRank][] = $townLeaders[$i];
Example #5
0
File: 1004.php Project: rwruss/ib3
    $playerId = $_SESSION['playerId'];
    echo 'conPanePlayer Games (' . $playerId . ')<p>
	<a href="javascript:void(0)" onclick=passClick("1009,0")>Join a Game</a>|
	<a href="javascript:void(0)" onclick=passClick(1010)>Create a new Game</a><hr>';
    $pDatFile = fopen('../users/userDat.dat', 'rb');
    fseek($pDatFile, $playerId * 500);
    $playerDat = fread($pDatFile, 500);
    $gameSlot = unpack('N', substr($playerDat, 8, 4));
    echo $gameSlot[1];
    if ($gameSlot[1] == 0) {
        echo 'Not playing any games now. (' . $gameSlot[1] . ')';
    } else {
        //echo 'Read Slot '.$gameSlot[1].'<br>';
        $slotFile = fopen('../users/userSlots.slt', 'rb');
        //$gameList = read_slot($slotFile, $gameSlot[1], 40);
        $gameList = unpack('N*', readSlotData($slotFile, $gameSlot[1], 40));
        fclose($slotFile);
        print_r($gameList);
        for ($i = 1; $i <= sizeof($gameList); $i++) {
            if ($gameList[$i] > 0) {
                echo 'Game #' . $gameList[$i] . ' - <a href="javascript:void(0)"; onclick=passClick("1012,' . $gameList[$i] . '")>Load Game</a><hr>';
            }
        }
    }
} else {
    include '../scripts/1002.php';
}
/*
function read_slot($file, $slot_num, $slot_size)
	{
	$next_slot = $slot_num;
Example #6
0
File: 2002.php Project: rwruss/ib3
echo 'Updating Resources...';
print_r($postVals);
include "./slotFunctions.php";
//Load city info
$cityID = $_SESSION['selectedItem'];
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
fseek($unitFile, $cityID * $defaultBlockSize);
$cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
fclose($unitFile);
echo 'City Data: ';
print_r($cityDat);
if ($cityDat[11] > 0) {
    // Load resource Data
    $slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
    $cityRsc = array_fill(1, 100, 0);
    $rscDat = unpack("i*", readSlotData($slotFile, $cityDat[11], 40));
    $numHave = sizeof($rscDat) / 2;
    echo '<p>City Resources in slot ' . $cityDat[11] . ': ';
    for ($i = 1; $i < $numHave; $i++) {
        $cityRsc[$rscDat[$i * 2 - 1]] = $rscDat[$i * 2];
    }
    // Update for resources to add...
    $cityRsc[$postVals[1]] += $postVals[2];
    // clear out empties
    $writeRsc = array_filter($cityRsc);
    $writeDat = '';
    foreach ($writeRsc as $rscID => $rscAmt) {
        $writeDat .= pack('i*', $rscID, $rscAmt);
        echo 'Save rsc ' . $rscID . '<br>';
    }
    print_r($writeRsc);
Example #7
0
File: 1023.php Project: rwruss/ib3
$cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
// Verify credintials
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
$credList = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[19], 40)));
$approved = array_search($pGameID, $credList);
echo '<p>City Dat cred slot is ' . $cityDat[19] . ':<br>';
print_r($credList);
if ($approved != false) {
    $credLevel = $credList[$approved - 1] * -1;
} else {
    $credLevel = 0;
}
if ($approved) {
    // Review city to see if it is allowed to construct this new building type
    /// Load list of buildings already at the city
    $buildingList = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[17], 40)));
    $numBuildings = sizeof($buildingList);
    for ($i = 1; $i <= $numBuildings; $i++) {
        fseek($unitFile, $buildingList[$i] * $defaultBlockSize);
        $buildingDat = unpack('i*', fread($unitFile, $unitBlockSize));
    }
    echo 'Select what you want to build at this location:<br>
	<select id="newBldgType">
		<option value="1">Farm</option>
		<option value="2">Mine</option>
	</select><div onclick="sendValue(\'newBldgType\', [1039,' . $baseX . ',' . $baseY . '])">Give the Order!</div>
	Buildings already present here:<br>';
    /*
    	if ($numBuildings > 0) {
    		foreach ($typeList as $typeID) {
    			echo 'Building type '.$typeID.'<br>';
Example #8
0
File: 1050.php Project: rwruss/ib3
     echo 'building list for slot (' . $cityDat[17] . '):';
     print_r($bldgList);
     foreach ($bldgList as $bldgID) {
         fseek($unitFile, $bldgID * $defaultBlockSize);
         $bldgDat = unpack('i*', fread($unitFile, 100));
         if ($bldgDat[7] == 1) {
             $buildingsPresent[$bldgDat[10]]++;
         }
     }
 } else {
     $bldgList = [];
     // check if a parent city exists
     if ($cityDat[29] > 0) {
         fseek($unitFile, $cityDat[29] * $defaultBlockSize);
         $parentDat = unpack('i*', fread($unitFile, 400));
         $bldgList = array_filter(unpack('i*', readSlotData($slotFile, $parentDat[17], 40)));
     }
     foreach ($bldgList as $bldgID) {
         fseek($unitFile, $bldgID * $defaultBlockSize);
         $bldgDat = unpack('i*', fread($unitFile, 100));
         if ($bldgDat[7] == 1) {
             $buildingsPresent[$bldgDat[10]]++;
         }
     }
 }
 $prereqs = explode(',', $bldgType[3]);
 $preCheck = true;
 $buildingsNeeded = [];
 echo 'Buildings Required (' . sizeof($prereqs) / 2 . ')<br>';
 print_r($prereqs);
 echo 'Buildings present:';
Example #9
0
File: 1032.php Project: rwruss/ib3
$credList = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[19], 40)));
$approved = array_search($pGameID, $credList);
if ($approved != false) {
    $credLevel = $credList[$approved - 1] * -1;
} else {
    $credLevel = 0;
}
if ($cityDat[20] == $pGameID) {
    $credLevel = 10;
}
// Determine the character's current rank in the city
fseek($unitFile, $postVals[1] * $defaultBlockSize);
$charDat = unpack('i*', fread($unitFile, $unitBlockSize));
// Get characters current position
print_r($charDat);
$positionList = unpack("i*", readSlotData($slotFile, $charDat[13], 40));
$posIndex = array_search($cityID * -1, $positionList);
print_r($positionList);
$charPosition = 0;
if ($posIndex) {
    $charPosition = $positionList[$posIndex + 1];
}
$promotionList = array('Chief', 'SWBear', 'SHBear', 'Warrior', 'Councilor');
//echo '<script>alert("test");</script>';
echo '<script>
window["saveRank"] = function() {

	setVal = document.getElementById("rankSelect").value;
	//alert("saveRank " + setVal + " for char ' . $postVals[1] . '");
	scrMod("1033,' . $postVals[1] . ',"+setVal);
}
Example #10
0
File: 1042.php Project: rwruss/ib3
<?php

include "./slotFunctions.php";
include "./cityClass.php";
echo 'This is the garrison at the town<br>';
$cityID = $_SESSION['selectedItem'];
// Verify selection is a town
$unitFile = fopen($gamePath . '/unitDat.dat', 'r+b');
fseek($unitFile, $cityID * $defaultBlockSize);
$cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
if ($cityDat[4] == 1) {
    // Verify credentials to view this town
    $slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
    //$credList = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[19], 40)));
    //$approved = array_search($pGameID, $credList);
    $credSlot = new itemSlot($cityDat[19], $slotFile, 40);
    $approved = checkCred($pGameID, $credSlot->slotData);
    // show units or show intelligence for town
    if ($approved) {
        $unitList = array_filter(unpack("N*", readSlotData($slotFile, $cityDat[18], 40)));
        echo 'Show the list';
        print_r($unitList);
        foreach ($unitList as $unitID) {
            echo '<div onclick="makeBox(\'cityMan\', \'1028,' . $unitID . '\', 500, 500, 200, 50);">Unit ' . $unitID . '</div>';
        }
    } else {
        echo 'You are not authorized to view this information';
    }
} else {
    echo 'This is an invalid selection';
}
Example #11
0
File: 1041.php Project: rwruss/ib3
<?php

include "./slotFunctions.php";
echo 'Assign labor to project #' . $postVals[1] . '<br>';
// get project information
$unitFile = fopen($gamePath . '/unitDat.dat', 'r+b');
//$taskFile = fopen($gamePath.'/tasks.tdt', 'r+b');
fseek($unitFile, $postVals[1] * $defaultBlockSize);
$taskDat = unpack('i*', fread($unitFile, $jobBlockSize));
// Verify that the person giving the order has the proper credintials
fseek($unitFile, $taskDat[8] * $defaultBlockSize);
$cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
$slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
$credList = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[19], 40)));
$approved = array_search($pGameID, $credList);
if ($approved) {
    // Get list of labor available at the location of this project
    echo 'List of units available at city #' . $taskDat[8];
    fseek($unitFile, $taskDat[8] * $defaultBlockSize);
    $cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
    $unitsHere = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[18], 40)));
    print_r($unitsHere);
}
fclose($unitFile);
Example #12
0
File: 1049.php Project: rwruss/ib3
            fseek($unitFile, $bldgID * $defaultBlockSize);
            $bldgDat = unpack('i*', fread($unitFile, 100));
            if (${$bldgDat}[5] == $pGameID) {
                if ($bldgDat[7] == 1) {
                    // Building is complete - add to list
                    $buildingsPresent[$bldgDat[10]]++;
                    if ($bldgDat[10] == 1) {
                        $playerRscSlot = $bldgDat[11];
                    }
                } else {
                    $buildingProgress[$bldgDat[10]]++;
                }
            }
        }
        // Load resources available for the player
        $rscDat = unpack("i*", readSlotData($slotFile, ${$playerRscSlot}, 40));
        for ($i = 0; $i < sizeof($rscDat); $i += 2) {
            $cityRsc[$rscDat[$i]] += $rscDat[$i + 1];
        }
    }
    // Compare the list of buildings in the $bldgNames list to what is here and can be constructed.
    echo '<script>
	useDeskTop.newPane("bldgStart");
	thisDiv = useDeskTop.getPane("bldgStart");
	addDiv("test", "reqHolder", thisDiv);';
    $selectedBldg = explode('<-->', $buildingDesc[$postVals[1]]);
    $prereqs = explode(',', $selectedBldg[3]);
    //echo 'Explode '.$buildingDesc[$postVals[1]*7+3].' ('.strlen($buildingDesc[$postVals[1]*7+3]).')';
    //print_r($prereqs);
    $preCheck = true;
    $buildingsNeeded = [];
Example #13
0
    fseek($taskFile, $unitDat[11] * 200);
    $taskDat = unpack('i*', fread($taskFile, 200));
    include '../gameScripts/units/tp_' . $taskDat[5] . '.php';
} else {
    echo 'This unit is not currently working on anything<br>';
}
// Read the data for the current city/army the unit is in
fseek($unitFile, $unitDat[12] * 400);
$homeDat = unpack('i*', fread($unitFile, 400));
if ($homeDat[4] == 1) {
    // unit is based in a city
    echo 'This unit is in a city right now<br>';
    // Get list of tasks available at the home city or the home army
    if ($homeDat[21] != 0) {
        $slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
        $taskList = array_filter(unpack("i*", readSlotData($slotFile, $homeDat[21], 40)));
        echo 'Tasks is slot ' . $homeDat[21] . ' - ' . sizeof($taskList) . '<br>';
        $taskFile = fopen($gamePath . '/tasks.tdt', 'r+b');
        foreach ($taskList as $taskID) {
            fseek($taskFile, $taskID * 200);
            $taskDat = unpack('i*', fread($taskFile, 200));
            $unitAssign = $postVals[1];
            include '../gameScripts/tasks/td_' . $taskDat[5] . '.php';
            echo '<div>Task ' . $taskID . '<br>
				Description of task<br>

				<div onclick="scrMod(\'1043,' . $postVals[1] . ',' . $taskID . '\')">work on task</div></div>';
        }
        fclose($taskFile);
        fclose($slotFile);
    } else {
Example #14
0
File: 1002a.php Project: rwruss/ib3
        $traitAffects = explode(',', $traitItems[$traitID * 2 + 1]);
        echo '<li>' . $traitItems[$traitID * 2];
        echo '<ul>';
        foreach ($traitAffects as $desc) {
            echo '<li>' . $desc;
        }
        echo '</ul>';
    }
    echo '</ul>';
} else {
    echo 'No traits (' . sizeof($traitList) . ')<br>';
}
// Race, Culture, Public Religion and Private Religion (Slots 16, 33, 34)
// Vassal List (Slot 28)
if ($charDat[28] > 0) {
    $LVList = unpack("i*", readSlotData($slotFile, $charDat[28], 40));
    echo 'Lord: ' . $LVList[1] . ' with a title of ' . $LVList[2] . '<br>';
    $vassalList = array_filter(array_slice($LVList, 2));
    $numVassals = sizeof($vassalList);
    if ($numVassals > 0) {
        for ($i = 0; $i < $numVassals; $i++) {
            if ($vassalList[$i] < 0) {
                echo 'Title: ' . $vassalList[$i] . '<br>';
            } else {
                echo 'Vassal: ' . $vassalList[$i] . '<br>';
            }
        }
    }
} else {
    echo 'No lord or vassals<br>';
}
Example #15
0
File: 1029.php Project: rwruss/ib3
<?php

// Show current tasks/projects in the city
include "./slotFunctions.php";
// verify that user is ok to view this info
$cityID = $_SESSION['selectedItem'];
// Verify that the person giving the order has the proper credintials
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
fseek($unitFile, $cityID * $defaultBlockSize);
$cityDat = unpack('i*', fread($unitFile, $unitBlockSize));
//print_r($cityDat);
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
//$taskFile = fopen($gamePath.'/tasks.tdt', 'rb');
$credList = array_filter(unpack("i*", readSlotData($slotFile, $cityDat[19], 40)));
$approved = array_search($pGameID, $credList);
//echo 'Approved level '.$approved.'<br>';
echo '<script>
useDeskTop.newPane("tasks");
thisDiv = useDeskTop.getPane("tasks");';
if ($approved) {
    // Read the block data for the projects in progress
    if ($cityDat[21] > 0) {
        //echo 'Project slot is '.$cityDat[21];
        $taskList = new itemSlot($cityDat[21], $slotFile, 40);
        $taskSize = sizeof($taskList->slotData);
        $taskFile = fopen($gamePath . '/tasks.tdt', 'rb');
        //echo '<div id="incomplete" style="width:100%; display:inline"></div>';
        for ($i = 1; $i <= $taskSize; $i++) {
            if ($taskList->slotData[$i] > 0) {
                fseek($taskFile, $taskList->slotData[$i] * $jobBlockSize);
                $taskDtl = unpack('i*', fread($taskFile, $jobBlockSize));
Example #16
0
<?php

include "./slotFunctions.php";
include "./unitClass.php";
echo 'This is a battle that is waiting to take place';
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
// Load list of units that the player controls
$playerObj = new player($pGameID, $unitFile, 400);
$unitList = array_filter(unpack("i*", readSlotData($slotFile, $playerObj->get('unitSlot'), 40)));
$matchedSide = 0;
// Look for units that the player controls to determine which side they are on
$sideA = new itemSlot($unitDat[15], $slotFile, 40);
$sideB = new itemSlot($unitDat[16], $slotFile, 40);
fclose($slotFile);
for ($i = 1; $i <= sizeof($unitList->slotData); $i++) {
    if (array_search($unitList->slotData[$i], $sideA->slotData)) {
        $matchedSide = 1;
    } else {
        if (array_search($unitList->slotData[$i], $sideB->slotData)) {
            $matchedSide = 2;
        }
    }
}
// Get information on the wars
for ($i = 0; $i <= 5; $i++) {
    fseek($unitFile, $unitDat[17 + $i] * $defaultBlockSize);
    $warDat = unpack('i*', fread($unitFile, 200));
    echo 'War #' . $unitDat[17 + $i] . '<br>';
}
echo '<div style="position:absolute; bottom:0; left:0;" onclick="scrMod(1094,' . $unitID . ');">Battle Detail</div>';
Example #17
0
File: 1045.php Project: rwruss/ib3
     break;
     // end case 4
 // end case 4
 case 5:
     // An agent
     echo 'Collision with agent ' . $collisionID . '<br>';
     break;
     // end case 5
 // end case 5
 case 6:
     // A warband
     echo 'Collision with warband ' . $collisionID . '<br>';
     // Load the war list for the unit
     fseek($unitFile, $foundList[$collisionID][2] * $defaultBlockSize);
     $trgPlayerData = unpack('i*', fread($unitFile, $unitBlockSize));
     $trgWarList = array_filter(unpack("i*", readSlotData($datSlotFile, $trgPlayerData[32], 40)));
     $collisionList[$collisionID] = 1;
     if (sizeof($trgWarList) > sizeof($myWarList)) {
         $foundWars = compareWarLists($myWarList, $trgWarList);
     } else {
         $foundWars = compareWarLists($trgWarList, $myWarList);
     }
     if (sizeof($foundWars) > 0) {
         // Start a battle at this location.  This will affect all of the common wars found.
         $battleID = startNewBattle($postVals[1], $collisionID, $unitFile);
         // Record battle ID for each unit
         fseek($unitFile, $postVals[1] * $defaultBlockSize + 120);
         fwrite($unitFile, pack('i', $battleID));
         fseek($unitFile, $collisionID * $defaultBlockSize + 120);
         fwrite($unitFile, pack('i', $battleID));
         goto endMove;