ResourcesPage + BonusPage

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • ResourcesPage + BonusPage

      En el archivo ShowResourcesPage.class.php se generan una series de cálculos matemáticos para encontrar la producción diaria de una mina , quisiera saber como puedo mostrar esos datos en otro archivo como por ejemplo ShowBonusPage.class.php sin hacer todos esos cálculos otra ves y mostrar esos datos con un echo, la producción diaria de una mina la voy a tener en cuenta para generar en bonus.
    • Как-то так (на скорую руку):

      PHP Source Code: subclass.ResForm

      1. $config = Config::get();
      2. if($USER['urlaubs_modus'] == 1 || $PLANET['planet_type'] != 1)
      3. {
      4. $basicIncome[901] = 0;
      5. $basicIncome[902] = 0;
      6. $basicIncome[903] = 0;
      7. $basicIncome[911] = 0;
      8. }
      9. else
      10. {
      11. $basicIncome[901] = $config->{$resource[901].'_basic_income'};
      12. $basicIncome[902] = $config->{$resource[902].'_basic_income'};
      13. $basicIncome[903] = $config->{$resource[903].'_basic_income'};
      14. $basicIncome[911] = $config->{$resource[911].'_basic_income'};
      15. }
      16. $temp = array(
      17. 901 => array(
      18. 'plus' => 0,
      19. 'minus' => 0,
      20. ),
      21. 902 => array(
      22. 'plus' => 0,
      23. 'minus' => 0,
      24. ),
      25. 903 => array(
      26. 'plus' => 0,
      27. 'minus' => 0,
      28. ),
      29. 911 => array(
      30. 'plus' => 0,
      31. 'minus' => 0,
      32. )
      33. );
      34. $ressIDs = array_merge(array(), $reslist['resstype'][1], $reslist['resstype'][2]);
      35. $productionList = array();
      36. if($PLANET['energy_used'] != 0) {
      37. $prodLevel = min(1, $PLANET['energy'] / abs($PLANET['energy_used']));
      38. } else {
      39. $prodLevel = 0;
      40. }
      41. /* Data for eval */
      42. $BuildEnergy = $USER[$resource[113]];
      43. $BuildTemp = $PLANET['temp_max'];
      44. foreach($reslist['prod'] as $ProdID)
      45. {
      46. if(isset($PLANET[$resource[$ProdID]]) && $PLANET[$resource[$ProdID]] == 0)
      47. continue;
      48. if(isset($USER[$resource[$ProdID]]) && $USER[$resource[$ProdID]] == 0)
      49. continue;
      50. $productionList[$ProdID] = array(
      51. 'production' => array(901 => 0, 902 => 0, 903 => 0, 911 => 0),
      52. 'elementLevel' => $PLANET[$resource[$ProdID]],
      53. 'prodLevel' => $PLANET[$resource[$ProdID].'_porcent'],
      54. );
      55. /* Data for eval */
      56. $BuildLevel = $PLANET[$resource[$ProdID]];
      57. $BuildLevelFactor = $PLANET[$resource[$ProdID].'_porcent'];
      58. foreach($ressIDs as $ID)
      59. {
      60. if(!isset($ProdGrid[$ProdID]['production'][$ID]))
      61. continue;
      62. $Production = eval(ResourceUpdate::getProd($ProdGrid[$ProdID]['production'][$ID]));
      63. if(in_array($ID, $reslist['resstype'][2]))
      64. {
      65. $Production *= $config->energySpeed;
      66. }
      67. else
      68. {
      69. $Production *= $prodLevel * $config->resource_multiplier;
      70. }
      71. $productionList[$ProdID]['production'][$ID] = $Production;
      72. if($Production > 0) {
      73. if($PLANET[$resource[$ID]] == 0) continue;
      74. $temp[$ID]['plus'] += $Production;
      75. } else {
      76. $temp[$ID]['minus'] += $Production;
      77. }
      78. }
      79. }
      80. $storage = array(
      81. 901 => shortly_number($PLANET[$resource[901].'_max']),
      82. 902 => shortly_number($PLANET[$resource[902].'_max']),
      83. 903 => shortly_number($PLANET[$resource[903].'_max']),
      84. );
      85. $basicProduction = array(
      86. 901 => $basicIncome[901] * $config->resource_multiplier,
      87. 902 => $basicIncome[902] * $config->resource_multiplier,
      88. 903 => $basicIncome[903] * $config->resource_multiplier,
      89. 911 => $basicIncome[911] * $config->energySpeed,
      90. );
      91. $totalProduction = array(
      92. 901 => $PLANET[$resource[901].'_perhour'] + $basicProduction[901],
      93. 902 => $PLANET[$resource[902].'_perhour'] + $basicProduction[902],
      94. 903 => $PLANET[$resource[903].'_perhour'] + $basicProduction[903],
      95. 911 => $PLANET[$resource[911]] + $basicProduction[911] + $PLANET[$resource[911].'_used'],
      96. );
      97. $bonusProduction = array(
      98. 901 => $temp[901]['plus'] * ($USER['factor']['Resource'] + 0.02 * $USER[$resource[131]]),
      99. 902 => $temp[902]['plus'] * ($USER['factor']['Resource'] + 0.02 * $USER[$resource[132]]),
      100. 903 => $temp[903]['plus'] * ($USER['factor']['Resource'] + 0.02 * $USER[$resource[133]]),
      101. 911 => $temp[911]['plus'] * $USER['factor']['Energy'],
      102. );
      103. $dailyProduction = array(
      104. 901 => $totalProduction[901] * 24,
      105. 902 => $totalProduction[902] * 24,
      106. 903 => $totalProduction[903] * 24,
      107. 911 => $totalProduction[911],
      108. );
      109. $weeklyProduction = array(
      110. 901 => $totalProduction[901] * 168,
      111. 902 => $totalProduction[902] * 168,
      112. 903 => $totalProduction[903] * 168,
      113. 911 => $totalProduction[911],
      114. );
      115. $prodSelector = array();
      116. foreach(range(10, 0) as $percent) {
      117. $prodSelector[$percent] = ($percent * 10).'%';
      118. }
      Display All


      PHP Source Code: ShowResourcesPage.class.php

      1. function show()
      2. {
      3. global $LNG, $ProdGrid, $resource, $reslist, $USER, $PLANET;
      4. include('includes/subclasses/subclass.ResForm.php');
      5. $this->assign(array(
      6. 'header' => sprintf($LNG['rs_production_on_planet'], $PLANET['name']),
      7. 'prodSelector' => $prodSelector,
      8. 'productionList' => $productionList,
      9. 'basicProduction' => $basicProduction,
      10. 'totalProduction' => $totalProduction,
      11. 'bonusProduction' => $bonusProduction,
      12. 'dailyProduction' => $dailyProduction,
      13. 'weeklyProduction' => $weeklyProduction,
      14. 'storage' => $storage,
      15. ));
      16. $this->display('page.resources.default.tpl');
      17. }
      Display All

      PHP Source Code: ShowBonusPage.class.php

      1. - function show()
      2. {
      3. global $LNG, $ProdGrid, $resource, $reslist, $USER, $PLANET;
      4. include('includes/subclasses/subclass.ResForm.php');
      5. $this->assign(array(
      6. 'header' => sprintf($LNG['rs_production_on_planet'], $PLANET['name']),
      7. 'prodSelector' => $prodSelector,
      8. 'productionList' => $productionList,
      9. 'basicProduction' => $basicProduction,
      10. 'totalProduction' => $totalProduction,
      11. 'bonusProduction' => $bonusProduction,
      12. 'dailyProduction' => $dailyProduction,
      13. 'weeklyProduction' => $weeklyProduction,
      14. 'storage' => $storage,
      15. ));
      16. $this->display('page.bonus.default.tpl');
      17. }
      Display All