function Sections_GetUnits($flashRevision) { $vReturn = load_array('sections_unit.txt'); if ($vReturn['flashRevision'] != $flashRevision) { $units = Units_GetByType('seed'); foreach ($units as $unit) { if (strlen($unit['realname']) == 0) { $unit['realname'] = $unit['name']; } $vSeeds[$unit['name']] = $unit['realname']; } $units = Units_GetByType('animal'); foreach ($units as $unit) { if (strlen($unit['realname']) == 0) { $unit['realname'] = $unit['name']; } $vAnimals[$unit['name']] = $unit['realname']; if (isset($unit['buyable']) && $unit['buyable'] == 'true') { if (isset($unit['market'])) { $vBuyAnimals['cash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyAnimals['coins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } else { if (isset($unit['market'])) { $vBuyAnimals['nocash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyAnimals['nocoins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } $vUnit = strpos($unit['name'], '_') === false ? $unit['name'] : substr($unit['name'], 0, strpos($unit['name'], '_')); $vAnimalUnits[$vUnit][$unit['name']] = $unit['realname']; } $units = Units_GetByType('tree'); foreach ($units as $unit) { $vTrees[$unit['name']] = $unit['realname']; if (isset($unit['buyable']) && $unit['buyable'] == 'true') { if (isset($unit['market'])) { $vBuyTrees['cash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyTrees['coins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } else { if (isset($unit['market'])) { $vBuyTrees['nocash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyTrees['nocoins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } } $units = Units_GetByType('decoration'); foreach ($units as $unit) { $vDecorations[$unit['name']] = $unit['realname']; if (isset($unit['buyable']) && $unit['buyable'] == 'true') { if (isset($unit['market'])) { $vBuyDecorations['cash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyDecorations['coins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } else { if (isset($unit['market'])) { $vBuyDecorations['nocash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyDecorations['nocoins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } } $units = Units_GetByType('building'); foreach ($units as $unit) { $vBuildings[$unit['name']] = $unit['realname']; if (isset($unit['buyable']) && $unit['buyable'] == 'true') { if (isset($unit['market'])) { $vBuyBuildings['cash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyBuildings['coins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } else { if (isset($unit['market'])) { $vBuyBuildings['nocash'][$unit['name']] = $unit['realname'] . ' (' . $unit['cash'] . ' cash)'; } else { $vBuyBuildings['nocoins'][$unit['name']] = $unit['realname'] . ' (' . $unit['cost'] . ' coins)'; } } } $units = Units_GetAll(); foreach ($units as $unit) { $vAll[$unit['name']] = $unit['realname']; } ksort($vSeeds); ksort($vAnimals); ksort($vTrees); ksort($vDecorations); ksort($vBuildings); ksort($vBuyAnimals['cash']); ksort($vBuyAnimals['coins']); ksort($vBuyAnimals['nocash']); ksort($vBuyAnimals['nocoins']); ksort($vBuyTrees['cash']); ksort($vBuyTrees['coins']); ksort($vBuyTrees['nocash']); ksort($vBuyTrees['nocoins']); ksort($vBuyDecorations['cash']); ksort($vBuyDecorations['coins']); ksort($vBuyDecorations['nocash']); ksort($vBuyDecorations['nocoins']); ksort($vBuyBuildings['cash']); ksort($vBuyBuildings['coins']); ksort($vBuyBuildings['nocash']); ksort($vBuyBuildings['nocoins']); ksort($vAnimalUnits); ksort($vAll); $vReturn['flashRevision'] = $flashRevision; $vReturn['vSeeds'] = $vSeeds; $vReturn['vAnimals'] = $vAnimals; $vReturn['vTrees'] = $vTrees; $vReturn['vDecorations'] = $vDecorations; $vReturn['vBuildings'] = $vBuildings; $vReturn['vBuyAnimals'] = $vBuyAnimals; $vReturn['vBuyTrees'] = $vBuyTrees; $vReturn['vBuyDecorations'] = $vBuyDecorations; $vReturn['vBuyBuildings'] = $vBuyBuildings; $vReturn['vAnimalUnits'] = $vAnimalUnits; $vReturn['vAll'] = $vAll; save_array($vReturn, 'sections_unit.txt'); } return $vReturn; }
private function _fvUpdateSeedDB() { $this->_fvFarmerDBM->queryExec('DELETE FROM seedinfo'); $this->_fvFarmerDBM->queryExec('BEGIN TRANSACTION;'); $results = Units_GetByType('seed', true); $mastcnt = unserialize(fBGetDataStore('cropmastery')); foreach (GetObjects() as $world) { if ($world['className'] == 'Plot' && $world['state'] == 'planted') { if ($world['isJumbo'] == 1) { @($seedcnt[$world['itemName']] = $seedcnt[$world['itemName']] + 2); } else { @$seedcnt[$world['itemName']]++; } } } foreach ($results as $key => $seed) { $seed['mastcnt'] = @$mastcnt[$seed['code']] + @$seedcnt[$seed['name']]; $seed['mastery'] = isset($seed['mastery']) && $seed['mastery'] == 'true' ? 1 : 0; $gtime = round($seed['growTime'] * 23); $masttime = $gtime * (@$seed['masterymax'] - $seed['mastcnt']); $profit = $seed['coinYield'] - $seed['cost']; $fvSQL = 'INSERT OR REPLACE INTO seedinfo (seedinfo_name, seedinfo_code, seedinfo_level,'; $fvSQL .= 'seedinfo_startdate, seedinfo_enddate, seedinfo_masttime, seedinfo_growtime,'; $fvSQL .= 'seedinfo_profhr, seedinfo_xphr, seedinfo_curramt, seedinfo_mastery, seedinfo_mastmax,'; $fvSQL .= 'seedinfo_license)'; $fvSQL .= "values('" . $seed['name'] . "', '" . $seed['code'] . "', '" . @$seed['requiredLevel'] . "', '"; $fvSQL .= strtotime(@$seed['limitedStart']) . "', '" . strtotime(@$seed['limitedEnd']) . "', '" . $masttime . "', '"; $fvSQL .= $seed['growTime'] . "', '" . number_format($profit / $gtime, 2) . "', '" . number_format($seed['plantXp'] / $gtime, 2) . "', '"; $fvSQL .= $seed['mastcnt'] . "', '" . $seed['mastery'] . "', '" . @$seed['masterymax'] . "', '"; $fvSQL .= @$seed['license'] . "');"; $this->_fvFarmerDBM->queryExec($fvSQL); } $this->_fvFarmerDBM->queryExec('COMMIT TRANSACTION;'); $this->_fvFarmerDBM->queryExec('DELETE FROM fmbushels'); $this->_fvFarmerDBM->queryExec('BEGIN TRANSACTION;'); 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->_fvFarmerDBM->queryExec($gfvSQL); } $this->_fvFarmerDBM->queryExec('COMMIT TRANSACTION;'); //Database Cleanup Routine if (!isset($this->settings['lastclean']) || time() - (int) $this->settings['lastclean'] >= 14400) { AddLog2('fvFarmer is doing DB Cleanup'); $this->_fvFarmerDBM->query('vacuum'); $fvSQL = "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('lastclean','" . time() . "')"; $this->_fvFarmerDBM->queryExec($fvSQL); } }