Info_Gates.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. public function initialize() {
  83. $startId = glc()->FirstGateId; # 初始化第一关的关卡id
  84. $this->CurrentGateId = $startId;
  85. $this->UnlockedGatesMaxId = $startId;
  86. $this->GateList = new \stdClass();
  87. $Ins_GateInfo = new Ins_GateInfo();
  88. $Ins_GateInfo->GateId = $this->CurrentGateId;
  89. $this->GateList->$startId = $Ins_GateInfo;
  90. $this->GatesChallengeRecord = new \stdClass();
  91. $this->xunluo_StartTs = now();
  92. }
  93. public function __construct($arg = null) {
  94. if ($arg == null) {
  95. if ($this->CurrentGateId == 0) {
  96. $startId = 1;
  97. $this->CurrentGateId = $startId;
  98. $this->UnlockedGatesMaxId = $startId;
  99. $this->GateList = new \stdClass();
  100. $Ins_GateInfo = new Ins_GateInfo();
  101. $Ins_GateInfo->GateId = $this->CurrentGateId;
  102. $this->GateList->$startId = $Ins_GateInfo;
  103. }
  104. $this->GatesChallengeRecord = new \stdClass();
  105. $this->xunluo_StartTs = now();
  106. $this->TowerGate = new Ins_TowerGateInfo();
  107. $this->TowerGate->skill_beidong = new \stdClass();
  108. $this->TowerGate->skill_zhudong = new \stdClass();
  109. $this->TowerGate->skill_zhudong_lockState = new \stdClass();
  110. $this->TowerGate->skill_beidong_lockState = new \stdClass();
  111. $this->TowerGate->CurLayer = 0; // 默认从1层开始
  112. } else {
  113. parent::__construct($arg);
  114. $this->TowerGateInfo()->fixArray();
  115. if (null != $this->GateList) {
  116. foreach ($this->GateList as $id => &$gt) {
  117. $gt = new Ins_GateInfo($gt);
  118. $gt->fixArray();
  119. }
  120. }
  121. }
  122. }
  123. /**
  124. * 计算启灵进化的buff加成
  125. */
  126. public function GetEnvovleBuffs() {
  127. $addHp = $addAtk = $addDecDamage = $addEatFood = 0; # 初始化加成值
  128. $arr = GameConfig::evolve();
  129. foreach ($arr as $key => $value) {
  130. isEditor() and $value = new \sm_evolve();
  131. if ($key <= $this->evolveMaxId_left) {
  132. isEditor() and $p = new \sm_predicate();
  133. $p = GameConfig::predicate_getItem($value->predicateId);
  134. my_Assert(null != $p, ErrCode::err_const_no);
  135. switch ($p->actionType) {
  136. case 'addHp': # + 血量上限
  137. $addHp += $p->actionParam1;
  138. break;
  139. case 'addDamge': # + 攻击力
  140. $addAtk += $p->actionParam1;
  141. break;
  142. case 'addDecDamage': # + 减伤
  143. $addDecDamage += $p->actionParam1;
  144. break;
  145. case 'addEatFood': # + 肉食恢复
  146. $addEatFood += $p->actionParam1;
  147. break;
  148. }
  149. }
  150. }
  151. return array($addHp, $addAtk, $addDecDamage, $addEatFood); # 返回元组
  152. }
  153. /**
  154. * 挑战关卡数据结构
  155. * @return Ins_TowerGateInfo
  156. */
  157. public function TowerGateInfo() {
  158. $this->TowerGate = new Ins_TowerGateInfo($this->TowerGate);
  159. return $this->TowerGate;
  160. }
  161. /**
  162. * 当前关卡信息
  163. * @return Ins_GateInfo
  164. */
  165. public function CurGateInfo() {
  166. $gateId = $this->CurrentGateId;
  167. my_Assert(StlUtil::dictHasProperty($this->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  168. $gateInfo = ctx()->gates->GateList->$gateId;
  169. return $gateInfo;
  170. }
  171. /**
  172. * @return int 解锁下一剧情关卡
  173. */
  174. public function UnlockNextPlotGate($gateId) {
  175. $nextId = $gateId;
  176. foreach (GameConfig::gate() as $k => $v) {
  177. isEditor() and $v = new \sm_gate();
  178. if ($v->unlockGateId == $gateId) {
  179. $nextId = $v->gateId;
  180. }
  181. }
  182. // echoLine("解锁下一关卡 $nextId");
  183. if (Ins_GateInfo::gateNum($this->UnlockedGatesMaxId) < Ins_GateInfo::gateNum($nextId)# 下一关尚未解锁
  184. && !StlUtil::dictHasProperty($this->GateList, $nextId)) {
  185. // $this->CurrentGateId = $nextId; # 不再自动推到下一关, -2024.5.31
  186. $this->UnlockedGatesMaxId = $nextId;
  187. $gate = new Ins_GateInfo();
  188. $gate->GateId = $nextId;
  189. $this->GateList->$nextId = $gate;
  190. }
  191. return $nextId;
  192. }
  193. /**
  194. * @param int $gateId 通关的关卡id
  195. */
  196. public function UnlockMainChallengeGate($gateId) {
  197. $dic = GameConfig::gate();
  198. $index = 0; # 挑战关卡解锁逻辑. -gwang 2024年4月15日
  199. foreach ($dic as $id => $item) {
  200. if (Ins_GateInfo::GateTypeFromId($id) == Enum_GateType::MainChallengeGate #
  201. && $item->challengeGateId == $gateId) {
  202. $index += 1;
  203. $gate = new Ins_GateInfo();
  204. $gate->GateId = $id;
  205. ctx()->gates->GateList->$id = $gate;
  206. }
  207. if ($index >= 3) { # 最多3个难度
  208. break;
  209. }
  210. }
  211. }
  212. /**
  213. * 最大通关id
  214. */
  215. public function maxPassGateNumId() {
  216. $maxIndex = 0;
  217. //$maxGateId = 0;
  218. foreach ($this->GateList as $gateId => $Ins_GateInfo) {
  219. if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) {
  220. $maxIndex = Ins_GateInfo::gateNum($gateId);
  221. //$maxGateId = $gateId;
  222. }
  223. }
  224. return $maxIndex;
  225. }
  226. /**
  227. * 最大通关id
  228. */
  229. public function maxPassGateId() {
  230. $maxIndex = 0;
  231. $maxGateId = 0;
  232. foreach ($this->GateList as $gateId => $Ins_GateInfo) {
  233. if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) {
  234. $maxIndex = Ins_GateInfo::gateNum($gateId);
  235. $maxGateId = $gateId;
  236. }
  237. }
  238. return $maxGateId;
  239. }
  240. }