PageRenderTime 35ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/plus.php

https://github.com/minea94/DboorZ
PHP | 125 lines | 108 code | 10 blank | 7 comment | 33 complexity | 984b0e8d7a90cd24b0e1ce07d948088c MD5 | raw file
  1. <?php
  2. /*********************/
  3. /* */
  4. /* Version : 5.1.0 */
  5. /* Author : RM */
  6. /* Comment : 071223 */
  7. /* */
  8. /*********************/
  9. require( ".".DIRECTORY_SEPARATOR."app".DIRECTORY_SEPARATOR."boot.php" );
  10. class GPage extends securegamepage
  11. {
  12. public $packageIndex = -1;
  13. public $plusTable = NULL;
  14. public function GPage( )
  15. {
  16. parent::securegamepage( );
  17. $this->viewFile = "plus.phtml";
  18. $this->contentCssClass = "plus";
  19. $this->plusTable = $this->gameMetadata['plusTable'];
  20. $i = 0;
  21. $c = sizeof( $this->plusTable );
  22. while ( $i < $c )
  23. {
  24. if ( 0 < $this->plusTable[$i]['time'] )
  25. {
  26. $this->plusTable[$i]['time'] = ceil( $this->plusTable[$i]['time'] / $this->gameMetadata['game_speed'] );
  27. }
  28. ++$i;
  29. }
  30. }
  31. public function load( )
  32. {
  33. parent::load( );
  34. $this->selectedTabIndex = isset( $_GET['t'] ) && is_numeric( $_GET['t'] ) && 0 <= intval( $_GET['t'] ) && intval( $_GET['t'] ) <= 2 ? intval( $_GET['t'] ) : 0;
  35. if ( $this->selectedTabIndex == 0 )
  36. {
  37. $this->packageIndex = isset( $_GET['id'] ) && is_numeric( $_GET['id'] ) && 0 < intval( $_GET['id'] ) && intval( $_GET['id'] ) <= sizeof( $this->appConfig['plus']['packages'] ) ? intval( $_GET['id'] ) - 1 : 0 - 1;
  38. }
  39. else if ( $this->selectedTabIndex == 2 && isset( $_GET['a'], $_GET['k'] ) && $_GET['k'] == $this->data['update_key'] && $this->plusTable[intval( $_GET['a'] )]['cost'] <= $this->data['gold_num'] && !$this->isGameTransientStopped( ) && !$this->isGameOver( ) )
  40. {
  41. switch ( intval( $_GET['a'] ) )
  42. {
  43. case 0 :
  44. case 1 :
  45. case 2 :
  46. case 3 :
  47. case 4 :
  48. $taskType = constant( "QS_PLUS".( intval( $_GET['a'] ) + 1 ) );
  49. $newTask = new QueueTask( $taskType, $this->player->playerId, $this->plusTable[intval( $_GET['a'] )]['time'] * 86400 );
  50. if ( 0 < intval( $_GET['a'] ) )
  51. {
  52. }
  53. $newTask->villageId = "";
  54. $newTask->tag = $this->plusTable[intval( $_GET['a'] )]['cost'];
  55. $this->queueModel->addTask( $newTask );
  56. break;
  57. case 5 :
  58. case 7 :
  59. $this->queueModel->finishTasks( $this->player->playerId, $this->plusTable[intval( $_GET['a'] )]['cost'], intval( $_GET['a'] ) == 7 );
  60. }
  61. }
  62. }
  63. public function preRender( )
  64. {
  65. parent::prerender( );
  66. if ( 0 < $this->selectedTabIndex )
  67. {
  68. $this->villagesLinkPostfix .= "&t=".$this->selectedTabIndex;
  69. }
  70. }
  71. public function getRemainingPlusTime( $action )
  72. {
  73. $time = 0;
  74. $tasks = $this->queueModel->tasksInQueue;
  75. if ( isset( $tasks[constant( "QS_PLUS".( $action + 1 ) )] ) )
  76. {
  77. $time = $tasks[constant( "QS_PLUS".( $action + 1 ) )][0]['remainingSeconds'];
  78. }
  79. return 0 < $time ? time_remain_lang." <span id=\"timer1\">".WebHelper::secondstostring( $time )."</span> ".time_hour_lang : "";
  80. }
  81. public function getPlusAction( $action )
  82. {
  83. if ( $this->data['gold_num'] < $this->plusTable[$action]['cost'] )
  84. {
  85. return "<span class=\"none\">".plus_text_lowgold."</span>";
  86. }
  87. if ( $action == 5 || $action == 7 )
  88. {
  89. return "<a href=\"plus.php?t=2&a=".$action."&k=".$this->data['update_key']."\">".plus_text_activatefeature."</a>";
  90. }
  91. if ( $action == 6 )
  92. {
  93. return $this->hasMarketplace( ) ? "<a href=\"build.php?bid=17&t=3\">".plus_text_gotomarket."</a>" : "<span class=\"none\">".plus_text_gotomarket."</span>";
  94. }
  95. $tasks = $this->queueModel->tasksInQueue;
  96. return isset( $tasks[constant( "QS_PLUS".( $action + 1 ) )] ) ? "<a href=\"plus.php?t=2&a=".$action."&k=".$this->data['update_key']."\">".plus_text_extendfeature."</a>" : "<a href=\"plus.php?t=2&a=".$action."&k=".$this->data['update_key']."\">".plus_text_activatefeature."</a>";
  97. }
  98. public function hasMarketplace( )
  99. {
  100. $b_arr = explode( ",", $this->data['buildings'] );
  101. foreach ( $b_arr as $b_str )
  102. {
  103. $b2 = explode( " ", $b_str );
  104. if ( !( $b2[0] == 17 ) )
  105. {
  106. continue;
  107. }
  108. return TRUE;
  109. }
  110. return FALSE;
  111. }
  112. }
  113. $p = new GPage( );
  114. $p->run( );
  115. ?>