Info_Gates.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace loyalsoft;
  8. /**
  9. * Description of Info_Gates
  10. *
  11. * @author c'y'zhao
  12. */
  13. class Info_Gates extends Object_ext {
  14. /**
  15. * 当前剧情选择的关卡
  16. */
  17. public $CurrentGateId = 0;
  18. /**
  19. * 已解锁剧情关卡的最大id
  20. * @var type
  21. */
  22. public $UnlockedGatesMaxId = 0;
  23. /**
  24. * 最大通关id
  25. * @var type
  26. */
  27. public $maxPassGateId = 0;
  28. /**
  29. * 章节列表
  30. * @var Ins_GateInfo
  31. */
  32. public $GateList = null;
  33. /**
  34. * 挑战功能领取记录
  35. * @var type
  36. */
  37. public $GatesChallengeRecord = null;
  38. /**
  39. * 进化解锁记录
  40. * @var type
  41. */
  42. #[ArrayType]
  43. public $evolveUnlockRecord = array();
  44. /**
  45. * 巡逻领取奖励的时间
  46. * @var int
  47. */
  48. public $xunluo_StartTs = 0;
  49. /**
  50. * 快速巡逻的购买记录
  51. * @var int
  52. */
  53. public $xunluo_quick_buyRecord = 0;
  54. /**
  55. * 进化左边解锁最大值得记录
  56. * @var type
  57. */
  58. public $evolveMaxId_left = 0;
  59. /**
  60. * 进化右边解锁最大值得记录
  61. * @var type
  62. */
  63. public $evolveMaxId_right = 0;
  64. /**
  65. * 扫荡
  66. * @var type
  67. */
  68. public $fightSweepNum = 0;
  69. /**
  70. * 挑战关卡信息
  71. * @var Ins_TowerGateInfo
  72. */
  73. public $TowerGate;
  74. public function initialize() {
  75. $startId = glc()->FirstGateId; # 初始化第一关的关卡id
  76. $this->CurrentGateId = $startId;
  77. $this->UnlockedGatesMaxId = $startId;
  78. $this->GateList = new \stdClass();
  79. $Ins_GateInfo = new Ins_GateInfo();
  80. $Ins_GateInfo->GateId = $this->CurrentGateId;
  81. $this->GateList->$startId = $Ins_GateInfo;
  82. $this->GatesChallengeRecord = new \stdClass();
  83. $this->xunluo_StartTs = now();
  84. }
  85. public function __construct($arg = null) {
  86. if ($arg == null) {
  87. if ($this->CurrentGateId == 0) {
  88. $startId = 1;
  89. $this->CurrentGateId = $startId;
  90. $this->UnlockedGatesMaxId = $startId;
  91. $this->GateList = new \stdClass();
  92. $Ins_GateInfo = new Ins_GateInfo();
  93. $Ins_GateInfo->GateId = $this->CurrentGateId;
  94. $this->GateList->$startId = $Ins_GateInfo;
  95. }
  96. $this->GatesChallengeRecord = new \stdClass();
  97. $this->xunluo_StartTs = now();
  98. $this->TowerGate = new Ins_TowerGateInfo();
  99. $this->TowerGate->skill_beidong = new \stdClass();
  100. $this->TowerGate->skill_zhudong = new \stdClass();
  101. $this->TowerGate->skill_zhudong_lockState = new \stdClass();
  102. $this->TowerGate->skill_beidong_lockState = new \stdClass();
  103. $this->TowerGate->CurLayer = 0; // 默认从1层开始
  104. } else {
  105. parent::__construct($arg);
  106. $this->TowerGateInfo()->fixArray();
  107. if (null != $this->GateList) {
  108. foreach ($this->GateList as $id => &$gt) {
  109. $gt = new Ins_GateInfo($gt);
  110. $gt->fixArray();
  111. }
  112. }
  113. }
  114. }
  115. /**
  116. * 计算启灵进化的buff加成
  117. */
  118. public function GetEnvovleBuffs() {
  119. $addHp = $addAtk = $addDecDamage = $addEatFood = 0; # 初始化加成值
  120. $arr = GameConfig::evolve();
  121. foreach ($arr as $key => $value) {
  122. isEditor() and $value = new \sm_evolve();
  123. if ($key <= $this->evolveMaxId_left) {
  124. isEditor() and $p = new \sm_predicate();
  125. $p = GameConfig::predicate_getItem($value->predicateId);
  126. my_Assert(null != $p, ErrCode::err_const_no);
  127. switch ($p->actionType) {
  128. case 'addHp': # + 血量上限
  129. $addHp += $p->actionParam1;
  130. break;
  131. case 'addDamge': # + 攻击力
  132. $addAtk += $p->actionParam1;
  133. break;
  134. case 'addDecDamage': # + 减伤
  135. $addDecDamage += $p->actionParam1;
  136. break;
  137. case 'addEatFood': # + 肉食恢复
  138. $addEatFood += $p->actionParam1;
  139. break;
  140. }
  141. }
  142. }
  143. return array($addHp, $addAtk, $addDecDamage, $addEatFood); # 返回元组
  144. }
  145. /**
  146. * 挑战关卡数据结构
  147. * @return Ins_TowerGateInfo
  148. */
  149. public function TowerGateInfo() {
  150. $this->TowerGate = new Ins_TowerGateInfo($this->TowerGate);
  151. return $this->TowerGate;
  152. }
  153. /**
  154. * 当前关卡信息
  155. * @return Ins_GateInfo
  156. */
  157. public function CurGateInfo() {
  158. $gateId = $this->CurrentGateId;
  159. my_Assert(StlUtil::dictHasProperty($this->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  160. $gateInfo = ctx()->gates->GateList->$gateId;
  161. return $gateInfo;
  162. }
  163. /**
  164. * @return int 解锁下一剧情关卡
  165. */
  166. public function UnlockNextPlotGate($gateId) {
  167. $nextId = $gateId;
  168. foreach (GameConfig::gate() as $k => $v) {
  169. isEditor() and $v = new \sm_gate();
  170. if ($v->unlockGateId == $gateId) {
  171. $nextId = $v->gateId;
  172. }
  173. }
  174. // echoLine("解锁下一关卡 $nextId");
  175. if (Ins_GateInfo::gateNum($this->UnlockedGatesMaxId) < Ins_GateInfo::gateNum($nextId)# 下一关尚未解锁
  176. && !StlUtil::dictHasProperty($this->GateList, $nextId)) {
  177. // $this->CurrentGateId = $nextId; # 不再自动推到下一关, -2024.5.31
  178. $this->UnlockedGatesMaxId = $nextId;
  179. $gate = new Ins_GateInfo();
  180. $gate->GateId = $nextId;
  181. $this->GateList->$nextId = $gate;
  182. }
  183. return $nextId;
  184. }
  185. /**
  186. * @param int $gateId 通关的关卡id
  187. */
  188. public function UnlockMainChallengeGate($gateId) {
  189. $dic = GameConfig::gate();
  190. $index = 0; # 挑战关卡解锁逻辑. -gwang 2024年4月15日
  191. foreach ($dic as $id => $item) {
  192. if (Ins_GateInfo::GateTypeFromId($id) == Enum_GateType::MainChallengeGate #
  193. && $item->challengeGateId == $gateId) {
  194. $index += 1;
  195. $gate = new Ins_GateInfo();
  196. $gate->GateId = $id;
  197. ctx()->gates->GateList->$id = $gate;
  198. }
  199. if ($index >= 3) { # 最多3个难度
  200. break;
  201. }
  202. }
  203. }
  204. /**
  205. * 最大通关id
  206. */
  207. public function maxPassGateNumId() {
  208. $maxIndex = 0;
  209. //$maxGateId = 0;
  210. foreach ($this->GateList as $gateId => $Ins_GateInfo) {
  211. if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) {
  212. $maxIndex = Ins_GateInfo::gateNum($gateId);
  213. //$maxGateId = $gateId;
  214. }
  215. }
  216. return $maxIndex;
  217. }
  218. /**
  219. * 最大通关id
  220. */
  221. public function maxPassGateId() {
  222. $maxIndex = 0;
  223. $maxGateId = 0;
  224. foreach ($this->GateList as $gateId => $Ins_GateInfo) {
  225. if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) {
  226. $maxIndex = Ins_GateInfo::gateNum($gateId);
  227. $maxGateId = $gateId;
  228. }
  229. }
  230. return $maxGateId;
  231. }
  232. }