Harvest Mood 1.8
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
I think I have posted that already but here it goes.
I, personally, like to use this on Empire page.
PHP Source Code
- private function HarvestResources($Harvest) {
- global $USER, $PLANET, $resource, $pricelist, $LNG;
- /**/ // Attack
- $AttackCount = Database::get()->selectSingle("SELECT COUNT(*) as count FROM %%FLEETS%% WHERE fleet_target_owner = :id AND (fleet_mission = 1 OR fleet_mission = 2 OR fleet_mission = 9) AND fleet_start_time > :timestamp;", array(
- ':id' => $USER['id'],
- ':timestamp' => TIMESTAMP,
- ), 'count');
- if ($AttackCount > 0)
- {
- $this->printMessage('While under foreign enemy activity, you can not use this function', array(
- array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=imperium'
- )
- ));
- }
- if ($Harvest == 1) // All
- {
- $TakeFrom = "";
- }
- elseif ($Harvest == 2) // Planets only
- {
- $TakeFrom = "planet_type = '1' AND";
- }
- elseif ($Harvest == 3) // Planets only
- {
- $TakeFrom = "planet_type = '3' AND";
- }
- $SelectedPlanets = Database::get()->select("SELECT * FROM %%PLANETS%% WHERE " . $TakeFrom . " id_owner = :id_owner AND id != :id;", array(
- ':id_owner' => $USER['id'],
- ':id' => $PLANET['id'],
- ));
- foreach ($SelectedPlanets as $CPLANET) {
- $planetUpdater = new ResourceUpdate();
- list($USER, $CPLANET) = $planetUpdater->CalcResource($USER, $CPLANET);
- }
- $TotalResourceSQL = "SELECT SUM(metal) as metal, SUM(crystal) as crystal,SUM(deuterium) as deuterium FROM %%PLANETS%% WHERE " . $TakeFrom . " id_owner = :id_owner AND id != :id ;";
- $Resource = Database::get()->selectSingle($TotalResourceSQL, array(
- ':id_owner' => $USER['id'],
- ':id' => $PLANET['id'],
- ));
- $PLANET[$resource[901]] += $Resource['metal'];
- $PLANET[$resource[902]] += $Resource['crystal'];
- $PLANET[$resource[903]] += $Resource['deuterium'];
- Database::get()->update("UPDATE %%PLANETS%% SET metal = 0, crystal = 0, deuterium = 0 WHERE " . $TakeFrom . " id_owner = :id_owner AND id != :id ;", array(
- ':id_owner' => $USER['id'],
- ':id' => $PLANET['id'],
- ));
- $this->printMessage($LNG['err_imperium_hr_success'], array(
- array(
- 'label' => $LNG['sys_back'],
- 'url' => 'game.php?page=imperium'
- )
- ));
- }
function Show to be loaded after post on
Source Code
- $Harvest = HTTP::_GP('harvest', '');
- if (!empty($Harvest) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
- $this->HarvestResources($Harvest);
- }
- /* ...... before Empire page foreach */
- $ResourcesToHarvest = array(
- 0 => array(
- 901 => 0,
- 902 => 0,
- 903 => 0
- ) ,
- 1 => array(
- 901 => 0,
- 902 => 0,
- 903 => 0
- ) ,
- 3 => array(
- 901 => 0,
- 902 => 0,
- 903 => 0
- ) ,
- );
- /* inside Empire page planet foreach */
- // Harvester
- $ResourcesToHarvest[0][901] += $CPLANET[$resource[901]];
- $ResourcesToHarvest[0][902] += $CPLANET[$resource[902]];
- $ResourcesToHarvest[0][903] += $CPLANET[$resource[903]];
- if ($CPLANET['planet_type'] == 1) {
- $ResourcesToHarvest[1][901] += $CPLANET[$resource[901]];
- $ResourcesToHarvest[1][902] += $CPLANET[$resource[902]];
- $ResourcesToHarvest[1][903] += $CPLANET[$resource[903]];
- }
- elseif ($CPLANET['planet_type'] == 3) {
- $ResourcesToHarvest[3][901] += $CPLANET[$resource[901]];
- $ResourcesToHarvest[3][902] += $CPLANET[$resource[902]];
- $ResourcesToHarvest[3][903] += $CPLANET[$resource[903]];
- }
- /* in $tpl->assign */
- 'ResourcesToHarvest' => $ResourcesToHarvest,
Source Code
- <div id='HarvestResource' class='modal-demo'>
- <button type='button' class='close' onclick='Custombox.close();'>
- <span>×</span><span class='sr-only'>Close</span>
- </button>
- <h4 class='custom-modal-title'>{$LNG.btn_imperium_1}</h4>
- <div class='custom-modal-text'>
- <table class="table table-dark">
- <form action="game.php?page=imperium" method="post" >
- <thead>
- <tr>
- <th></th>
- <th>{$LNG.cr_type}</th>
- <th>{$LNG.tech.901}</th>
- <th>{$LNG.tech.902}</th>
- <th>{$LNG.tech.903}</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th scope="row"><input name="harvest" id="type0" type="radio" value="1" checked="checked"></th>
- <th scope="row">All</th>
- <td>{$ResourcesToHarvest.0.901|number}</td>
- <td>{$ResourcesToHarvest.0.902|number}</td>
- <td>{$ResourcesToHarvest.0.903|number}</td>
- </tr>
- <tr>
- <th scope="row"><input name="harvest" id="type1" type="radio" value="2"></th>
- <th scope="row">{$LNG.type_planet_1}</th>
- <td>{$ResourcesToHarvest.1.901|number}</td>
- <td>{$ResourcesToHarvest.1.902|number}</td>
- <td>{$ResourcesToHarvest.1.903|number}</td>
- </tr>
- <tr>
- <th scope="row"><input name="harvest" id="type3" type="radio" value="3"></th>
- <th scope="row">{$LNG.type_planet_3}</th>
- <td>{$ResourcesToHarvest.3.901|number}</td>
- <td>{$ResourcesToHarvest.3.902|number}</td>
- <td>{$ResourcesToHarvest.3.903|number}</td>
- </tr>
- <tr>
- <td colspan="5"><button type="submit" class="btn btn-xs btn-primary col-12">{$LNG.gl_collect}</button></td>
- </tr>
- </tbody>
- </form>
- </table>
- </div>
- </div>
The post was edited 1 time, last by Qwa ().
-
This harvest all the resources from colony and transport resources to your chosen planet ?
-
Yes, since Harvester function deposit all resources to $PLANET from selected source ($TakeFrom)
The post was edited 1 time, last by Qwa ().
-
Thanks will check this out, i have made this in my gam, but there is some problem on sending transport fleet, and I am to lazy to search for bug
Will give a test to your code. Thanks -
-
2moons 1.8 e can not adapt to the file as a file I can not adapt, I have an error I wonder if the page can not find
-
Tell me your error.
EDIT: removed "Megastructure" vars to avoid errors since it's from my game. Should work now. -
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0
-
Users Online 1
1 Guest
-
Tags