|
@@ -9,167 +9,130 @@ namespace loyalsoft;
|
|
|
class SweepGatesProc {
|
|
|
//
|
|
|
// <editor-fold defaultstate="collapsed" desc="三层关卡">
|
|
|
-
|
|
|
- /**
|
|
|
- * [6817]新版本的挑战地图关卡
|
|
|
- * @param req $req
|
|
|
- */
|
|
|
- public static function NewArenas_Fight($req) {
|
|
|
- # 提取参数
|
|
|
- $gateId = $req->paras[0]; # 0. 挑战的关卡Id
|
|
|
- $difficulty = $req->paras[1]; # 1. 关卡难度 difficulty
|
|
|
- $star = $req->paras[2]; # 2. 几星
|
|
|
- $TeamObj = $req->paras[3]; # 3. 队伍信息
|
|
|
- $bossId = $req->paras[4]; # 4. 本关消灭的bossid (<=0代表本关卡未出现boss)
|
|
|
- $rewards = $req->paras[5]; # 5. 本关获得的宝箱列表,id:num,id:num,...
|
|
|
-
|
|
|
- $smGate = GameConfig::gate_getItem($gateId); # 关卡配置数据
|
|
|
-///按 三个难度取不同的值.
|
|
|
- $i = $difficulty + 1;
|
|
|
- $tili = self::getProperty_n($smGate, "tili", $i);
|
|
|
-// $reward = self::getProperty_n($smGate, "reward", $i);
|
|
|
- $gold = self::getProperty_n($smGate, "gold", $i);
|
|
|
- $exp = self::getProperty_n($smGate, "exp", $i);
|
|
|
-
|
|
|
- self::newRecordFight($req, $gateId, $difficulty, $star); # 更新战斗记录
|
|
|
-
|
|
|
- $canfighterr = SweepGatesProc::CanFight($req, $gateId, $difficulty); # 是否可以挑战当前关卡计算
|
|
|
-
|
|
|
- if ($canfighterr) { # 不能符合战斗要求
|
|
|
- return $canfighterr;
|
|
|
- }
|
|
|
-//
|
|
|
- ActiveProc::ChangeTili(-$tili); # 扣减体力
|
|
|
- $req->userInfo->game->gates->TotalNum++; # 更新战斗次数统计
|
|
|
- $req->userInfo->game->gates->Times++;
|
|
|
-///增加英雄经验 组长去掉
|
|
|
- foreach ($TeamObj as $heroUID) {
|
|
|
- if ($heroUID > 0) {
|
|
|
- HeroProc::HeroAddEXP($heroUID, $tili);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $rewardsArr = explode(",", $rewards); // 开箱子抽奖品
|
|
|
- $rewardArr = array();
|
|
|
- foreach ($rewardsArr as $r) {
|
|
|
- $arr = explode(':', $r);
|
|
|
- $boxID = intval($arr[0]);
|
|
|
- $num = intval($arr[1]);
|
|
|
-// $boxMo = GameConfig::item_box_getItem($boxID);
|
|
|
- $boxPool = GameConfig::boxpool_getItem($boxID); # 提取对应序列的奖池,
|
|
|
- $itemArr = array_filter($boxPool, function($item) use($dropindex) { # 这一步形同虚设了. 所有dropType都填的1
|
|
|
- return $item->dropType == 1;
|
|
|
- });
|
|
|
- $itemArr = Lotterys::FilterPrizepool($req, $itemArr); # 对奖池依解锁等级进行过滤
|
|
|
- foreach ($itemArr as $item) {
|
|
|
- $prop = $item->normal;
|
|
|
- if ($prop < 0) {
|
|
|
- $prop = 0;
|
|
|
- }
|
|
|
- $item->probability = $prop;
|
|
|
- }
|
|
|
- $err = Lotterys::Dice($itemArr, $num, $rewardstr); # 投骰子
|
|
|
- if ($err != ErrCode::ok) { # 出错了
|
|
|
- return Resp::err($err);
|
|
|
- }
|
|
|
- if (strlen($rewardstr) <= 0) { # 抽奖结果为空
|
|
|
- return Resp::err(ErrCode::err_innerfault);
|
|
|
- }
|
|
|
- $rewardArr[] = $rewardstr;
|
|
|
- }
|
|
|
- if ($bossId > 0) { # boss关处理
|
|
|
- $req->userInfo->game->gates->killedBoss[] = $bossId;
|
|
|
- }
|
|
|
- UserGameModel::Add_Gold($req->userInfo->game, $gold); # 发放金币奖励
|
|
|
-
|
|
|
- UserGameModel::Add_Exp($req->userInfo->game, $exp); # 发放经验奖励
|
|
|
- UserProc::updateUserInfo(); # 在获取战利品哪里已经update了.
|
|
|
- $result = array(
|
|
|
- 'store' => $req->userInfo->game->store,
|
|
|
- 'heros' => $req->userInfo->game->heros,
|
|
|
- 'gates' => $req->userInfo->game->gates,
|
|
|
- 'tili' => $req->userInfo->game->tili,
|
|
|
- 'time' => $req->userInfo->game->privateState->TiliTime,
|
|
|
- 'gold' => $gold,
|
|
|
- 'exp' => $exp,
|
|
|
- 'rewardstr' => implode(';', $rewardArr)
|
|
|
- );
|
|
|
- return Resp::ok($result);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新战斗记录(新)
|
|
|
- * @param req $req
|
|
|
- * @param type $gateId
|
|
|
- * @param type $difficulty
|
|
|
- * @param type $star
|
|
|
- */
|
|
|
- private static function newRecordFight($req, $gateId, $difficulty, $star) {
|
|
|
- if (!CommUtil::isPropertyExists($req->userInfo->game->gates, "newGateRecord")) {
|
|
|
- $req->userInfo->game->gates->newGateRecord = ObjectInit(); # 防御未初始化的变量
|
|
|
- }
|
|
|
- $gatesRecord = $req->userInfo->game->gates->newGateRecord;
|
|
|
- if (!CommUtil::isPropertyExists($gatesRecord, "record")) { # 防御未初始化的变量
|
|
|
- $gatesRecord->record = ObjectInit();
|
|
|
- }
|
|
|
- if (!CommUtil::isPropertyExists($gatesRecord->record, $gateId)) { # 补充战斗记录
|
|
|
- $gatesRecord->record->$gateId = ObjectInit();
|
|
|
- }
|
|
|
-
|
|
|
- if ($difficulty <= 0) {
|
|
|
- $gatesRecord->record->$gateId->normal = $star;
|
|
|
- if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "normalToday")) {
|
|
|
- $gatesRecord->record->$gateId->normalToday = 0;
|
|
|
- }
|
|
|
- } else if ($difficulty == 1) {
|
|
|
- $gatesRecord->record->$gateId->hard = $star;
|
|
|
- if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "hardToday")) {
|
|
|
- $gatesRecord->record->$gateId->hardToday = 0;
|
|
|
- }
|
|
|
- } else if ($difficulty == 2) {
|
|
|
- $gatesRecord->record->$gateId->elite = $star;
|
|
|
- if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "eliteToday")) {
|
|
|
- $gatesRecord->record->$gateId->eliteToday = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- $req->userInfo->game->gates->newGateRecord = $gatesRecord; # 回写数据
|
|
|
- }
|
|
|
-
|
|
|
// /**
|
|
|
-// * [6818]更改地图所停留的城镇
|
|
|
-// * //需要消耗体力
|
|
|
-// * @param type $req
|
|
|
-// * @deprecated since version 0
|
|
|
+// * [6817]新版本的挑战地图关卡
|
|
|
+// * @param req $req
|
|
|
// */
|
|
|
-// public static function ChangeArenas_StayCity($req) {
|
|
|
-//# 提取参数
|
|
|
-//# 0. 目标地址
|
|
|
-//# 1. 消耗体力
|
|
|
-// $cityId = $req->paras[0];
|
|
|
-// $costTili = $req->paras[1];
|
|
|
-// if (!CommUtil::isPropertyExists($req->userInfo->game->gates, "newGateRecord")) {
|
|
|
-// $req->userInfo->game->gates->newGateRecord = ObjectInit();
|
|
|
+// public static function NewArenas_Fight($req) {
|
|
|
+// # 提取参数
|
|
|
+// $gateId = $req->paras[0]; # 0. 挑战的关卡Id
|
|
|
+// $difficulty = $req->paras[1]; # 1. 关卡难度 difficulty
|
|
|
+// $star = $req->paras[2]; # 2. 几星
|
|
|
+// $TeamObj = $req->paras[3]; # 3. 队伍信息
|
|
|
+// $bossId = $req->paras[4]; # 4. 本关消灭的bossid (<=0代表本关卡未出现boss)
|
|
|
+// $rewards = $req->paras[5]; # 5. 本关获得的宝箱列表,id:num,id:num,...
|
|
|
+//
|
|
|
+// $smGate = GameConfig::gate_getItem($gateId); # 关卡配置数据
|
|
|
+/////按 三个难度取不同的值.
|
|
|
+// $i = $difficulty + 1;
|
|
|
+// $tili = self::getProperty_n($smGate, "tili", $i);
|
|
|
+//// $reward = self::getProperty_n($smGate, "reward", $i);
|
|
|
+// $gold = self::getProperty_n($smGate, "gold", $i);
|
|
|
+// $exp = self::getProperty_n($smGate, "exp", $i);
|
|
|
+//
|
|
|
+// self::newRecordFight($req, $gateId, $difficulty, $star); # 更新战斗记录
|
|
|
+//
|
|
|
+// $canfighterr = SweepGatesProc::CanFight($req, $gateId, $difficulty); # 是否可以挑战当前关卡计算
|
|
|
+//
|
|
|
+// if ($canfighterr) { # 不能符合战斗要求
|
|
|
+// return $canfighterr;
|
|
|
+// }
|
|
|
+////
|
|
|
+// ActiveProc::ChangeTili(-$tili); # 扣减体力
|
|
|
+// $req->userInfo->game->gates->TotalNum++; # 更新战斗次数统计
|
|
|
+// $req->userInfo->game->gates->Times++;
|
|
|
+/////增加英雄经验 组长去掉
|
|
|
+// foreach ($TeamObj as $heroUID) {
|
|
|
+// if ($heroUID > 0) {
|
|
|
+// HeroProc::HeroAddEXP($heroUID, $tili);
|
|
|
+// }
|
|
|
// }
|
|
|
-// $gatesRecord = $req->userInfo->game->gates->newGateRecord;
|
|
|
//
|
|
|
-// #在此补充检查消耗体力的数值是否正确
|
|
|
-// #
|
|
|
-//
|
|
|
-// $gatesRecord->lastStayCityId = $cityId;
|
|
|
-// $req->userInfo->game->gates->newGateRecord = $gatesRecord;
|
|
|
-// #体力变化
|
|
|
-// ActiveProc::ChangeTili(-$costTili, $req);
|
|
|
-// UserProc::updateUserInfo($req);
|
|
|
+// $rewardsArr = explode(",", $rewards); // 开箱子抽奖品
|
|
|
+// $rewardArr = array();
|
|
|
+// foreach ($rewardsArr as $r) {
|
|
|
+// $arr = explode(':', $r);
|
|
|
+// $boxID = intval($arr[0]);
|
|
|
+// $num = intval($arr[1]);
|
|
|
+//// $boxMo = GameConfig::item_box_getItem($boxID);
|
|
|
+// $boxPool = GameConfig::boxpool_getItem($boxID); # 提取对应序列的奖池,
|
|
|
+// $itemArr = array_filter($boxPool, function($item) use($dropindex) { # 这一步形同虚设了. 所有dropType都填的1
|
|
|
+// return $item->dropType == 1;
|
|
|
+// });
|
|
|
+// $itemArr = Lotterys::FilterPrizepool($req, $itemArr); # 对奖池依解锁等级进行过滤
|
|
|
+// foreach ($itemArr as $item) {
|
|
|
+// $prop = $item->normal;
|
|
|
+// if ($prop < 0) {
|
|
|
+// $prop = 0;
|
|
|
+// }
|
|
|
+// $item->probability = $prop;
|
|
|
+// }
|
|
|
+// $err = Lotterys::Dice($itemArr, $num, $rewardstr); # 投骰子
|
|
|
+// if ($err != ErrCode::ok) { # 出错了
|
|
|
+// return Resp::err($err);
|
|
|
+// }
|
|
|
+// if (strlen($rewardstr) <= 0) { # 抽奖结果为空
|
|
|
+// return Resp::err(ErrCode::err_innerfault);
|
|
|
+// }
|
|
|
+// $rewardArr[] = $rewardstr;
|
|
|
+// }
|
|
|
+// if ($bossId > 0) { # boss关处理
|
|
|
+// $req->userInfo->game->gates->killedBoss[] = $bossId;
|
|
|
+// }
|
|
|
+// UserGameModel::Add_Gold($req->userInfo->game, $gold); # 发放金币奖励
|
|
|
//
|
|
|
+// UserGameModel::Add_Exp($req->userInfo->game, $exp); # 发放经验奖励
|
|
|
+// UserProc::updateUserInfo(); # 在获取战利品哪里已经update了.
|
|
|
// $result = array(
|
|
|
+// 'store' => $req->userInfo->game->store,
|
|
|
+// 'heros' => $req->userInfo->game->heros,
|
|
|
// 'gates' => $req->userInfo->game->gates,
|
|
|
// 'tili' => $req->userInfo->game->tili,
|
|
|
// 'time' => $req->userInfo->game->privateState->TiliTime,
|
|
|
+// 'gold' => $gold,
|
|
|
+// 'exp' => $exp,
|
|
|
+// 'rewardstr' => implode(';', $rewardArr)
|
|
|
// );
|
|
|
// return Resp::ok($result);
|
|
|
// }
|
|
|
-// </editor-fold>
|
|
|
//
|
|
|
+// /**
|
|
|
+// * 更新战斗记录(新)
|
|
|
+// * @param req $req
|
|
|
+// * @param type $gateId
|
|
|
+// * @param type $difficulty
|
|
|
+// * @param type $star
|
|
|
+// */
|
|
|
+// private static function newRecordFight($req, $gateId, $difficulty, $star) {
|
|
|
+// if (!CommUtil::isPropertyExists($req->userInfo->game->gates, "newGateRecord")) {
|
|
|
+// $req->userInfo->game->gates->newGateRecord = ObjectInit(); # 防御未初始化的变量
|
|
|
+// }
|
|
|
+// $gatesRecord = $req->userInfo->game->gates->newGateRecord;
|
|
|
+// if (!CommUtil::isPropertyExists($gatesRecord, "record")) { # 防御未初始化的变量
|
|
|
+// $gatesRecord->record = ObjectInit();
|
|
|
+// }
|
|
|
+// if (!CommUtil::isPropertyExists($gatesRecord->record, $gateId)) { # 补充战斗记录
|
|
|
+// $gatesRecord->record->$gateId = ObjectInit();
|
|
|
+// }
|
|
|
+//
|
|
|
+// if ($difficulty <= 0) {
|
|
|
+// $gatesRecord->record->$gateId->normal = $star;
|
|
|
+// if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "normalToday")) {
|
|
|
+// $gatesRecord->record->$gateId->normalToday = 0;
|
|
|
+// }
|
|
|
+// } else if ($difficulty == 1) {
|
|
|
+// $gatesRecord->record->$gateId->hard = $star;
|
|
|
+// if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "hardToday")) {
|
|
|
+// $gatesRecord->record->$gateId->hardToday = 0;
|
|
|
+// }
|
|
|
+// } else if ($difficulty == 2) {
|
|
|
+// $gatesRecord->record->$gateId->elite = $star;
|
|
|
+// if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "eliteToday")) {
|
|
|
+// $gatesRecord->record->$gateId->eliteToday = 0;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $req->userInfo->game->gates->newGateRecord = $gatesRecord; # 回写数据
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 提取某个对象的某个字段(利用后面2个参数组合为字段名)
|
|
@@ -331,51 +294,13 @@ class SweepGatesProc {
|
|
|
|
|
|
//
|
|
|
// <editor-fold defaultstate="collapsed" desc=" 扫荡 ">
|
|
|
-// /**
|
|
|
-// * 关卡-扫荡
|
|
|
-// * @param RequestVo $req
|
|
|
-// */
|
|
|
-// public static function Arenas_SweepFight($req)
|
|
|
-// {
|
|
|
-// $resp = ResponseVo::err($req, ErrCode::msg_methodnotimplement);
|
|
|
-// # 提取参数
|
|
|
-// # 0. 扫荡的关卡Id
|
|
|
-// # 1. 扫荡次数
|
|
|
-// # 2. 挑战记录 // 验证之用.
|
|
|
-// $gateId = $req->paras[0];
|
|
|
-// $iNum = $req->paras[1];
|
|
|
-// $fightLog = $req->paras[2];
|
|
|
-// $isNewbieGuideGate = false;
|
|
|
-// $gates = $req->userInfo->game->gates;
|
|
|
-// if ($gateId == 504001) {
|
|
|
-// $isNewbieGuideGate = true;
|
|
|
-// }
|
|
|
-// if ($iNum && !$fightLog) {# 检查挑战记录
|
|
|
-// return ResponseVo::err($req, ErrCode::err_arenas_logillegal);
|
|
|
-// }
|
|
|
-// if (!$isNewbieGuideGate) {
|
|
|
-// if ($gateId > $gates->highest + 1) { # 不能跳关
|
|
|
-// return ResponseVo::err($req, ErrCode::err_arenasgate_indexillegal);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// #记录数据
|
|
|
-// $uGate = new UGateModel();
|
|
|
-// if (isset($gates->gates->$gateId)) {
|
|
|
-// $uGate = $gates->gates->$gateId;
|
|
|
-// }
|
|
|
-// $uGate->challengeTimes += $iNum;
|
|
|
-// $gates->gates->$gateId = $uGate;
|
|
|
-// UserProc::updateUserInfo($req);
|
|
|
-// $resp = ResponseVo::ok($req, array()); // 返回成功,以及奖励数据
|
|
|
-//
|
|
|
-// return $resp;
|
|
|
-// }
|
|
|
|
|
|
/**
|
|
|
* [6802]新扫荡
|
|
|
* @param req $req
|
|
|
*/
|
|
|
public static function Arenas_NewSweepFight($req) {
|
|
|
+
|
|
|
$gateId = $req->paras[0];
|
|
|
$difficulty = $req->paras[1]; # 关卡难度 difficulty
|
|
|
$costItemId = $req->paras[2]; #扫荡券id
|
|
@@ -507,86 +432,6 @@ class SweepGatesProc {
|
|
|
|
|
|
// </editor-fold>
|
|
|
//
|
|
|
-
|
|
|
- /**
|
|
|
- * [6803] 关卡—————— 根据星星数量获得对应奖励
|
|
|
- * @param type $req
|
|
|
- * @deprecated since version 0 用新版
|
|
|
- */
|
|
|
- public static function GetArenasStarReward($req) {
|
|
|
- return Resp::err(ErrCode::err_method_notimplement); # 屏蔽此方法
|
|
|
-
|
|
|
- $rewardID = $req->paras[0]; //奖励的数据ID
|
|
|
-
|
|
|
- $rewardCfg = GameConfig::gate_starreward_getItem($rewardID);
|
|
|
- if (!$rewardCfg) { //1.检查奖励数据是否存在
|
|
|
- return Resp::err(ErrCode::err_arenas_starreward_const_no);
|
|
|
- }
|
|
|
- $gates = $req->userInfo->game->gates;
|
|
|
- $getStarRewardRecord = ArrayInit();
|
|
|
- if (CommUtil::isPropertyExists($gates, "starRewards")) { //2.检查玩家是否已经领取了
|
|
|
- $getStarRewardRecord = $gates->starRewards;
|
|
|
- }
|
|
|
- if (CommUtil::isInArray($getStarRewardRecord, $rewardID)) {
|
|
|
- return Resp::err(ErrCode::err_arenas_hasgetstarreward);
|
|
|
- }
|
|
|
-
|
|
|
- $totalStarNum = 0; # 总得星数
|
|
|
- $normalRecord = $gates->normal;
|
|
|
- foreach ($normalRecord->gates as $key => $gate) {
|
|
|
- $totalStarNum += $gate->star;
|
|
|
- }
|
|
|
-
|
|
|
- $hardRecord = $gates->hard;
|
|
|
- foreach ($hardRecord->gates as $key => $gate) {
|
|
|
- $totalStarNum += $gate->star;
|
|
|
- }
|
|
|
-
|
|
|
- $eliteRecord = $gates->elite;
|
|
|
- foreach ($eliteRecord->gates as $key => $gate) {
|
|
|
- $totalStarNum += $gate->star;
|
|
|
- }
|
|
|
-
|
|
|
- DebugHelper::var_dump($totalStarNum);
|
|
|
- if ($totalStarNum < $rewardCfg->star) { //3.检查玩家的当前星星数是否满足数量要求
|
|
|
- return Resp::err(ErrCode::err_arenas_starreward_starNotEnough);
|
|
|
- }
|
|
|
- $rewardStr = $rewardCfg->reward;
|
|
|
- $arr_reward = explode(",", $rewardStr);
|
|
|
- $itemId = $arr_reward[0];
|
|
|
- $itemNum = $arr_reward[1];
|
|
|
- $str1 = substr($itemId, 0, 3);
|
|
|
- switch ($str1) {
|
|
|
- case "101": ///怪物卡或者英雄卡牌获取
|
|
|
- case "201":
|
|
|
-// HeroProc::AddHeroTFromStore($req, $itemId);
|
|
|
- break;
|
|
|
- case "301": ///装备物品的获取.
|
|
|
- case "302":
|
|
|
- case "303":
|
|
|
- StoreProc::PutEquipInStore($itemId, $req);
|
|
|
- break;
|
|
|
- case "304": // 宝石的获取
|
|
|
- StoreProc:: PutOverlyingItemInStore($itemId, $itemNum);
|
|
|
- break;
|
|
|
- case "399":
|
|
|
- if ($itemId == "399002") { // 金币的获取
|
|
|
- UserGameModel::Add_Gold($req->userInfo->game, $itemNum);
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- $getStarRewardRecord[] = $rewardID; // 保存记录
|
|
|
- $req->userInfo->game->gates->starRewards = $getStarRewardRecord;
|
|
|
- UserProc::updateUserInfo(); // 更新数据库数据
|
|
|
- $result = array(
|
|
|
- "getreward" => true
|
|
|
- );
|
|
|
- return Resp::ok($result);
|
|
|
- }
|
|
|
-
|
|
|
//
|
|
|
// <editor-fold defaultstate="collapsed" desc=" 好友租借 ">
|
|
|
// /**
|