|
@@ -195,7 +195,9 @@ class SweepGatesProc {
|
|
public static function Arenas_Fight($req) {
|
|
public static function Arenas_Fight($req) {
|
|
list($gateId, $difficulty, $star, $TeamObj) = $req->paras; # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍
|
|
list($gateId, $difficulty, $star, $TeamObj) = $req->paras; # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍
|
|
Resp::assert($gateId > 0, "关卡id非法");
|
|
Resp::assert($gateId > 0, "关卡id非法");
|
|
- $err = self::recordFight($req, $gateId, $difficulty, $star); # 挑战记录
|
|
|
|
|
|
+ $isFirst = false; # 是否首次通关
|
|
|
|
+
|
|
|
|
+ $err = self::recordFight($req, $gateId, $difficulty, $star, $isFirst); # 挑战记录
|
|
if (ErrCode::ok != $err) {
|
|
if (ErrCode::ok != $err) {
|
|
return Resp::err($err);
|
|
return Resp::err($err);
|
|
}
|
|
}
|
|
@@ -203,6 +205,7 @@ class SweepGatesProc {
|
|
$i = $difficulty + 1; # 按三个难度取不同的值.
|
|
$i = $difficulty + 1; # 按三个难度取不同的值.
|
|
// $tili = self::getProperty_n($smGate, "tili", $i); # 体力暂时未用上
|
|
// $tili = self::getProperty_n($smGate, "tili", $i); # 体力暂时未用上
|
|
$rwdstr = self::getProperty_n($smGate, "reward", $i);
|
|
$rwdstr = self::getProperty_n($smGate, "reward", $i);
|
|
|
|
+ $firstPassRewardStr = self::getProperty_n($smGate, 'first_reward', $i);
|
|
$gold = self::getProperty_n($smGate, "gold", $i);
|
|
$gold = self::getProperty_n($smGate, "gold", $i);
|
|
$exp = self::getProperty_n($smGate, "exp", $i);
|
|
$exp = self::getProperty_n($smGate, "exp", $i);
|
|
$heroExp = self::getProperty_n($smGate, "heroExp", $i);
|
|
$heroExp = self::getProperty_n($smGate, "heroExp", $i);
|
|
@@ -214,21 +217,12 @@ class SweepGatesProc {
|
|
HeroProc::HeroAddEXP($heroUID, $heroExp, $req); # 增加英雄经验
|
|
HeroProc::HeroAddEXP($heroUID, $heroExp, $req); # 增加英雄经验
|
|
}
|
|
}
|
|
|
|
|
|
- $rewardsArr = explode(";", $rwdstr); # 计算奖品
|
|
|
|
- $rewardArr = array();
|
|
|
|
- foreach ($rewardsArr as $r) { #
|
|
|
|
- if (strlen($r) <= 0) { # 抽奖结果为空
|
|
|
|
- return Resp::err(ErrCode::err_innerfault);
|
|
|
|
- }
|
|
|
|
- $percent = explode(',', $r)[2];
|
|
|
|
- if (CommUtil::randomPercent($percent)) {
|
|
|
|
- $err = StoreProc::AddMultiItemInStore($req, $r); # 发放战利品
|
|
|
|
- if ($err != ErrCode::ok) { # 出错了
|
|
|
|
- return Resp::err($err);
|
|
|
|
- }
|
|
|
|
- $rewardArr[] = substr($r, 0, strrpos($r, ',')); # 剔除最后一段概率字符串
|
|
|
|
- }
|
|
|
|
|
|
+ $rewardArr = array(); # 统计所获奖励物品
|
|
|
|
+ $rewardArr = array_merge($rewardArr, self::SetRewards($req, $rwdstr)); # 通关奖励
|
|
|
|
+ if ($isFirst) { # 首次通关奖励
|
|
|
|
+ $rewardArr = array_merge($rewardArr, self::SetRewards($req, $firstPassRewardStr));
|
|
}
|
|
}
|
|
|
|
+
|
|
UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold); # 发金币
|
|
UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold); # 发金币
|
|
UserGameModel::Add_Exp($req, $exp); # 给玩家(指挥官)增加经验
|
|
UserGameModel::Add_Exp($req, $exp); # 给玩家(指挥官)增加经验
|
|
|
|
|
|
@@ -247,6 +241,31 @@ class SweepGatesProc {
|
|
return Resp::ok($result);
|
|
return Resp::ok($result);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 发放奖励串
|
|
|
|
+ * @param Req $req
|
|
|
|
+ * @param type $rewardStr
|
|
|
|
+ */
|
|
|
|
+ public static function SetRewards($req, $rewardStr) {
|
|
|
|
+ $getedArr = array(); # 统计所获奖励物品
|
|
|
|
+ $rewardsArr = explode(";", $rewardStr);
|
|
|
|
+ foreach ($rewardsArr as $r) { #
|
|
|
|
+ if (strlen($r) <= 0) { # 奖励串为空
|
|
|
|
+ Err(ErrCode::err_innerfault);
|
|
|
|
+ }
|
|
|
|
+ $percentStr = explode(',', $r)[2];
|
|
|
|
+ $percent = intval(trim($percentStr, "%")); # 剔除%
|
|
|
|
+ if (CommUtil::randomPercent($percent)) {
|
|
|
|
+ $err = StoreProc::AddMultiItemInStore($req, $r); # 发放奖励物品
|
|
|
|
+ if ($err != ErrCode::ok) { # 出错了
|
|
|
|
+ Err($err);
|
|
|
|
+ }
|
|
|
|
+ $getedArr[] = substr($r, 0, strrpos($r, ',')); # 剔除最后一段概率字符串
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $getedArr;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更新战斗记录
|
|
* 更新战斗记录
|
|
* @param req $req
|
|
* @param req $req
|
|
@@ -254,7 +273,7 @@ class SweepGatesProc {
|
|
* @param type $difficulty
|
|
* @param type $difficulty
|
|
* @param type $star
|
|
* @param type $star
|
|
*/
|
|
*/
|
|
- private static function recordFight($req, $gateId, $difficulty, $star) {
|
|
|
|
|
|
+ private static function recordFight($req, $gateId, $difficulty, $star, $isFirst = false) {
|
|
$userGates = $req->userInfo->game->gates;
|
|
$userGates = $req->userInfo->game->gates;
|
|
if ($difficulty == 0) { # 按照难度查找
|
|
if ($difficulty == 0) { # 按照难度查找
|
|
$diffCult = $userGates->normal;
|
|
$diffCult = $userGates->normal;
|
|
@@ -289,8 +308,10 @@ class SweepGatesProc {
|
|
$uGate->star = $star;
|
|
$uGate->star = $star;
|
|
}
|
|
}
|
|
|
|
|
|
- $uGate->cleared = 1; # 当前关卡是否已通关
|
|
|
|
-
|
|
|
|
|
|
+ if (!$uGate->cleared) {
|
|
|
|
+ $uGate->cleared = 1; # 当前关卡是否已通关
|
|
|
|
+ $isFirst = true;
|
|
|
|
+ }
|
|
$diffCult->gates->$gateId = $uGate; # 回写关卡记录
|
|
$diffCult->gates->$gateId = $uGate; # 回写关卡记录
|
|
|
|
|
|
$userGates->TotalNum++; # 总战斗次数+1
|
|
$userGates->TotalNum++; # 总战斗次数+1
|