Пример #1
0
                     continue;
                 }
                 $seedc = Units_GetCodeByName($req2['@attributes']['name']);
                 if ($req2['@attributes']['name'] == $seed['name']) {
                     echo '(Hybrid) ';
                 }
                 @($mastered = $maststar[$seedc] == $req2['@attributes']['level'] ? ' - <font color="green"><b>Mastered</b></font>' : '');
                 echo Units_GetRealnameByName($req2['@attributes']['name']) . $mastered . '<br />';
             }
         }
         if (isset($req['requirement'])) {
             foreach ($req as $req2) {
                 if ($req2['@attributes']['className'] == 'SeedPackage') {
                     continue;
                 }
                 $seedc = Units_GetCodeByName($req2['@attributes']['name']);
                 @($mastered = $maststar[$seedc] == $req2['@attributes']['level'] ? ' - <font color="green"><b>Mastered</b></font>' : '');
                 echo Units_GetRealnameByName($req2['@attributes']['name']) . $mastered . '<br />';
             }
         }
     }
 } else {
     echo '&nbsp;';
 }
 echo '</small></td>';
 // ******************** START Override and Default cell*************************
 echo '<td width="70" align="center"><div style="position:relative;z-index:1; text-align:left;">';
 // ******************** Override DIV content *************************
 echo '<div id="' . $seed['realname'] . 'OverNoMastery" class="doOverride" style="display:none;">';
 echo '<div><b>Override seed:<br />' . $seed['realname'] . '</b></div>';
 echo '<form method="post">';
Пример #2
0
function Grifter_TurboSell($name, $x)
{
    Addlog2('selling ' . $name . ' : ' . $x . ' times');
    $vSpeed = 8;
    $Code = Units_GetCodeByName($name);
    unset($GLOBALS['amfphp']['encoding']);
    $vRunMainLoop = ceil($x / $vSpeed);
    for ($vI = 0; $vI < $vRunMainLoop; $vI++) {
        $vNumAction = 0;
        for ($vJ = $vI * $vSpeed; $vJ < $vI * $vSpeed + $vSpeed && $vJ < $x; $vJ++) {
            @($amf = CreateMultAMFRequest($amf, $vNumAction, '', 'UserService.sellStoredItem'));
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][0]['code'] = $Code;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][1] = false;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2] = -1;
            $vNumAction++;
        }
        $res = RequestAMF($amf);
        if ($res == 'OK') {
            Addlog2(" result {$res}");
        } else {
            AddLog2("GiftBox: Error - " . $res);
            return $res;
        }
    }
    return $res;
}
Пример #3
0
 function fvPlantPlots()
 {
     AddLog2('fvFarmer: Planting Plots');
     $plots = array();
     foreach (GetObjects('Plot') as $plot) {
         if ($plot['state'] == 'plowed') {
             $plots[] = $plot;
         }
     }
     if (empty($plots)) {
         return;
     }
     $seed_plots = array();
     //Plant Overrides
     if (is_array($this->overrides) && !empty($this->overrides)) {
         foreach ($this->overrides as $key1 => $orSeed) {
             if ($orSeed[2] > 0) {
                 for ($x = 0; $x < $orSeed[2]; $x++) {
                     if (empty($plots)) {
                         break;
                     }
                     $tmpplot = array_pop($plots);
                     $tmpplot['itemName'] = $orSeed[0];
                     $seed_plots[] = $tmpplot;
                     $this->overrides[$key1][2]--;
                 }
                 if ($this->overrides[$key1][2] == 0 && $this->overrides[$key1][1] != 1) {
                     unset($this->overrides[$key1]);
                 }
             }
         }
         file_put_contents($_SESSION['base_path'] . F('overrideseed.txt'), serialize($this->overrides));
     }
     if (!empty($plots) && $this->settings['automast'] == 1) {
         $maststar = unserialize(fBGetDataStore('cropmasterycnt'));
         $this->settings['masteryorder'] = isset($this->settings['masteryorder']) ? $this->settings['masteryorder'] : 'masttime';
         $this->settings['direction'] = isset($this->settings['direction']) ? $this->settings['direction'] : 'asc';
         switch ($this->settings['masteryorder']) {
             case 'masttime':
                 $fvSQL = "SELECT * FROM seedinfo WHERE seedinfo_masttime > 0 AND ";
                 $fvSQL .= "(seedinfo_level <= '" . $this->level . "' OR seedinfo_level = '') AND ";
                 $fvSQL .= "(seedinfo_startdate <= '" . time() . "' OR seedinfo_startdate= '') AND ";
                 $fvSQL .= "(seedinfo_enddate >= '" . time() . "' OR seedinfo_enddate = '') AND ";
                 $fvSQL .= "seedinfo_mastery = '1' ";
                 $fvSQL .= "ORDER BY seedinfo_masttime " . $this->settings['direction'];
                 break;
             case 'growtime':
                 $fvSQL = "SELECT * FROM seedinfo WHERE seedinfo_masttime > 0 AND ";
                 $fvSQL .= "(seedinfo_level <= '" . $this->level . "' OR seedinfo_level = '') AND ";
                 $fvSQL .= "(seedinfo_startdate <= '" . time() . "' OR seedinfo_startdate= '') AND ";
                 $fvSQL .= "(seedinfo_enddate >= '" . time() . "' OR seedinfo_enddate = '') AND ";
                 $fvSQL .= "seedinfo_mastery = '1' ";
                 $fvSQL .= "ORDER BY seedinfo_growtime " . $this->settings['direction'];
                 break;
             case 'profithr':
                 $fvSQL = "SELECT * FROM seedinfo WHERE seedinfo_profhr > 0 AND ";
                 $fvSQL .= "(seedinfo_level <= '" . $this->level . "' OR seedinfo_level = '') AND ";
                 $fvSQL .= "(seedinfo_startdate <= '" . time() . "' OR seedinfo_startdate= '') AND ";
                 $fvSQL .= "(seedinfo_enddate >= '" . time() . "' OR seedinfo_enddate = '') AND ";
                 $fvSQL .= "seedinfo_mastery = '1' ";
                 $fvSQL .= "ORDER BY seedinfo_profhr " . $this->settings['direction'];
                 break;
             case 'xphr':
                 $fvSQL = "SELECT * FROM seedinfo WHERE seedinfo_xphr > 0 AND ";
                 $fvSQL .= "(seedinfo_level <= '" . $this->level . "' OR seedinfo_level = '') AND ";
                 $fvSQL .= "(seedinfo_startdate <= '" . time() . "' OR seedinfo_startdate= '') AND ";
                 $fvSQL .= "(seedinfo_enddate >= '" . time() . "' OR seedinfo_enddate = '') AND ";
                 $fvSQL .= "seedinfo_mastery = '1' ";
                 $fvSQL .= "ORDER BY seedinfo_xphr " . $this->settings['direction'];
                 break;
             case 'nomast':
                 $fvSQL = "SELECT * FROM seedinfo WHERE ";
                 $fvSQL .= "(seedinfo_level <= '" . $this->level . "' OR seedinfo_level = '') AND ";
                 $fvSQL .= "(seedinfo_startdate <= '" . time() . "' OR seedinfo_startdate= '') AND ";
                 $fvSQL .= "(seedinfo_enddate >= '" . time() . "' OR seedinfo_enddate = '') AND ";
                 $fvSQL .= "seedinfo_mastery = '0' ";
                 $fvSQL .= "ORDER BY seedinfo_xphr " . $this->settings['direction'];
                 break;
             case 'crafting':
                 if (count($seed_plots) > 0) {
                     $this->_fvPlotWork($seed_plots, 'place');
                 }
                 $this->_fvPlantCrafts($plots);
                 DoInit();
                 return;
                 break;
             case 'coop':
                 if (count($seed_plots) > 0) {
                     $this->_fvPlotWork($seed_plots, 'place');
                 }
                 $this->_fvPlantQuests($plots);
                 DoInit();
                 return;
                 break;
         }
         $q = $this->_fvFarmerDBM->query($fvSQL);
         $results = $q->fetchAll(SQLITE_ASSOC);
         $seeds = array();
         if (is_array($results)) {
             foreach ($results as $result) {
                 //Check License
                 if (!empty($result['seedinfo_license'])) {
                     if ($this->_fvGetLicense($result['seedinfo_code']) === false) {
                         continue;
                     }
                 }
                 $seedUnit = Units_GetUnitByCode($result['seedinfo_code'], true);
                 if (isset($seedUnit['seedpackage'])) {
                     $seedpkg = Units_GetUnitByName($seedUnit['seedpackage']);
                     $conbox = unserialize(fBGetDataStore('inseedbox'));
                     $result['seedpackage'] = isset($conbox[$seedpkg['code']]) ? $conbox[$seedpkg['code']] : 0;
                 }
                 //Check Requirements
                 if (isset($seedUnit['requirements']) && !isset($seedUnit['isHybrid'])) {
                     $reqs = unserialize($seedUnit['requirements']);
                     $mast = 0;
                     foreach ($reqs as $req) {
                         if (!isset($req['@attributes']) && !isset($req[0]) && !isset($req['requirement'])) {
                             $req['@attributes'] = $req;
                         }
                         if (isset($req['@attributes']['className'])) {
                             $seedc = Units_GetCodeByName($req['@attributes']['name']);
                             if (@$maststar[$seedc] == $req['@attributes']['level']) {
                                 $mast++;
                             }
                         }
                         if (isset($req[0]['@attributes'])) {
                             foreach ($req as $req2) {
                                 $seedc = Units_GetCodeByName($req2['@attributes']['name']);
                                 if (@$maststar[$seedc] == $req2['@attributes']['level']) {
                                     $mast++;
                                 }
                             }
                         }
                         if (isset($req['requirement'])) {
                             foreach ($req as $req2) {
                                 $seedc = Units_GetCodeByName($req2['@attributes']['name']);
                                 if (@$maststar[$seedc] == $req2['@attributes']['level']) {
                                     $mast++;
                                 }
                             }
                         }
                     }
                     if ($mast != count($reqs)) {
                         continue;
                     }
                 }
                 $seeds[] = $result;
             }
             foreach ($seeds as $skey => $seed) {
                 $seed['seedinfo_curramt'] = is_numeric($seed['seedinfo_curramt']) ? $seed['seedinfo_curramt'] : 0;
                 $numPlanted = 0;
                 if (empty($plots)) {
                     break;
                 }
                 for ($x = 0; $x < $seed['seedinfo_mastmax'] - $seed['seedinfo_curramt']; $x++) {
                     if (empty($plots)) {
                         break;
                     }
                     if (isset($seed['seedpackage'])) {
                         if ($x == $seed['seedpackage']) {
                             break;
                         }
                     }
                     $seedc = Units_GetCodeByName($seed['seedinfo_name']);
                     if (@$maststar[$seedc] == 2) {
                         break;
                     }
                     $tmpplot = array_pop($plots);
                     $tmpplot['itemName'] = $seed['seedinfo_name'];
                     $seed_plots[] = $tmpplot;
                 }
             }
         }
     }
     if (!empty($plots)) {
         $defseeds = unserialize(file_get_contents($_SESSION['base_path'] . F('defaultseed.txt')));
         if (is_array($defseeds) && !empty($defseeds)) {
             foreach ($defseeds as $key1 => $orSeed) {
                 if ($orSeed[1] > 0) {
                     if (empty($plots)) {
                         break;
                     }
                     for ($x = 0; $x < $orSeed[1]; $x++) {
                         if (empty($plots)) {
                             break;
                         }
                         $tmpplot = array_pop($plots);
                         $tmpplot['itemName'] = $orSeed[0];
                         $seed_plots[] = $tmpplot;
                         $defseeds[$key1][1]--;
                     }
                     if ($defseeds[$key1][1] == 0) {
                         unset($defseeds[$key1]);
                     }
                 }
             }
             file_put_contents($_SESSION['base_path'] . F('defaultseed.txt'), serialize($defseeds));
         }
     }
     if (count($seed_plots) > 0) {
         foreach ($seed_plots as $seed) {
             @($newseed[$seed['itemName']][] = $seed);
         }
         foreach ($newseed as $iplots) {
             $this->_fvPlotWork($iplots, 'place');
         }
         DoInit();
     }
     unset($plots, $seed_plots, $newseed);
 }
Пример #4
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;
         }
     }
 }