PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/classes/missions/MissionCaseFoundDM.class.php

https://bitbucket.org/VolCh/2moons
PHP | 89 lines | 54 code | 10 blank | 25 comment | 3 complexity | 5a58d2de6ba84c2e10a399099823a713 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, GPL-3.0, GPL-2.0, Apache-2.0, AGPL-3.0
  1. <?php
  2. /**
  3. * 2Moons
  4. * Copyright (C) 2012 Jan Krรถpke
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * @package 2Moons
  20. * @author Jan Krรถpke <info@2moons.cc>
  21. * @copyright 2012 Jan Krรถpke <info@2moons.cc>
  22. * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
  23. * @version 1.7.2 (2013-03-18)
  24. * @info $Id$
  25. * @link http://2moons.cc/
  26. */
  27. class MissionCaseFoundDM extends MissionFunctions implements Mission
  28. {
  29. const CHANCE = 30;
  30. const CHANCE_SHIP = 0.25;
  31. const MIN_FOUND = 423;
  32. const MAX_FOUND = 1278;
  33. const MAX_CHANCE = 50;
  34. function __construct($Fleet)
  35. {
  36. $this->_fleet = $Fleet;
  37. }
  38. function TargetEvent()
  39. {
  40. $this->setState(FLEET_HOLD);
  41. $this->SaveFleet();
  42. }
  43. function EndStayEvent()
  44. {
  45. $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
  46. $chance = mt_rand(0, 100);
  47. if($chance <= min(self::MAX_CHANCE, (self::CHANCE + $this->_fleet['fleet_amount'] * self::CHANCE_SHIP))) {
  48. $FoundDark = mt_rand(self::MIN_FOUND, self::MAX_FOUND);
  49. $this->UpdateFleet('fleet_resource_darkmatter', $FoundDark);
  50. $Message = $LNG['sys_expe_found_dm_'.mt_rand(1, 3).'_'.mt_rand(1, 2).''];
  51. } else {
  52. $Message = $LNG['sys_expe_nothing_'.mt_rand(1, 9)];
  53. }
  54. $this->setState(FLEET_RETURN);
  55. $this->SaveFleet();
  56. PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 15,
  57. $LNG['sys_expe_report'], $Message, $this->_fleet['fleet_end_stay'], NULL, 1, $this->_fleet['fleet_universe']);
  58. }
  59. function ReturnEvent()
  60. {
  61. $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
  62. if($this->_fleet['fleet_resource_darkmatter'] > 0)
  63. {
  64. $message = sprintf($LNG['sys_expe_back_home_with_dm'],
  65. $LNG['tech'][921],
  66. pretty_number($this->_fleet['fleet_resource_darkmatter']),
  67. $LNG['tech'][921]
  68. );
  69. $this->UpdateFleet('fleet_array', '220,0;');
  70. }
  71. else
  72. {
  73. $message = $LNG['sys_expe_back_home_without_dm'];
  74. }
  75. PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 4, $LNG['sys_mess_fleetback'],
  76. $message, $this->_fleet['fleet_end_time'], NULL, 1, $this->_fleet['fleet_universe']);
  77. $this->RestoreFleet();
  78. }
  79. }