cmd) { case CmdCode::fight_settle: # 6801 主线战斗结算 return FightProc::Settle(); case CmdCode::fight_PassGateTsPrizeReceive: # 6802 章节宝箱的领取 return FightProc::PassGateTsPrizeReceive(); case CmdCode::fight_selectGate: # 6803 主线剧情关卡选择 return FightProc::SelectGate(); case CmdCode::fight_gateChallengePriceReviced: # 6804 挑战关卡: 领取奖励 return FightProc::GateChallengePriceReviced(); case CmdCode::fihgt_towerStart: # 6805 挑战关卡: 开始挑战 return FightProc::ChallengeGateStartFight(); case CmdCode::fight_plotSav: # 6806 主线剧情(已播放)回存 return FightProc::PlotSav(); case CmdCode::fight_sweep: # 6807 主线扫荡 return FightProc::FightSweep(); case CmdCode::fight_startFight: # 6808 主线剧情关卡开始挑战 return self::StartFight(); default: Err(ErrCode::cmd_err); } } /** * 6807 扫荡 * @return type */ public static function FightSweep() { //list($gateId) = req()->paras; my_Assert(ctx()->gates->UnlockedGatesMaxId != 0, ErrCode::user_Gate_NoSweep); $mo = GameConfig::gate_getItem(ctx()->gates->UnlockedGatesMaxId); $costTili = glc()->sweep_cost_tili; my_Assert(ctx()->baseInfo->tili >= $costTili, ErrCode::notenough_tili); $max = glc()->sweepMaxNum; my_Assert(ctx()->gates->fightSweepNum < $max, ErrCode::user_Gate_SweepMaxNum_limit); ctx()->gates->fightSweepNum += 1; ctx()->baseInfo->Consume_tili($costTili); $prizeArr = array(); $prizeArr[] = $mo->reward_win; if ($mo->sweep_gold != null) { $goodsStr = self::sweepRandReward($mo->sweep_gold); $prizeArr[] = $goodsStr; StoreProc::AddMultiItemInStore($goodsStr); } if ($mo->sweep_tuzhi != null) { $goodsStr = self::sweepRandReward($mo->sweep_tuzhi); $prizeArr[] = $goodsStr; StoreProc::AddMultiItemInStore($goodsStr); } if ($mo->sweep_gem != null) { $goodsStr = self::sweepRandReward($mo->sweep_gem); $list = explode(',', $goodsStr); $posId = rand(1, 6); $qual = $list[0]; $dic = GameConfig::gem(); foreach ($dic as $key => $gemMo) { if ($gemMo->qual == $qual && $gemMo->position == $posId) { $prizeArr[] = $gemMo->typeId . ',' . $list[1]; StoreProc::PutGemInStore($gemMo->typeId, $list[1]); break; } } } if ($mo->sweep_qiling != null) { $goodsStr = self::sweepRandReward($mo->sweep_qiling); $prizeArr[] = $goodsStr; StoreProc::AddMultiItemInStore($goodsStr); } UserProc::updateUserInfo(); $ret = array( 'tili' => ctx()->baseInfo->tili, 'fightSweepNum' => ctx()->gates->fightSweepNum, 'prizeArr' => $prizeArr, 'store' => ctx()->store, ); return Resp::ok($ret); } static function sweepRandReward($rewardStr) { $ctxArr = explode(';', $rewardStr); $numArr = explode('-', $ctxArr[0]); $num = rand($numArr[0], $numArr[1]); $randNum = rand(1, 100); $start = 0; $end = 0; $res = ""; $itemArr = explode(',', $ctxArr[1]); foreach ($itemArr as $str) { $arr = explode(':', $str); $itemId = $arr[1]; $per = $arr[2]; $end += $per; if ($randNum >= $start && $randNum < $end) { $res = $itemId; break; } $start = $end; } return $res . ',' . $num; } /** * 6808 主线关卡: 开始挑战 (扣除体力) */ private static function StartFight() { list($gateId) = req()->paras; my_Assert($gateId > 0, ErrCode::paras_err); $mo = GameConfig::gate_getItem($gateId); my_Assert(null != $mo, ErrCode::err_const_no); my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili); return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts)); } /** * [废弃] 6807 巡逻奖励领取 * @return type */ public static function XunluoPrizeReceived() { list($type) = req()->paras; $gateId = ctx()->gates->UnlockedGatesMaxId; $gateMo = GameConfig::gate_getItem($gateId); my_Assert($gateMo != null, ErrCode::err_const_no); if ($type == 1) {//巡逻 $curTs = now(); $startTs = ctx()->gates->xunluo_StartTs; $ts = $curTs - $startTs; $ts2 = intval($ts / 60); //总的分钟数 $fenzhong = intval($ts2 / 10); //有几个10分钟 $gold = 0; $exp = 0; $price = ""; if ($fenzhong > 0) { $gold = intval($gateMo->gold_xunluo / 6 * $fenzhong); $exp = intval($gateMo->exp_xunluo / 6 * $fenzhong); $price = "1," . $gold . ';' . "4," . $exp; } $itemStr = explode(';', $gateMo->xunluo_item_ts); $itemId = 0; $itemNum = 0; $tempTs = 0; foreach ($itemStr as $s) { $arr = explode('-', $s); $tsItemArr = explode(',', $arr[0]); $sTs = $tsItemArr[0]; //开始时间 $eTs = $tsItemArr[1]; //终止时间 $produceTs = $tsItemArr[2]; //间隔 while (true) { $tempTs += $produceTs; if ($tempTs <= $eTs && $tempTs <= $ts2) { $sList = explode(',', $arr[1]); $itemId = $sList[0]; $itemNum += $sList[1]; } if ($tempTs >= $ts2) { break; } if ($tempTs >= $eTs) { $tempTs = $eTs; break; } } if ($tempTs >= $ts2) { break; } } if ($itemNum > 0) { $price = $price . ";" . $itemId . ',' . $itemNum; } //--------------------------- $tuzhiStr = explode(';', $gateMo->xunluo_tuzhi_ts); $tuzhiId = 0; $tuzhiNum = 0; $tempTs2 = 0; foreach ($tuzhiStr as $s) { $arr = explode('-', $s); $tsItemArr = explode(',', $arr[0]); $sTs = $tsItemArr[0]; //开始时间 $eTs = $tsItemArr[1]; //终止时间 $produceTs = $tsItemArr[2]; //间隔 while (true) { $tempTs2 += $produceTs; if ($tempTs2 <= $eTs && $tempTs2 <= $ts2) { $sList = explode(',', $arr[1]); $tuzhiId = $sList[0]; $tuzhiNum += $sList[1]; } if ($tempTs2 >= $ts2) { break; } if ($tempTs2 >= $eTs) { $tempTs2 = $eTs; break; } } if ($tempTs2 >= $ts2) { break; } } if ($tuzhiNum > 0) { $price = $price . ";" . $tuzhiId . ',' . $tuzhiNum; } //--------------------- $equipStr = explode(';', $gateMo->xunluo_equip_ts); $equipId = 0; $equipNum = 0; $tempTs3 = 0; foreach ($equipStr as $s) { $arr = explode('-', $s); $tsItemArr = explode(',', $arr[0]); $sTs = $tsItemArr[0]; //开始时间 $eTs = $tsItemArr[1]; //终止时间 $produceTs = $tsItemArr[2]; //间隔 while (true) { $tempTs3 += $produceTs; if ($tempTs3 <= $eTs && $tempTs3 <= $ts2) { $sList = explode(',', $arr[1]); $equipId = $sList[0]; $equipNum += $sList[1]; } if ($tempTs3 >= $ts2) { break; } if ($tempTs3 >= $eTs) { $tempTs3 = $eTs; break; } } if ($tempTs3 >= $ts2) { break; } } if ($equipNum > 0) { $price = $price . ";" . $equipId . ',' . $equipNum; } StoreProc::AddMultiItemInStore($price); ctx()->gates->xunluo_StartTs = now(); } else {//快速巡逻 my_Assert(ctx()->gates->xunluo_quick_buyRecord < $gateMo->xueluo_quick_num, ErrCode::err_const_no); ctx()->gates->xunluo_quick_buyRecord += 1; ctx()->baseInfo->Consume_tili(15); StoreProc::AddMultiItemInStore($gateMo->xueluo_quick_reward); } UserProc::updateUserInfo(); $ret = array( 'tili' => ctx()->baseInfo->tili, 'gates' => ctx()->gates, ); return Resp::ok($ret); } public static function FightDailyClear() { //ctx()->gates->xunluo_quick_buyRecord = 0; ctx()->gates->fightSweepNum = 0; } /** * 6806 剧情回存 * @return type */ public static function PlotSav() { list($gateId) = req()->paras; my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::err_const_no); ctx()->gates->GateList->$gateId->plotStart = 1; UserProc::updateUserInfo(); $ret = array( 'ok' => 1, ); return Resp::ok($ret); } /** * 6805 挑战关卡: 开始挑战(扣除次数) * @return type */ public static function ChallengeGateStartFight() { list($type, $id) = req()->paras; UserProc::updateUserInfo(); $ret = array( 'store' => ctx()->store, 'gates' => ctx()->gates, ); return Resp::ok($ret); } /** * 6804 挑战关卡: 奖励领取 * @return type */ public static function GateChallengePriceReviced() { list($zhangjieId, $gateId) = req()->paras; $gateMo = GameConfig::gate_getItem($gateId); my_Assert($gateMo != null, ErrCode::err_const_no); if (!StlUtil::dictHasProperty(ctx()->gates->GatesChallengeRecord, $zhangjieId)) { ctx()->gates->GatesChallengeRecord->$zhangjieId = array(); } my_Assert(!in_array($gateId, ctx()->gates->GatesChallengeRecord->$zhangjieId), ErrCode::user_Gate_GatePriceHasReceive); my_Assert(in_array($gateMo->challengeUnlockId, ctx()->gates->GatesChallengeRecord->$zhangjieId), ErrCode::user_Gate_GateNoUnlock); ctx()->gates->GatesChallengeRecord->$zhangjieId[] = $gateId; StoreProc::AddMultiItemInStore($gateMo->reward_win); ctx()->gates->CurrentGateId = $gateId; UserProc::updateUserInfo(); $ret = array( 'store' => ctx()->store, 'gates' => ctx()->gates, ); return Resp::ok($ret); } /** * 6803 关卡选择 * @return type */ public static function SelectGate() { list($gateId) = req()->paras; ctx()->gates->CurrentGateId = $gateId; UserProc::updateUserInfo(); $ret = array( 'gates' => ctx()->gates, ); return Resp::ok($ret); } /** * 6802 章节宝箱的领取 * @return type */ public static function PassGateTsPrizeReceive() { list($gateId, $index) = req()->paras; $gateMo = GameConfig::gate_getItem($gateId); my_Assert($gateMo != null, ErrCode::err_const_no); my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo); $gateInfo = ctx()->gates->GateList->$gateId; $tag = false; $prize = ""; $mask = 0; switch ($index) { case 1: $ts = $gateMo->first_ts1 * 60; if ($gateInfo->MaxSeconds >= $ts) { $tag = true; } $mask = 1; $prize = $gateMo->first_reward1; break; case 2: $ts = $gateMo->first_ts2 * 60; if ($gateInfo->MaxSeconds >= $ts) { $tag = true; } $mask = 2; $prize = $gateMo->first_reward2; break; case 3: if ($gateInfo->pass > 0) { $tag = true; } $mask = 3; $prize = $gateMo->first_reward3; break; default: break; } if ($tag) { my_Assert($mask > $gateInfo->FirstReward, ErrCode::user_Gate_GatePriceHasReceive); $gateInfo->FirstReward = $mask; StoreProc::AddMultiItemInStore($prize); } ctx()->gates->GateList->$gateId = $gateInfo; UserProc::updateUserInfo(); $ret = array( 'gates' => ctx()->gates, 'store' => ctx()->store, ); return Resp::ok($ret); } /** * [6801]关卡战斗结算 * @return type */ public static function Settle() { list($resultType, $gateId, $gold, $curTs, $pickups) = req()->paras; $gateMo = GameConfig::gate_getItem($gateId); my_Assert($gateMo != null, ErrCode::err_const_no); my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo); $gateInfo = ctx()->gates->GateList->$gateId; $ts = $gateInfo->MaxSeconds; if ($curTs >= $ts) { $gateInfo->MaxSeconds = $curTs; } if ($resultType) { # 胜利 if (ctx()->gates->GateList->$gateId->pass == 0) { ctx()->gates->GateList->$gateId->pass = 1; } StoreProc::AddMultiItemInStore($gateMo->reward_win); if (Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainStoryGate) { ctx()->gates->UnlockNextPlotGate(); $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) { break; } } } else { } } else { # 失败 StoreProc::AddMultiItemInStore($gateMo->reward_fail); } StoreProc::AddMultiItemInStore($pickups); # 战场拾取道具 ctx()->baseInfo->Add_Gold($gold); //ctx()->baseInfo->Add_Exp($exp); UserProc::updateUserInfo(); $ret = array( 'gates' => ctx()->gates, 'store' => ctx()->store, ); return Resp::ok($ret); } }