123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- namespace loyalsoft;
- /**
- * Description of Info_Gates
- *
- * @author c'y'zhao
- */
- class Info_Gates extends Object_ext {
- /**
- * 当前剧情选择的关卡
- * @var int
- */
- public $CurrentGateId = 0;
- /**
- * 已解锁剧情关卡的最大id
- * @var int
- */
- public $UnlockedGatesMaxId = 0;
- /**
- * 最大通关id
- * @var int
- */
- public $maxPassGateId = 0;
- /**
- * 章节列表
- * @var Ins_GateInfo
- */
- public $GateList = null;
- /**
- * 挑战功能领取记录
- * @var []
- */
- public $GatesChallengeRecord = null;
- /**
- * 进化解锁记录
- * @var []
- */
- #[ArrayType]
- public $evolveUnlockRecord = array();
- /**
- * 巡逻领取奖励的时间
- * @var int
- * @deprecated since version 巡逻没有用着
- */
- public $xunluo_StartTs = 0;
- /**
- * 快速巡逻的购买记录
- * @var int
- * @deprecated since version 巡逻没有用着
- */
- public $xunluo_quick_buyRecord = 0;
- /**
- * 进化左边解锁最大值得记录
- * @var int
- */
- public $evolveMaxId_left = 0;
- /**
- * 进化右边解锁最大值得记录
- * @var int
- */
- public $evolveMaxId_right = 0;
- /**
- * 扫荡
- * @var int
- */
- public $fightSweepNum = 0;
- /**
- * 扫荡 下次扫荡时间戳
- * @var int
- */
- public $fightSweepTs = 0;
- /**
- * 挑战关卡信息
- * @var Ins_TowerGateInfo
- */
- public $TowerGate;
- /**
- * @var int 上次开始战斗的时间戳
- */
- public $lastStartFightTs = 0;
-
- public $oldChapterId = 0;
-
- public $newChapterId = 0;
-
- public function initialize() {
- $startId = glc()->FirstGateId; # 初始化第一关的关卡id
- $this->CurrentGateId = $startId;
- $this->UnlockedGatesMaxId = $startId;
- $this->GateList = new \stdClass();
- $Ins_GateInfo = new Ins_GateInfo();
- $Ins_GateInfo->GateId = $this->CurrentGateId;
- $this->GateList->$startId = $Ins_GateInfo;
- $this->GatesChallengeRecord = new \stdClass();
- $this->xunluo_StartTs = now();
- }
- public function __construct($arg = null) {
- if ($arg == null) {
- if ($this->CurrentGateId == 0) {
- $startId = 1;
- $this->CurrentGateId = $startId;
- $this->UnlockedGatesMaxId = $startId;
- $this->GateList = new \stdClass();
- $Ins_GateInfo = new Ins_GateInfo();
- $Ins_GateInfo->GateId = $this->CurrentGateId;
- $this->GateList->$startId = $Ins_GateInfo;
- }
- $this->GatesChallengeRecord = new \stdClass();
- $this->xunluo_StartTs = now();
- $this->TowerGate = new Ins_TowerGateInfo();
- $this->TowerGate->skill_beidong = new \stdClass();
- $this->TowerGate->skill_zhudong = new \stdClass();
- $this->TowerGate->skill_zhudong_lockState = new \stdClass();
- $this->TowerGate->skill_beidong_lockState = new \stdClass();
- $this->TowerGate->CurLayer = 0; // 默认从1层开始
- } else {
- parent::__construct($arg);
- $this->TowerGateInfo()->fixArray();
- if (null != $this->GateList) {
- foreach ($this->GateList as $id => &$gt) {
- $gt = new Ins_GateInfo($gt);
- $gt->fixArray();
- }
- }
- }
- }
- /**
- * 计算启灵进化的buff加成
- */
- public function GetEnvovleBuffs() {
- $addHp = $addAtk = $addDecDamage = $addEatFood = 0; # 初始化加成值
- $arr = GameConfig::evolve();
- foreach ($arr as $key => $value) {
- isEditor() and $value = new \sm_evolve();
- if ($key <= $this->evolveMaxId_left) {
- isEditor() and $p = new \sm_predicate();
- $p = GameConfig::predicate_getItem($value->predicateId);
- my_Assert(null != $p, ErrCode::err_const_no);
- switch ($p->actionType) {
- case 'addHp': # + 血量上限
- $addHp += $p->actionParam1;
- break;
- case 'addDamge': # + 攻击力
- $addAtk += $p->actionParam1;
- break;
- case 'addDecDamage': # + 减伤
- $addDecDamage += $p->actionParam1;
- break;
- case 'addEatFood': # + 肉食恢复
- $addEatFood += $p->actionParam1;
- break;
- }
- }
- }
- return array($addHp, $addAtk, $addDecDamage, $addEatFood); # 返回元组
- }
- /**
- * 挑战关卡数据结构
- * @return Ins_TowerGateInfo
- */
- public function TowerGateInfo() {
- $this->TowerGate = new Ins_TowerGateInfo($this->TowerGate);
- return $this->TowerGate;
- }
- /**
- * 当前关卡信息
- * @return Ins_GateInfo
- */
- public function CurGateInfo() {
- $gateId = $this->CurrentGateId;
- my_Assert(StlUtil::dictHasProperty($this->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
- $gateInfo = ctx()->gates->GateList->$gateId;
- return $gateInfo;
- }
- /**
- * @return int 解锁下一剧情关卡
- */
- public function UnlockNextPlotGate($gateId) {
- $nextId = $gateId;
- foreach (GameConfig::gate() as $k => $v) {
- isEditor() and $v = new \sm_gate();
- if ($v->unlockGateId == $gateId) {
- $nextId = $v->gateId;
- }
- }
- // echoLine("解锁下一关卡 $nextId");
- if (Ins_GateInfo::gateNum($this->UnlockedGatesMaxId) < Ins_GateInfo::gateNum($nextId)# 下一关尚未解锁
- && !StlUtil::dictHasProperty($this->GateList, $nextId)) {
- // $this->CurrentGateId = $nextId; # 不再自动推到下一关, -2024.5.31
- $this->UnlockedGatesMaxId = $nextId;
- $gate = new Ins_GateInfo();
- $gate->GateId = $nextId;
- $this->GateList->$nextId = $gate;
- }
- return $nextId;
- }
- /**
- * @param int $gateId 通关的关卡id
- */
- public function UnlockMainChallengeGate($gateId) {
- $dic = GameConfig::gate();
- $index = 0; # 挑战关卡解锁逻辑. -gwang 2024年4月15日
- foreach ($dic as $id => $item) {
- if (Ins_GateInfo::GateTypeFromId($id) == Enum_GateType::MainChallengeGate #
- && $item->challengeGateId == $gateId) {
- $index += 1;
- $gate = new Ins_GateInfo();
- $gate->GateId = $id;
- ctx()->gates->GateList->$id = $gate;
- }
- if ($index >= 3) { # 最多3个难度
- break;
- }
- }
- }
- /**
- * 最大通关id
- */
- public function maxPassGateNumId() {
- $maxIndex = 0;
- //$maxGateId = 0;
- foreach ($this->GateList as $gateId => $Ins_GateInfo) {
- if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) {
- $maxIndex = Ins_GateInfo::gateNum($gateId);
- //$maxGateId = $gateId;
- }
- }
- return $maxIndex;
- }
- /**
- * 最大通关id
- */
- public function maxPassGateId() {
- $maxIndex = 0;
- $maxGateId = 0;
- foreach ($this->GateList as $gateId => $Ins_GateInfo) {
- if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) {
- $maxIndex = Ins_GateInfo::gateNum($gateId);
- $maxGateId = $gateId;
- }
- }
- return $maxGateId;
- }
- }
|