Beispiel #1
0
</h1>
<div class="tabber" id="t"><a name="top"></a> <!--Seeding Tab-->
<div class="tabbertab">
<h2>Crops</h2>
<table>
	<tr>
		<td colspan=3>
		<table style="text-align: left;" width="100%" class="crops">
			<tbody>
				<tr>
					<td class="crops" width="100%" colspan="6" rowspan="1"
						style="vertical-align: top;"><?php 
//$seedCnt = $fvM->fsItemCounts('seed');
$plotCnt = count(GetObjects('Plot'));
$seedCnt = 0;
foreach (GetObjects('Plot') as $plot) {
    if ($plot['state'] == 'planted') {
        $newplot[$plot['itemName']][number_format($plot['plantTime'], 0, '', '')]++;
        $seedCnt++;
    }
}
@($plotCnt = $plotCnt - $seedCnt);
?>
 <big><b>Crops: </b><?php 
echo $seedCnt;
?>
 - <b>Empty Plots: </b><?php 
echo $plotCnt;
?>
</big></td>
				</tr>
 private function _fvUpdateWorldDB()
 {
     AddLog2('fvManager is updating the Farmville World');
     if ($this->haveWorld === false) {
         return;
     }
     $this->_fvManagerDBW->queryExec('DELETE FROM myworld');
     $this->_fvManagerDBW->queryExec('BEGIN TRANSACTION;');
     foreach (GetObjects() as $world) {
         $result = Units_GetUnitByName($world['itemName']);
         if (@$result['type'] == 'seed') {
             $kresult = Units_GetUnitByName($world['itemName'] . 'bushel');
             if (isset($kresult['code'])) {
                 $this->keepbushel[$kresult['code']] = 1;
             }
         }
         //Get Recipes that are available;
         if (isset($world['recipeQueue'])) {
             $this->recipe[$world['id']] = $world['recipeQueue'];
             $this->recipe[$world['id']]['craftLevel'] = $world['craftLevel'];
         }
         if (isset($world['contents'])) {
             $this->building[$world['id']] = array('itemName' => $world['itemName'], 'contents' => $world['contents']);
         }
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $result['sizeX'] = @$result['sizeX'] < 1 ? 1 : @$result['sizeX'];
         $result['sizeY'] = @$result['sizeY'] < 1 ? 1 : @$result['sizeY'];
         $mfvSQL = "INSERT INTO myworld(myworld_id, myworld_className, myworld_itemName, myworld_itemRealName, myworld_iconURL,  myworld_itemCode, myworld_direction, myworld_sizex, myworld_sizey, myworld_posx, myworld_posy, myworld_type, myworld_plantTime, myworld_state, myworld_canWander, myworld_usesAltGraphic, myworld_giftSenderId, myworld_explicitType, myworld_expansionLevel)\n\t\t\t\t\t\t\tvalues(" . $world['id'] . ",'" . @$world['className'] . "', '" . @$world['itemName'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . @$result['code'] . "', '" . @$world['direction'] . "', '" . @$result['sizeX'] . "', '" . @$result['sizeY'] . "', '" . $world['position']['x'] . "','" . $world['position']['y'] . "','" . @$result['type'] . "','" . @$world['plantTime'] . "','" . @$world['state'] . "','" . @$world['canWander'] . "','" . @$world['usesAltGraphic'] . "','" . @$world['giftSenderId'] . "','" . @$world['_explicitType'] . "',' " . @$world['expansionLevel'] . "');";
         $this->_fvManagerDBW->queryExec($mfvSQL, $error);
         if (!empty($error)) {
             AddLog2($error);
         }
     }
     $this->_fvManagerDBW->queryExec('COMMIT TRANSACTION;');
     save_array($this->recipe, 'recipe.txt');
     $this->_fvManagerDBW->queryExec('DELETE FROM storage');
     $this->_fvManagerDBW->queryExec('BEGIN;');
     //Get Storage Box Items
     if ($this->settings['debug'] == 1) {
         AddLog2('Updating Storage Box');
     }
     foreach ($this->stBox as $key => $sbox) {
         $cl = explode(':', $key);
         if (!empty($cl[0])) {
             $result = Units_GetUnitByCode($cl[0]);
         } else {
             $result = Units_GetUnitByCode($key);
         }
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $gfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL,  storage_itemCode, storage_type, storage_itemCount, storage_id)\n\t\t\t\t\t\tvalues('" . @$result['className'] . "', '" . @$result['name'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . $key . "','" . @$result['type'] . "','" . $sbox[0] . "','-2');";
         $this->_fvManagerDBW->queryExec($gfvSQL);
     }
     //Get Giftbox Items
     if ($this->settings['debug'] == 1) {
         AddLog2('Updating Giftbox');
     }
     foreach ($this->giftBox as $key => $gbox) {
         $result = Units_GetUnitByCode($key);
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $gfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL, storage_itemCode, storage_type, storage_itemCount, storage_id)\n\t\t\t\t\t\t\tvalues('" . @$result['className'] . "', '" . @$result['name'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . $key . "','" . @$result['type'] . "','" . $gbox[0] . "','-1');";
         $this->_fvManagerDBW->queryExec($gfvSQL);
     }
     //Get Consumable Box Items
     if ($this->settings['debug'] == 1) {
         AddLog2('Updating Consumable Box');
     }
     foreach ($this->conBox as $key => $cbox) {
         $result = Units_GetUnitByCode($key);
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $gfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL, storage_itemCode, storage_type, storage_itemCount, storage_id)\n\t\t\t\t\tvalues('" . @$result['className'] . "', '" . @$result['name'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . $key . "','" . @$result['type'] . "','" . $cbox[0] . "','-6');";
         $this->_fvManagerDBW->queryExec($gfvSQL);
     }
     //Get Other Stored Items
     if ($this->settings['debug'] == 1) {
         AddLog2('Updating Other Stored Items');
     }
     foreach ($this->building as $key => $items) {
         foreach ($items['contents'] as $cont) {
             $uinfo = Units_GetUnitByCode($cont['itemCode']);
             $uinfo['realname'] = str_replace("'", "''", @$uinfo['realname']);
             $bfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL, storage_itemCode, storage_type, storage_itemCount, storage_id, storage_itemExtra)\n\t\t\t\t\tvalues('" . @$uinfo['className'] . "', '" . @$uinfo['name'] . "', '" . @$uinfo['realname'] . "', '" . @$uinfo['iconurl'] . "', '" . $cont['itemCode'] . "', '" . @$uinfo['type'] . "', '" . @$cont['numItem'] . "', {$key}, '" . @$cont['numParts'] . "');";
             $this->_fvManagerDBW->queryExec($bfvSQL);
         }
     }
     $this->_fvManagerDBW->queryExec('COMMIT;');
     $this->_fvManagerDBW->queryExec('DELETE FROM fmarket');
     $this->_fvManagerDBW->queryExec('BEGIN;');
     if ($this->settings['debug'] == 1) {
         AddLog2('Updating Crafts');
     }
     foreach ($this->fmCraft as $key => $FMarket) {
         $cl = explode(':', $key);
         $result = Units_GetUnitByCode($cl[0]);
         $result['realname'] = $result['realname'] . ' (Level ' . $cl[1] . ')';
         $result['realname'] = str_replace("'", "''", $result['realname']);
         $gfvSQL = "INSERT INTO fmarket(fmarket_className, fmarket_itemName, fmarket_itemRealName, fmarket_iconURL,  fmarket_itemCode, fmarket_type, fmarket_itemCount)\n\t\t\t\t\t\t\tvalues('" . @$result['className'] . "', '" . @$result['name'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . $key . "','" . @$result['type'] . "','" . $FMarket[0] . "');";
         $this->_fvManagerDBW->queryExec($gfvSQL);
     }
     $this->_fvManagerDBW->queryExec('COMMIT;');
     $this->_fvManagerDBW->queryExec('DELETE FROM fmbushels');
     $this->_fvManagerDBW->queryExec('BEGIN;');
     if ($this->settings['debug'] == 1) {
         AddLog2('Updating Bushels');
     }
     foreach ($this->fmBushels as $key => $FMBushels) {
         $result = Units_GetUnitByCode($FMBushels['itemCode']);
         $result['realname'] = str_replace("'", "''", $result['realname']);
         $gfvSQL = "INSERT INTO fmbushels(fmbushels_className, fmbushels_itemName, fmbushels_itemRealName, fmbushels_iconURL,  fmbushels_itemCode, fmbushels_type, fmbushels_itemCount)\n\t\t\t\t\t\t\tvalues('" . @$result['className'] . "', '" . @$result['name'] . "', '" . @$result['realname'] . "', '" . $result['iconurl'] . "', '" . $FMBushels['itemCode'] . "','" . @$result['type'] . "','" . $FMBushels['quantity'] . "');";
         $this->_fvManagerDBW->queryExec($gfvSQL);
     }
     $this->_fvManagerDBW->queryExec('COMMIT;');
     //Database Cleanup Routine
     if (!isset($this->settings['lastclean']) || time() - (int) $this->settings['lastclean'] >= 14400) {
         $iguser = array();
         save_array($iguser, 'ignores.txt');
         AddLog2('fvManager is doing DB Cleanup');
         $this->_fvManagerDBM->query('vacuum');
         $this->_fvManagerDBU->query('vacuum');
         $this->_fvManagerDBW->query('vacuum');
         $fvSQL = "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('lastclean','" . time() . "')";
         $this->_fvManagerDBM->queryExec($fvSQL);
     }
     $this->_fvCreateMap();
     $this->_fvGetEmptySpots();
     $fvSQL = "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('freespace','" . $this->freespace . "');";
     $fvSQL .= "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('goodState','" . serialize($this->fmGoodState) . "');";
     $this->_fvManagerDBM->queryExec($fvSQL);
     AddLog2('fvManager has finished updating the Farmville World');
 }
 private function _fsUpdateWorldDB()
 {
     AddLog2('FarmStats is updating the Farmville World');
     $this->_fsManagerDBW->queryExec('DELETE FROM myworld');
     $this->_fsManagerDBW->queryExec('BEGIN;');
     foreach (GetObjects() as $world) {
         $result = Units_GetUnitByName($world['itemName']);
         //Get Recipes that are available;
         if (isset($world['recipeQueue'])) {
             $this->recipe[$world['id']] = $world['recipeQueue'];
             $this->recipe[$world['id']]['craftLevel'] = $world['craftLevel'];
         }
         if (isset($world['contents'])) {
             $this->building[$world['id']] = array('itemName' => $world['itemName'], 'contents' => $world['contents']);
         }
         $world['message'] = str_replace("'", "''", @$world['message']);
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $result['sizeX'] = @$result['sizeX'] < 1 ? 1 : @$result['sizeX'];
         $result['sizeY'] = @$result['sizeY'] < 1 ? 1 : @$result['sizeY'];
         $mfvSQL = "INSERT INTO myworld(myworld_id, myworld_className, myworld_itemName, myworld_itemRealName, myworld_iconURL,  myworld_itemCode, myworld_direction, myworld_sizex, myworld_sizey, myworld_posx, myworld_posy, myworld_type, myworld_plantTime, myworld_state, myworld_canWander, myworld_usesAltGraphic, myworld_giftSenderId, myworld_explicitType, myworld_expansionLevel, myworld_message)\n\t\t\t\t\t\t\tvalues(" . $world['id'] . ",'" . @$world['className'] . "', '" . $world['itemName'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . @$result['code'] . "', '" . @$world['direction'] . "', '" . @$result['sizeX'] . "', '" . @$result['sizeY'] . "', '" . @$world['position']['x'] . "','" . @$world['position']['y'] . "','" . @$result['type'] . "','" . @$world['plantTime'] . "','" . @$world['state'] . "','" . @$world['canWander'] . "','" . @$world['usesAltGraphic'] . "','" . @$world['giftSenderId'] . "','" . @$world['_explicitType'] . "',' " . @$world['expansionLevel'] . "','" . @$world['message'] . "');";
         $this->_fsManagerDBW->queryExec($mfvSQL, $error);
         if (!empty($error)) {
             AddLog2($error);
         }
     }
     $this->_fsManagerDBW->queryExec('COMMIT;');
     $this->_fsManagerDBW->queryExec('DELETE FROM storage');
     $this->_fsManagerDBW->queryExec('BEGIN;');
     //Get Storage Box Items
     $this->stBox = unserialize(fBGetDataStore('instorage'));
     foreach ($this->stBox as $key => $sbox) {
         if (strpos($key, ':')) {
             $key = substr($key, 0, strpos($key, ':'));
         }
         $result = Units_GetUnitByCode($key);
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $gfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL,  storage_itemCode, storage_type, storage_itemCount, storage_id)\n\t\t\t\t\t\tvalues('" . @$result['className'] . "', '" . $result['name'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . $key . "','" . @$result['type'] . "','" . $sbox . "','-2');";
         $this->_fsManagerDBW->queryExec($gfvSQL);
     }
     //Get Giftbox Items
     $this->giftBox = unserialize(fBGetDataStore('ingiftbox'));
     foreach ($this->giftBox as $key => $gbox) {
         if (strpos($key, ':')) {
             $key = substr($key, 0, strpos($key, ':'));
         }
         $result = Units_GetUnitByCode($key);
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $gfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL, storage_itemCode, storage_type, storage_itemCount, storage_id)\n\t\t\t\t\t\t\tvalues('" . @$result['className'] . "', '" . @$result['name'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . $key . "','" . @$result['type'] . "','" . $gbox . "','-1');";
         $this->_fsManagerDBW->queryExec($gfvSQL);
     }
     //Get Consumable Box Items
     $this->conBox = unserialize(fBGetDataStore('inconbox'));
     foreach ($this->conBox as $key => $cbox) {
         $result = Units_GetUnitByCode($key);
         $result['realname'] = str_replace("'", "''", @$result['realname']);
         $gfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL, storage_itemCode, storage_type, storage_itemCount, storage_id)\n\t\t\t\t\tvalues('" . @$result['className'] . "', '" . @$result['name'] . "', '" . @$result['realname'] . "', '" . @$result['iconurl'] . "', '" . $key . "','" . @$result['type'] . "','" . $cbox . "','-6');";
         $this->_fsManagerDBW->queryExec($gfvSQL);
     }
     //Get Other Stored Items
     foreach ($this->building as $key => $items) {
         foreach ($items['contents'] as $cont) {
             $uinfo = $this->fsGetUnits($cont['itemCode']);
             $uinfo['realname'] = str_replace("'", "''", $uinfo['realname']);
             $bfvSQL = "INSERT INTO storage(storage_className, storage_itemName, storage_itemRealName, storage_iconURL, storage_itemCode, storage_type, storage_itemCount, storage_id, storage_itemExtra)\n\t\t\t\t\tvalues('" . @$uinfo['className'] . "', '" . @$uinfo['name'] . "', '" . @$uinfo['realname'] . "', '" . @$uinfo['iconurl'] . "', '" . $cont['itemCode'] . "', '" . @$uinfo['type'] . "', '" . @$cont['numItem'] . "', {$key}, '" . @$cont['numParts'] . "');";
             $this->_fsManagerDBW->queryExec($bfvSQL);
         }
     }
     $this->_fsManagerDBW->queryExec('COMMIT;');
     //Database Cleanup Routine
     if (!isset($this->settings['lastclean']) || time() - (int) $this->settings['lastclean'] >= 21600) {
         AddLog2('FarmStats is doing DB Cleanup');
         $this->_fsManagerDBM->query('vacuum');
         $this->_fsManagerDBW->query('vacuum');
         $fvSQL = "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('lastclean','" . time() . "')";
         $this->_fsManagerDBM->queryExec($fvSQL);
     }
     $this->_fsGetEmptySpots();
     $fvSQL = "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('freespace','" . $this->freespace . "')";
     $this->_fsManagerDBM->queryExec($fvSQL);
     $fvSQL = "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('goodState','" . serialize($this->fmGoodState) . "')";
     $this->_fsManagerDBM->queryExec($fvSQL);
     AddLog2('FarmStats has finished updating the Farmville World');
 }
Beispiel #4
0
function Sections_plant_sections()
{
    global $need_reload;
    $enable_seed = true;
    echo "Sections v", sections_Version, " >> plant_sections\r\n";
    $sections = load_array('sections.txt');
    if (!(is_array($sections) && count($sections))) {
        return;
    }
    #return;  // uncomment to disable for debug purposes
    if ($need_reload) {
        $res = DoInit();
        //reload farm
        $need_reload = false;
    }
    #  $units = @unserialize(file_get_contents(F('units.txt')));
    $objects = @unserialize(fBGetDataStore('objects'));
    list($level, $gold, $cash, $sizeX, $sizeY, $firstname, $locale, $tileset, $wither, $xp, $energy, $flashRevision) = explode(';', fBGetDataStore('playerinfo'));
    // Build matrix so we can know which locations are empty
    $location_empty = array();
    for ($x = 0; $x < $sizeX; $x++) {
        for ($y = 0; $y < $sizeY; $y++) {
            $location_empty[$x][$y] = true;
        }
    }
    foreach ($objects as $o) {
        #    $u = $units[$o['itemName']];
        $u = Units_GetUnitByName($o['itemName']);
        if (!isset($u['sizeX'])) {
            $u['sizeX'] = 1;
            $u['sizeY'] = 1;
        }
        if ($o['state'] == 'vertical') {
            $t = $u['sizeX'];
            $u['sizeX'] = $u['sizeY'];
            $u['sizeY'] = $t;
        }
        for ($x = 0; $x < $u['sizeX']; $x++) {
            for ($y = 0; $y < $u['sizeY']; $y++) {
                $location_empty[$o['position']['x'] + $x][$o['position']['y'] + $y] = false;
            }
        }
    }
    foreach ($sections as $section) {
        if ($section['active'] == '1' && $section['place'] == '1' && $section['type'] == 'seed') {
            $u['sizeX'] = 4;
            $u['sizeY'] = 4;
            while ($newpos = Sections_Find_Free_Location_Buy($section, $u, $location_empty)) {
                unset($vPlot);
                $vPlot['itemName'] = null;
                $vPlot['isProduceItem'] = false;
                $vPlot['isBigPlot'] = false;
                $vPlot['direction'] = 0;
                $vPlot['plantTime'] = 'NaN';
                $vPlot['deleted'] = false;
                $vPlot['isJumbo'] = false;
                $vPlot['state'] = 'plowed';
                $vPlot['tempId'] = -1;
                $vPlot['id'] = 0;
                $vPlot['className'] = 'Plot';
                $vPlot['position']['z'] = 0;
                $vPlot['position']['x'] = (int) $newpos['x'];
                $vPlot['position']['y'] = (int) $newpos['y'];
                $tractor_plots[] = $vPlot;
                for ($x = 0; $x < $u['sizeX']; $x++) {
                    for ($y = 0; $y < $u['sizeY']; $y++) {
                        $location_empty[$newpos['x'] + $x][$newpos['y'] + $y] = false;
                    }
                }
            }
        }
    }
    if (isset($tractor_plots) && count($tractor_plots) > 0) {
        $result = Do_Farm_Work_Plots($tractor_plots, 'tractor');
        $need_reload = $need_reload || $result;
    }
    // Below mostly copied from parser.php with adaptions
    if ($need_reload) {
        $res = DoInit();
        //reload farm
        $need_reload = false;
    }
    if ($enable_seed) {
        $plots = GetObjects('Plot');
        //Find empty plots
        $plowed_plots = array();
        foreach ($plots as $plowed_key => $plot) {
            if ($plot['state'] == 'plowed') {
                $plowed_plots[] = $plot;
            }
        }
        $seed_plots = array();
        foreach ($plowed_plots as $plot) {
            $itemName = "";
            $px = floor($plot['position']['x'] / 4);
            $py = floor($plot['position']['y'] / 4);
            $npx = $plot['position']['x'];
            $npy = $plot['position']['y'];
            foreach ($sections as $section) {
                if ($section['active'] == '1' && $section['type'] == 'seed' && $section['seed'] != 'just_plow' && $section['seed'] != '---' && $npx >= $section['bot_x'] && $npx <= $section['top_x'] && $npy >= $section['bot_y'] && $npy <= $section['top_y']) {
                    // found the section
                    switch ($section['pat']) {
                        case 'checkerboard':
                            $itemName = ($px + $py) % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'striped-row':
                            $itemName = $py % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'striped-col':
                            $itemName = $px % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'squared1':
                            $itemName = $px % 2 == 1 || $py % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'squared2':
                            $itemName = $px % 2 == 1 || $py % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-w':
                            $itemName = $px % 2 == 1 && $px >= $py || $py % 2 == 1 && $py >= $px ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-e':
                            $itemName = $px % 2 == 1 && $px <= $py || $py % 2 == 1 && $py <= $px ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-n':
                            $sz_x = floor(($section['top_x'] - $section['bot_x']) / 4);
                            $itemName = $px % 2 == 1 && $sz_x - $px <= $py || $py % 2 == 1 && $py <= $sz_x - $px ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-s':
                            $sz_x = floor(($section['top_x'] - $section['bot_x']) / 4);
                            $itemName = $px % 2 == 1 && $sz_x - $px >= $py || $py % 2 == 1 && $py <= $sz_x - $px ? $section['seed'] : $section['seed2'];
                            break;
                        default:
                            $itemName = $section['seed'];
                    }
                }
            }
            if (strlen($itemName) > 0) {
                $plot['itemName'] = $itemName;
                $seed_plots[] = $plot;
                #      } else {
                #        echo GetPlotName($plot) . " not in a section.";
            }
        }
        if (count($seed_plots) > 0) {
            Do_Farm_Work_Plots($seed_plots, 'place');
            //plant crops
        }
        unset($seed_plots, $plowed_plots);
    }
}
 function fvBestVehicles()
 {
     $garage = GetObjects('GarageBuilding');
     //get vehicles in the garage
     if (count($garage) != 0) {
         foreach ($garage[0]['contents'] as $vehicle) {
             $vUnits = Units_GetUnitByCode($vehicle['itemCode']);
             @($veh[$vUnits['className']][$vehicle['itemCode']] = !isset($veh[$vUnits['className']][$vehicle['itemCode']]) || $veh[$vUnits['className']][$vehicle['itemCode']] >= $vehicle['numParts'] ? $vehicle['numParts'] : $veh[$vUnits['className']][$vehicle['itemCode']]);
         }
     }
     //get vehicles on the farm
     $harvesters = GetObjects('Harvester');
     foreach ($harvesters as $harv) {
         $hUnits = Units_GetUnitByName($harv['itemName']);
         @($veh[$harv['className']][$hUnits['code']] = !isset($veh[$harv['className']][$hUnits['code']]) || $veh[$harv['className']][$hUnits['code']] >= $harv['m_equipmentPartsCount'] ? $harv['m_equipmentPartsCount'] : $veh[$harv['className']][$hUnits['code']]);
     }
     $tractors = GetObjects('Tractor');
     foreach ($tractors as $tract) {
         $tUnits = Units_GetUnitByName($tract['itemName']);
         @($veh[$tract['className']][$tUnits['code']] = !isset($veh[$tract['className']][$tUnits['code']]) || $veh[$tract['className']][$tUnits['code']] >= $tract['m_equipmentPartsCount'] ? $tract['m_equipmentPartsCount'] : $veh[$tract['className']][$tUnits['code']]);
     }
     $seeders = GetObjects('Seeder');
     foreach ($seeders as $seed) {
         $sUnits = Units_GetUnitByName($seed['itemName']);
         @($veh[$seed['className']][$sUnits['code']] = !isset($veh[$seed['className']][$sUnits['code']]) || $veh[$seed['className']][$sUnits['code']] >= $seed['m_equipmentPartsCount'] ? $seed['m_equipmentPartsCount'] : $veh[$seed['className']][$sUnits['code']]);
     }
     $combines = GetObjects('Combine');
     foreach ($combines as $comb) {
         $cUnits = Units_GetUnitByName($comb['itemName']);
         @($veh[$comb['className']][$cUnits['code']] = !isset($veh[$comb['className']][$cUnits['code']]) || $veh[$comb['className']][$cUnits['code']] >= $comb['m_equipmentPartsCount'] ? $comb['m_equipmentPartsCount'] : $veh[$comb['className']][$cUnits['code']]);
     }
     unset($combines, $seeders, $tractors, $harvesters, $garage);
     //Get best Harvester
     $harvcount = 0;
     if (is_array($veh['Harvester'])) {
         foreach ($veh['Harvester'] as $key => $parts) {
             if ($parts >= $harvcount) {
                 $harvcount = $parts;
                 $numPlots = 1;
                 $numPlots = $parts >= 2 ? 6 : $numPlots;
                 $numPlots = $parts >= 7 ? 9 : $numPlots;
                 $numPlots = $parts >= 17 ? 12 : $numPlots;
                 $numPlots = $parts == 32 ? 16 : $numPlots;
                 $this->bHarvester = array('itemCode' => $key, 'numParts' => $parts, 'numPlots' => $numPlots);
             }
         }
     }
     //Get Best Tractor
     $harvcount = 0;
     if (is_array($veh['Tractor'])) {
         foreach ($veh['Tractor'] as $key => $parts) {
             if ($parts >= $harvcount) {
                 $harvcount = $parts;
                 $numPlots = 1;
                 $numPlots = $parts >= 2 ? 6 : $numPlots;
                 $numPlots = $parts >= 7 ? 9 : $numPlots;
                 $numPlots = $parts >= 17 ? 12 : $numPlots;
                 $numPlots = $parts == 32 ? 16 : $numPlots;
                 $this->bTractor = array('itemCode' => $key, 'numParts' => $parts, 'numPlots' => $numPlots);
             }
         }
     }
     //Get Best Seeder
     $harvcount = 0;
     if (is_array($veh['Seeder'])) {
         foreach ($veh['Seeder'] as $key => $parts) {
             if ($parts >= $harvcount) {
                 $harvcount = $parts;
                 $numPlots = 1;
                 $numPlots = $parts >= 2 ? 6 : $numPlots;
                 $numPlots = $parts >= 7 ? 9 : $numPlots;
                 $numPlots = $parts >= 17 ? 12 : $numPlots;
                 $numPlots = $parts == 32 ? 16 : $numPlots;
                 $this->bSeeder = array('itemCode' => $key, 'numParts' => $parts, 'numPlots' => $numPlots);
             }
         }
     }
     //Get Best Combine
     $harvcount = 0;
     if (is_array(@$veh['Combine'])) {
         foreach ($veh['Combine'] as $key => $parts) {
             if ($parts >= $harvcount) {
                 $harvcount = $parts;
                 $this->bCombine = array('itemCode' => $key, 'numParts' => $parts);
             }
         }
     }
 }
Beispiel #6
0
function loadObjects()
{
    return GetObjects();
}
Beispiel #7
0
 private function _fvFarmLimits()
 {
     //Go Through All Objects on the Farm and Get Counts for Items
     foreach (GetObjects() as $object) {
         if ($object['className'] != 'MysterySeedling') {
             $uCode = Units_GetCodeByName($object['itemName']);
             if (isset($this->fbFarmLims[$uCode])) {
                 @$items[$uCode]['count']++;
                 @($items[$uCode]['object'][] = $object);
             }
         } else {
             $uCode = Units_GetNameByCode($object['seedType']);
             if (isset($this->fbFarmLims['tree_' . $object['seedType']])) {
                 @$items['tree_' . $object['seedType']]['count']++;
                 @($items['tree_' . $object['seedType']]['object'][] = $object);
             }
         }
     }
     if (empty($items)) {
         return;
     }
     AddLog2('fvTools: Applying Farm Limits');
     foreach ($items as $key => $item) {
         if ($this->fbFarmLims[$key] < $item['count']) {
             array_splice($item['object'], $item['count'] - $this->fbFarmLims[$key]);
             if (!empty($item['object'])) {
                 foreach ($item['object'] as $object) {
                     $newitems[] = $object;
                 }
             }
         }
     }
     $amfcount = 0;
     $amf = '';
     foreach ($newitems as $object) {
         $amf = $this->_fvCreateMultAMFRequest($amf, $amfcount, 'sell', 'WorldService.performAction');
         $amf->_bodys[0]->_value[1][$amfcount]['params'][1] = $object;
         $amf->_bodys[0]->_value[1][$amfcount]['params'][2] = array();
         $realname = Units_GetRealnameByName($object['itemName']);
         $tmpArray[$amfcount]['realname'] = $realname;
         if ($amfcount < $this->botspeed - 1) {
             $amfcount++;
             continue;
         }
         $amf2 = $this->_fvAMFSend($amf);
         $amf = '';
         $amfcount = 0;
         if ($amf2 === false) {
             DoInit();
             continue;
         }
         foreach ($amf2->_bodys[0]->_value['data'] as $key => $returned) {
             $resp = $returned['errorType'];
             $err = $returned['errorData'];
             if ($resp == 0) {
                 AddLog2('[' . $key . '] Sold: ' . $tmpArray[$key]['realname'] . ' - Result: ' . $this->zErrCGen[$resp]);
             } else {
                 AddLog2('fvTools Error: ' . $tmpArray[$key]['realname'] . " Code: " . $resp . ' - ' . $err);
             }
         }
         if ($this->reload === true) {
             DoInit();
             $this->reload = false;
         }
     }
     if (!empty($amf)) {
         $amf2 = $this->_fvAMFSend($amf);
         if ($amf2 === false) {
             continue;
         }
         foreach ($amf2->_bodys[0]->_value['data'] as $key => $returned) {
             $resp = $returned['errorType'];
             $err = $returned['errorData'];
             if ($resp == 0) {
                 AddLog2('[' . $key . '] Sold: ' . $tmpArray[$key]['realname'] . ' - Result: ' . $this->zErrCGen[$resp]);
             } else {
                 AddLog2('fvTools Error: ' . $tmpArray[$key]['realname'] . " Code: " . $resp . ' - ' . $err);
             }
         }
         if ($this->reload === true) {
             DoInit();
             $this->reload = false;
         }
     }
 }