Mod Harvest

    • PHP Source Code

      1. <?php
      2. class ShowHarvestPage extends AbstractGamePage {
      3. public static $requireModule = 0;
      4. var $HarvestPrice = array(1=>500,3=>1000,6=>2000, 15=>4000); // (weeks => price dm)
      5. function __construct() {
      6. parent::__construct();
      7. }
      8. function show() {
      9. global $CONF, $LNG, $PLANET, $USER, $resource, $UNI;
      10. $db = Database::get();
      11. if($USER['harvest_delay'] < TIMESTAMP - 24*60*60){
      12. if($USER['harvest_time'] < 5){
      13. $time = TIMESTAMP;
      14. $db->update("UPDATE `uni1_users` SET `harvest_time` = 5, `harvest_delay` = ".$time." where `id` = ".$USER['id'].";");
      15. $this->printMessage("Whe are setting back your harvest counters to 5.", true, array('game.php?page=harvest', 2));
      16. die();
      17. } else{
      18. $time = TIMESTAMP;
      19. $db->update("UPDATE `uni1_users` SET `harvest_delay` = ".$time." where `id` = ".$USER['id'].";");
      20. $this->printMessage("Loading your data.", true, array('game.php?page=harvest', 2));
      21. die();
      22. }
      23. }
      24. if(!empty($USER['urlaubs_modus'])){
      25. $this->printMessage("You can't access this page while you are in V mode!", true, array('game.php?page=overview', 2));
      26. die();
      27. }
      28. if($_POST){
      29. $mode = HTTP::_GP('con', '');
      30. switch($mode){
      31. case 'extra':
      32. $take = HTTP::_GP('buy',0);
      33. if(!array_key_exists($take,$this->HarvestPrice)){
      34. $this->printMessage("Invalid Option", true, array('?page=Harvest', 3));
      35. }else{
      36. //option is ok . go forward
      37. //enough dm ?
      38. if($USER['darkmatter'] < $this->HarvestPrice[$take]){
      39. $this->printMessage("Not enough DM", true, array('?page=Harvest', 3));
      40. die();
      41. }
      42. $USER['darkmatter'] -= $this->HarvestPrice[$take];
      43. $db->update("UPDATE %%USERS%% SET `harvest_time` = `harvest_time` + ".($take)." WHERE `id` = ".$USER['id']." ; ");
      44. $this->printMessage("You have bought ".$take." Harvest Points", true, array('?page=Harvest', 3));
      45. die();
      46. }
      47. break;
      48. case 'gather':
      49. if($USER['harvest_time'] == 0 ){
      50. $this->printMessage("No Harvest Points Left!", true, array('game.php?page=Harvest', 2));
      51. die();
      52. }
      53. if (!isset($_POST['check_planet']) && !isset($_POST['check_moons']))
      54. $this->redirectTo('game.php?page=harvest');
      55. if(!isset($_POST['check_planet']))
      56. $_POST['check_planet'] = array();
      57. foreach($_POST['check_planet'] as $ID => $Value) {
      58. $sur = $db->select("SELECT id, metal, crystal, deuterium FROM %%PLANETS%% where `id` = '".$Value."';");
      59. $db->nativeQuery("LOCK TABLE %%PLANETS%% WRITE; UPDATE %%PLANETS%% SET `metal` = metal - ".$sur['metal'].", `crystal` = crystal - ".$sur['crystal'].", `deuterium` = deuterium - ".$sur['deuterium']." WHERE `id` = '".$Value."'; UNLOCK TABLES;");
      60. $PLANET['metal'] += $sur['metal'];
      61. $PLANET['crystal'] += $sur['crystal'];
      62. $PLANET['deuterium'] += $sur['deuterium'];
      63. }
      64. if(!isset($_POST['check_moons']))
      65. $_POST['check_moons'] = array();
      66. foreach($_POST['check_moons'] as $ID => $Value) {
      67. $surr = $db->select("SELECT metal, crystal, deuterium FROM %%PLANETS%% where `id` = '".$Value."';");
      68. $db->nativeQuery("LOCK TABLE %%PLANETS%% WRITE; UPDATE %%PLANETS%% SET `metal` = metal - ".$surr['metal'].", `crystal` = crystal - ".$surr['crystal'].", `deuterium` = deuterium - ".$surr['deuterium']." WHERE `id` = '".$Value."'; UNLOCK TABLES;");
      69. $PLANET['metal'] += $surr['metal'];
      70. $PLANET['crystal'] += $surr['crystal'];
      71. $PLANET['deuterium'] += $surr['deuterium'];
      72. }
      73. $db->update("UPDATE %%USERS%% SET `harvest_time` = `harvest_time` - 1 where `id` = '".$USER['id']."';");
      74. $this->printMessage($LNG['h_ok'], true, array('game.php?page=harvest', 4));
      75. break;
      76. }
      77. }
      78. $Planets= array();
      79. $Moons = array();
      80. if (isset($USER['PLANETS'])) {
      81. $USER['PLANETS'] = getPlanets($USER);
      82. }
      83. foreach($USER['PLANETS'] as $ID => $PlanetQuery) {
      84. if ($ID == $PLANET['id']) continue;
      85. if ($PlanetQuery['planet_type'] == 3) {
      86. $Moons[$PlanetQuery['id']] = " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
      87. } elseif ($PlanetQuery['planet_type'] == 1) {
      88. $Planets[$PlanetQuery['id']] = " [".$PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
      89. }
      90. }
      91. $this->tplObj->loadscript("jquery.countdown.js");
      92. $this->tplObj->assign_vars(array(
      93. 'prices' => $this->HarvestPrice,
      94. 'PlanetsList'=> $Planets,
      95. 'MoonsList'=> $Moons,
      96. 'harvest'=> $USER['harvest_time'],
      97. 'p_state' => $USER['harvest_time'],
      98. 'p_delay' => ((($USER['harvest_delay']+24*60*60) < TIMESTAMP) ? true : (($USER['harvest_delay']+24*60*60) - TIMESTAMP)),
      99. ));
      100. $this->display('page.harvest.default.tpl');
      101. }
      102. }
      103. ?>
      Display All
      coswars - Open

      The post was edited 1 time, last by Coswars ().

    • Help with teleportation gives an error



      NOTICE
      Message: Undefined index: metal
      File: /includes/pages/game/ShowHarvestPage.class.php
      Line: 70
      URL: coswars.space/game.php?page=Harvest
      PHP-Version: 5.6.35
      PHP-API: litespeed
      2Moons Version: 2.0.git
      Debug Backtrace:
      #0 /includes/pages/game/ShowHarvestPage.class.php(70): errorHandler(8, 'Undefined index...', 'FILEPATH ...', 70, Array)
      #1 /game.php(57): ShowHarvestPage->show()
      #2 {main}
      coswars - Open
    • Check the data you return the on $sur

      I have made a personal available anywhere is it works very well for resources and for the fleet
      2moons 2.0 OPEN Demo
      Thank you to send by ticket or message or via the forum in the part made for this purpose for all problems.

      Download version 2.0 here
      Shop Mods and Games HERE

      -------------------------------------------------------
      My personal game
      OUnivers - Open
      Xterium - Comming Soon - No code is taken from available versions
    • No there is not
      2moons 2.0 OPEN Demo
      Thank you to send by ticket or message or via the forum in the part made for this purpose for all problems.

      Download version 2.0 here
      Shop Mods and Games HERE

      -------------------------------------------------------
      My personal game
      OUnivers - Open
      Xterium - Comming Soon - No code is taken from available versions