Info_Gates.php 8.2 KB

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