/** * [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); # 扣减体力 $req->userInfo->game->gates->TotalNum++; # 更新战斗次数统计 $req->userInfo->game->gates->Times++; ///增加英雄经验 组长去掉 foreach ($TeamObj as $heroUID) { HeroProc::HeroAddEXP($heroUID, $tili, $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; } $err = UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold); # 发放金币奖励 if ($err != ErrCode::ok) { return Resp::err($err); } UserGameModel::Add_Exp($req, $exp); # 发放经验奖励 UserProc::updateUserInfo($req); # 在获取战利品哪里已经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 // */ // 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(); // } // $gatesRecord = $req->userInfo->game->gates->newGateRecord; // // #在此补充检查消耗体力的数值是否正确 // # // // $gatesRecord->lastStayCityId = $cityId; // $req->userInfo->game->gates->newGateRecord = $gatesRecord; // #体力变化 // ActiveProc::ChangeTili(-$costTili, $req); // UserProc::updateUserInfo($req); // // $result = array( // 'gates' => $req->userInfo->game->gates, // 'tili' => $req->userInfo->game->tili, // 'time' => $req->userInfo->game->privateState->TiliTime, // ); // return Resp::ok($result); // } // // /** * 提取某个对象的某个字段(利用后面2个参数组合为字段名) * @param type $obj * @param type $name * @param type $index * @return type */ private static function getProperty_n($obj, $name, $index) { if (is_object($obj)) { $ke = "$name$index"; if (property_exists($obj, $ke)) { return $obj->$ke; } } return null; } /** * [6801] 关卡挑战1次 * @param Req $req */ public static function Arenas_Fight($req) { list($gateId, $difficulty, $star, $TeamObj) = $req->paras; # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍 Resp::assert($gateId > 0, "关卡id非法"); $err = self::recordFight($req, $gateId, $difficulty, $star); # 挑战记录 if (ErrCode::ok != $err) { return Resp::err($err); } $smGate = GameConfig::gate_getItem($gateId); # 关卡配置数据 $i = $difficulty + 1; # 按三个难度取不同的值. // $tili = self::getProperty_n($smGate, "tili", $i); # 体力暂时未用上 $rwdstr = self::getProperty_n($smGate, "reward", $i); $gold = self::getProperty_n($smGate, "gold", $i); $exp = self::getProperty_n($smGate, "exp", $i); $heroExp = self::getProperty_n($smGate, "heroExp", $i); // ActiveProc::ChangeTili(-$tili, $req); # 扣减体力变化 // UserGameModel::Add_Exp($req->mem, $req->userInfo->game, $tili); # 老的增加玩家经验的去掉 // foreach ($TeamObj as $heroUID) { 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, ',')); # 剔除最后一段概率字符串 } } UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold); # 发金币 UserGameModel::Add_Exp($req, $exp); # 给玩家(指挥官)增加经验 UserProc::updateUserInfo($req); # 回写玩家数据. $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 recordFight($req, $gateId, $difficulty, $star) { $userGates = $req->userInfo->game->gates; if ($difficulty == 0) { # 按照难度查找 $diffCult = $userGates->normal; } else if ($difficulty == 1) { $diffCult = $userGates->hard; } else if ($difficulty == 2) { $diffCult = $userGates->elite; } else { return ErrCode::err_arenas_difficulty; # 找不到难度类型 } $typeId = substr($diffCult->highest, 0, 3); # 防御: 分类头不对 if ($typeId != '503') { $diffCult->highest = 503000; # 设置为关卡第一关 } if ($gateId > $diffCult->highest + 1) { # 不能跳关 return ErrCode::err_arenasgate_indexillegal; } if ($gateId == $diffCult->highest + 1 && $star > 0) { # 星级大于等于0,才可以推关 $diffCult->highest += 1; # 更新最高记录 } $diffCult->latest = $gateId; # 记录上次挑战关卡id $uGate = new UGateModel(); # 当前关卡的记录数据 if (isset($diffCult->gates->$gateId)) { $uGate = $diffCult->gates->$gateId; } $uGate->challengeTimes++; # 当前关卡挑战次数 if ($uGate->star < $star) { # 当前关卡得分评星 $uGate->star = $star; } $uGate->cleared = 1; # 当前关卡是否已通关 $diffCult->gates->$gateId = $uGate; # 回写关卡记录 $userGates->TotalNum++; # 总战斗次数+1 $userGates->Times++; $req->userInfo->game->gates = $userGates; # 回写数据 return ErrCode::ok; } /** * 清理每个难度副本的每日战斗次数 * @param Req $req */ public static function ClearGateTimes($req) { $req->userInfo->game->gates->Times = 0; } // // // /** // * 关卡-扫荡 // * @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 $smGate = GameConfig::gate_getItem($gateId); 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(); # 防御未初始化的变量 } ///按 三个难度取不同的值. $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); $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $costItemId, 1); if ($err) { # 扣除失败 return Resp::err($err); } #补充战斗记录 $canfighterr = SweepGatesProc::CanFight($req, $gateId, $difficulty); if ($canfighterr) {#不能符合战斗要求 return $canfighterr; } // $req->userInfo->game->gates->newGateRecord = $gatesRecord; # 回写数据 ActiveProc::ChangeTili(- $tili, $req); # 扣减体力 $req->userInfo->game->gates->TotalNum++; # 更新战斗次数统计 $req->userInfo->game->gates->Times++; // 按照概率规则发放奖品 $rewardsArr = explode(";", $reward); $rwds = array(); foreach ($rewardsArr as $r) { $arr = explode(',', $r); $itemid = intval($arr[0]); $num = intval($arr[1]); $probability = intval($arr[2]); if (CommUtil::randomPercent($probability)) { # 投色子 $err = StoreProc::AddMultiItemInStore($req, "$itemid,$num"); if ($err) { return Resp::err($err); } $rwds[] = "$itemid,$num"; } } UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold); # 发放金币奖励 if ($err) { return Resp::err($err); } UserGameModel::Add_Exp($req, $exp); # 发放经验奖励 UserProc::updateUserInfo($req); # 在获取战利品哪里已经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(';', $rwds) ); return Resp::ok($result); } /** * 是否可以战斗 * @param type $req * @param $gateId * @param $difficulty * @return type */ static function CanFight($req, $gateId, $difficulty) { $gatesRecord = $req->userInfo->game->gates->newGateRecord; $smGate = GameConfig::gate_getItem($gateId); if (!CommUtil::isPropertyExists($gatesRecord->record, $gateId)) { $gatesRecord->record->$gateId = ObjectInit(); } if ($difficulty > 2) { return Resp::err(ErrCode::err_arenasgate_indexillegal); } if ($difficulty == 0) { if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "normal")) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "normalToday")) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } if ($smGate->cishu1 - $gatesRecord->record->$gateId->normalToday < 1) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } $gatesRecord->record->$gateId->normalToday += 1; } else if ($difficulty == 1) { if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "hard")) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "hardToday")) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } if ($smGate->cishu2 - $gatesRecord->record->$gateId->hardToday < 1) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } $gatesRecord->record->$gateId->hardToday += 1; } else if ($difficulty == 2) { if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "elite")) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "eliteToday")) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } if ($smGate->cishu3 - $gatesRecord->record->$gateId->eliteToday < 1) { return Resp::err(ErrCode::err_arenas_normalgate_numno); } $gatesRecord->record->$gateId->eliteToday += 1; } return null; // false } // // /** * [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, $req); break; case "399": if ($itemId == "399002") { // 金币的获取 UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $itemNum); } break; default: break; } $getStarRewardRecord[] = $rewardID; // 保存记录 $req->userInfo->game->gates->starRewards = $getStarRewardRecord; UserProc::updateUserInfo($req); // 更新数据库数据 $result = array( "getreward" => true ); return Resp::ok($result); } // // // /** // * [6805] 查询租借好友记录 // * @param Req $req // */ // public static function GetBorrowedFriends($req) { //// 查询好友借用记录中的数据 // $rentedfriends = $req->userInfo->game->privateState->rentedFriends; // if (!$rentedfriends || !is_array($rentedfriends)) { // $rentedfriends = ArrayInit(); // } // return Resp::ok(array('ret' => $rentedfriends)); // } // // /** // * 清理战斗租借好友记录 // * // */ // public static function ClearFightRentRecord($req) { // $req->userInfo->game->privateState->rentedFriends = ArrayInit(); // } // // /** // * [6806] 扣除借用好友费用 // * @param Req $req // */ // public static function ConsumeBorrowFriend($req) { //// 提取参数:好友id // $friend_uid = $req->paras[0]; //// 验证好友关系 // if (!FriendProc::isFriendship($req->zoneid, $req->uid, $friend_uid)) { // return Resp::err(ErrCode::friend_no_err); // } //// 验证尚未租借过 // $rentedfriends = $req->userInfo->game->privateState->rentedFriends; // if (!$rentedfriends || !is_array($rentedfriends)) { // $rentedfriends = ArrayInit(); // } // if (in_array($friend_uid, $rentedfriends)) { // return Resp::err(array('err' => -1, 'msg' => 'has rented this player today!')); // } //// 验证好友出借英雄 // $friend_info = UserProc::getUserInfo(gMem(), $req->zoneid, $friend_uid); // if (!$friend_info) { // return Resp::err(ErrCode::user_no_err, '找不到好友的游戏数据!'); // } //// todo:啦啦啦... 先不写了,管它用的是哪个英雄呢 //// //// 扣除费用,失败->金币不足 // $arr = explode(',', glc()->User_Friends_HireFriendForBattle_Cost); // if (count($arr) < 2) { // return Resp::err(ErrCode::err_const_no); // } // $itemid = $arr[0]; # 道具id // $amt = $arr[1]; # 数量 // if ($itemid == META_GOLD_ITEMID) { // $user = $req->userInfo->game; // if ($user->gold < $amt) { // return Resp::err(array('err' => -2, 'msg' => 'gold not enough!')); // } // UserGameModel::Consume_Gold($user, $amt); //// todo: 给好友发送金币 邮件 // EmailProc::SendHireCoinFromFight($req->zoneid, $friend_uid, # // $req->userInfo->game->name, $req->uid, $amt); # 好友收益需要扣除系统税率. // } else { // return Resp::err(ErrCode::err_const_no); // } //// 添加借用记录 // $rentedfriends[] = $friend_uid; // $req->userInfo->game->privateState->rentedFriends = $rentedfriends; //// 回写数据 // UserProc::updateUserInfo($req); // 玩家数据 //// UserProc::setUserInfo(global_mem(), $friend_info); // 好友数据 //// 返回 // return Resp::ok(array('err' => 0, 'curgold' => $user->gold)); // } // // // // /** // * [6804] 扣除买buffer的费用 // * @param type $req // * @return type // */ // public static function ConsumeBufferGold($req) { // $user = $req->userInfo->game; # user引用 // $money = $req->paras[0]; //需要的手工费 //// echo var_dump($money); // $bDeal = UserGameModel::Consume_Gold($user, $money); // if ($bDeal) { // $result = array( // 'resp' => "succeed!" // ); //// 更新数据库数据 // // $resp = Resp::ok($result); // } else { // //// $user->gold=0; // $result = array( // 'resp' => "succeed!" // ); //// 更新数据库数据 // // $resp = Resp::ok($result); // } // UserProc::updateUserInfo($req); // return $resp; // } // /** // * [6807] 挑战黄金 无穷无尽战斗模式 // * @param type $req // */ // public static function ChallengeEndlessFightMode_Gold($req) { // $gateForeverId = $req->paras[0]; // $difficuty = $req->paras[1]; // $bociCount = $req->paras[2]; ////判断是否已经达到挑战的次数上限 // $gates = $req->userInfo->game->gates; // // if (!CommUtil::isPropertyExists($gates, "forever_Gold_FightTimes")) { // $gates->forever_Gold_FightTimes = 0; // } // // if ($gates->forever_Gold_FightTimes >= glc()->Battle_Forever_MaxCountEveryDay) { // return Resp::err(ErrCode::err_gateForever_countIsFull, '挑战次数已经用尽!'); // } ////1.取出无尽模式的关卡常量数据 // $gateForeverConst = GameConfig::gateforever_getItem($gateForeverId); // ConstProc::getGold_GateForeverGoldConst($gateForeverId); // $gateBattleBociConst = GameConfig::gatecombat_getItem($gateForeverId); // if (!$gateForeverConst) { // return Resp::err(ErrCode::err_gateForever_const_no); // } ////判断次数是否合法 // $bociArr = explode(",", $gateBattleBociConst->level); // if ($bociCount > count($bociArr)) { // return Resp::err(ErrCode::err_gateForever_countillegal); // } ////2.取出模式下的奖励数据 // $rewardStr = $gateForeverConst->reward1; // // $arr_reward = explode(";", $rewardStr); // foreach ($arr_reward as $value) { // if (strlen($value) > 0) { // // $arr_RealReward = explode(",", $value); // $itemId = $arr_RealReward[0]; // $itemNum = $arr_RealReward[1]; // // $str1 = substr($itemId, 0, 3); ////3.根据挑战的波次数据,重复累计获得奖励 // for ($i = 0; $i < $bociCount; $i++) { // // 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, $req); // break; ////金币的获取 // case "399": // if ($itemId == "399002") { // UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $itemNum); // } // break; // default: // break; // } // } // } // } ////4、存储玩家的挑战次数 // $gates->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes + 1; //// 回写数据 // UserProc::updateUserInfo($req); // $result = ObjectInit(); // $result->result = "succeed"; // $result->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes; // $resp = Resp::ok($result); // return $resp; // } // /** // * 清理挑战无尽模式的 次数记录 // * // */ // public static function ClearGateForeverGold_FightCountEveryDay($req) { // $req->userInfo->game->gates->forever_Gold_FightTimes = 0; // } // // // // // /** // * [6801] 开启副本 // * @param Req $req // * @deprecated since version 0 // */ // public static function OpenTheCarbon($req) { // $gates = $req->userInfo->game->gates; // $openedcarbons = $gates->carbons->openedCarbons; //# 提取参数 // $carbonId = $req->paras[0]; # 副本ID // $difficulty = $req->paras[1]; # 难度等级 1,2,3 // $key = "$carbonId-$difficulty"; # 键值 // if (!($gates && $openedcarbons)) { // return Resp::err(ErrCode::err_innerfault); // } // if ($difficulty > 3 || $difficulty < 1) { // return Resp::err(ErrCode::carbon_wrongdifficult); // } // // if (CommUtil::isPropertyExists($openedcarbons, $key)) { // $carbon = $openedcarbons->$key; // } else { // $carbon = new CarbonModel(); // } // if ($carbon->closeTs > now()) { // return Resp::err(ErrCode::carbon_opened); // } // $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 常量 //# 扣除开启消耗的道具 // $keyid = "keyId$difficulty"; // $keynum = "keyNum$difficulty"; // $costItemId = $carbonModel->$keyid; // $costItemNum = $carbonModel->$keynum; // // $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $costItemId, $costItemNum); // if ($err) { # 扣除失败 // return Resp::err($err); // } // $carbon->closeTs = now() + $carbonModel->duration; # 关闭倒计时 // $carbon->curIndex = 0; # 索引重置为0 // $openedcarbons->$key = $carbon; // $req->userInfo->game->gates->carbons->openedCarbons = $openedcarbons; // UserProc::updateUserInfo($req); // return Resp::ok(array('err' => 0, 'carbons' => $openedcarbons)); // } // /** // * 挑战副本关卡 // * @param Req $req // * @deprecated since version number // */ // public static function ChallengeCarbon($req) { // $gates = $req->userInfo->game->gates; // $carbons = $gates->carbons->openedCarbons; //# 提取参数 // $carbonId = $req->paras[0]; # 副本ID // $difficulty = $req->paras[1]; # 难度等级 1,2,3 // $gateindex = $req->paras[2]; # 关卡索引 0,1,2,... // $star = $req->paras[3]; # 战斗评价(几星) // $TeamObj = $req->paras[4]; # 队伍信息 //// $bossId = $req->paras[5]; # 本关消灭的bossid (<=0代表本关卡未出现boss) // if ($difficulty > 3 || $difficulty < 1) { // return Resp::err(ErrCode::carbon_wrongdifficult); // } // $key = "$carbonId-$difficulty"; # 键值 //# 0 当前副本处于开启状态 //# 1 当前关卡索引,不能跳着打, //# 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励 //# 3 决定掉落物品, 发给客户端 //# 4 发放对应的经验之类的东西 //# 5 检查是否最后一个关卡, 是, 关闭副本 //# 6 回存数据,返回 // // isEditor() && $carbon = new CarbonModel; // if (CommUtil::isPropertyExists($carbons, $key)) { // $carbon = $carbons->$key; // } else { // $carbon = null; // } // if (!$carbon || $carbon->closeTs < now()) { // return Resp::err(ErrCode::carbon_closed); // } // // $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 副本常量数据 // $gateIds = explode(',', $carbonModel->gateids); // if ($gateindex < 0 || $gateindex >= count($gateIds)) { // return Resp::err(ErrCode::carbon_gateIndex); // } // if ($carbon->curIndex == $gateindex || $gateindex == 0) { // $carbon->curIndex += 1; # 更新进度 // } else { # 不能跳关 // return Resp::err(ErrCode::carbon_gateIndex); // } // // $gateId = $gateIds[$gateindex]; # 通过索引获得关卡ID // $tl = "tili$difficulty"; # 体力难度 // $rwd = "reward$difficulty"; # 奖励难度 // $arr = array("normal", 'hard', 'elite'); # 难度名称 // $gt = $arr[$difficulty - 1]; # 关卡分类 // $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据 // $tili = $gateModel->$tl; # 扣除体力 // $reward = $gateModel->$rwd; # 获得奖励 //# //# 打副本呢也要扣除体力 // ActiveProc::ChangeTili(-$tili, $req); //# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109 // UserGameModel::Add_Exp($req, $tili); //# 增加英雄经验(也是依据扣除的体力数) // foreach ($TeamObj as $heroUID) { // HeroProc::HeroAddEXP($heroUID, $tili, $req); // } //// $carbon->stars; 暂不记录了 //# 掉落战利品->获取 // $err = StoreProc::AddMultiItemInStore($req, $reward); // if ($err) { // return Resp::err($err); // } // if (count($gateIds) == $gateindex + 1) { # 最后一个关卡 // unset($carbons->$key); # 关闭掉关卡,或者是直接删掉 // } else { // $carbons->$key = $carbon; # 回存数据 // } // $req->userInfo->game->gates->carbons->openedCarbons = $carbons; // UserProc::updateUserInfo($req); //在获取战利品哪里已经update了. // # Ps.备注,奖品是固定的,所以不必返回 // $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 // ); // return Resp::ok($result); // } // /** // * [6809]新版本的挑战 副本胜利 // * @param Req $req // * @deprecated since version 0 // */ // public static function NewChallengeCarbon($req) { // $gates = $req->userInfo->game->gates; // $carbons = $gates->carbons->openedCarbons; //# 提取参数 // $carbonId = $req->paras[0]; # 副本ID // $gateId = $req->paras[1]; # 关卡ID // $difficulty = $req->paras[2]; # 难度等级 1,2,3 // // $star = $req->paras[3]; # 战斗评价(几星) // $TeamObj = $req->paras[4]; # 队伍信息 // // if ($difficulty > 3 || $difficulty < 1) { // return Resp::err(ErrCode::carbon_wrongdifficult); // } // $key = "$carbonId-$difficulty"; # 键值 // # 0 当前副本处于开启状态 // # 1 战斗胜利之后,副本直接关闭 // # 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励 // # 3 决定掉落物品, 发给客户端 // # 4 发放对应的经验之类的东西 // # 5 检查是否最后一个关卡, 是, 关闭副本 // # 6 回存数据,返回 // // isEditor() && $carbon = new CarbonModel; // if (CommUtil::isPropertyExists($carbons, $key)) { // $carbon = $carbons->$key; // } else { // $carbon = null; // } // if (!$carbon || $carbon->closeTs < now()) { // return Resp::err(ErrCode::carbon_closed); // } // unset($carbons->$key); // $tl = "tili$difficulty"; # 体力难度 // $rwd = "reward$difficulty"; # 奖励难度 // // $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据 // $tili = $gateModel->$tl; # 扣除体力 // $reward = $gateModel->$rwd; # 获得奖励 // # // # 打副本呢也要扣除体力 // ActiveProc::ChangeTili(-$tili, $req); // // // 按照概率规则发放奖品 // $rewardsArr = explode(";", $reward); // $rwds = array(); // foreach ($rewardsArr as $r) { // $arr = explode(',', $r); // $itemid = intval($arr[0]); // $num = intval($arr[1]); // $probability = floatval($arr[2]); # 掉落概率精度精确到±0.01% // if (CommUtil::randomPercent($probability)) { # 投色子 // $err = StoreProc::AddMultiItemInStore($req, "$itemid,$num"); // if ($err) { // return Resp::err($err); // } // $rwds[] = "$itemid,$num"; // } // } // // if ($err) { // return Resp::err($err); // } // // $req->userInfo->game->gates->carbons->openedCarbons = $carbons; // UserProc::updateUserInfo($req); //在获取战利品哪里已经update了. // # Ps.备注,奖品是固定的,所以不必返回 // SystemProc::Carbon_Win($req->zoneid, $req->userInfo->game, $carbonId, $difficulty); # 插入通过副本消息 // $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' => 0, // 'exp' => 0, // 'rewardstr' => implode(';', $rwds) // ); // return Resp::ok($result); // } // /** // * [6816] 挑战剧情关卡 // * @param type $req // * @deprecated since version 0 // */ // public static function ChallengeStoryGate($req) { // $gates = $req->userInfo->game->gates; //# 提取参数 // $storyId = $req->paras[0]; # 剧情ID // $difficulty = $req->paras[1]; # 难度等级 1,2,3 // $star = $req->paras[2]; # 战斗评价(几星) // $TeamObj = $req->paras[3]; # 队伍信息 // $bossId = $req->paras[4]; # 本关消灭的bossid (<=0代表本关卡未出现boss) //// //#1. 判断是否有记录过剧情的战斗信息 // if (!CommUtil::isPropertyExists($gates, "story")) { // $gates->story = ObjectInit(); // $gates->story->lastFinishedStoryGateId = 0; // $gates->story->allFinishedStoryGateIdList = ArrayInit(); // } // $storrRecord = $gates->story; //#2.取出模式下的奖励数据 // $memStoryModel = GameConfig::gatestory_getItem($storyId); // $tili = 0; // $rewardStr = $memStoryModel->storyGateReward; // //#3 同步下剧情的推进进度数据 // if ($storrRecord->lastFinishedStoryGateId == $storyId || in_array($storyId, $storrRecord->allFinishedStoryGateIdList)) { // return Resp::err(ErrCode::story_repeatfight); #剧情关卡不能重复战斗 只能打一次 // } else { // $storrRecord->lastFinishedStoryGateId = $storyId; // $storrRecord->allFinishedStoryGateIdList[] = $storyId; // } //# //# 4 万一打剧情也扣除体力呢 // if ($tili > 0) { // ActiveProc::ChangeTili(-$tili, $req); //# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109 // UserGameModel::Add_Exp($req, $tili); //# 增加英雄经验(也是依据扣除的体力数) // foreach ($TeamObj as $heroUID) { // HeroProc::HeroAddEXP($heroUID, $tili, $req); // } // }# 5 玩家获得 剧情的战斗奖励 // $err = StoreProc::AddMultiItemInStore($req, $rewardStr); // if ($err) { // return Resp::err($err); // }# 6 回存玩家的战斗记录 // $req->userInfo->game->gates->story = $storrRecord; // UserProc::updateUserInfo($req); //在获取战利品哪里已经update了. // # Ps.备注,奖品是固定的,所以不必返回 // $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 // ); // return Resp::ok($result); // } // // // }