PageRenderTime 55ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/classes/missions/MissionCaseFoundDM.php

https://bitbucket.org/VolCh/2moons
PHP | 75 lines | 44 code | 6 blank | 25 comment | 4 complexity | 969091125fde06d77a5742fc9b2d3022 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.1 (2013-01-18)
  24. * @info $Id$
  25. * @link http://2moons.cc/
  26. */
  27. class MissionCaseFoundDM extends MissionFunctions
  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. SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_stay'], 15, $LNG['sys_mess_tower'], $LNG['sys_expe_report'], $Message);
  57. }
  58. function ReturnEvent()
  59. {
  60. $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
  61. if($this->_fleet['fleet_resource_darkmatter'] > 0) {
  62. SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_time'], 15, $LNG['sys_mess_tower'], $LNG['sys_expe_report'], sprintf($LNG['sys_expe_back_home_with_dm'], $LNG['tech'][921], pretty_number($this->_fleet['fleet_resource_darkmatter']), $LNG['tech'][921]));
  63. $this->UpdateFleet('fleet_array', '220,0;');
  64. } else {
  65. SendSimpleMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_time'], 15, $LNG['sys_mess_tower'], $LNG['sys_expe_report'], $LNG['sys_expe_back_home_without_dm']);
  66. }
  67. $this->RestoreFleet();
  68. }
  69. }