cmd) { case CmdCode::active_day7_drawreward: # 6502 领取七日签到奖励 return self::Day7_DrawReward(); case CmdCode::active_getzonePublicTs: # 6503 查询开服时间戳 return ActiveProc::GetZonePublicTS(); case CmdCode::active_getTodayOnlineInfos: # 6504 查询当天在线时长 return self::getTotayOnlineInfos(); case CmdCode::Task_Tili: # 6508 体力变化 return ActiveProc::RecoveryTili(); case CmdCode::active_token_drawReward: # 6512 兑换码礼包 return self::drawActivePackageByCode(); case CmdCode::active_draw_onlinegift: # 6513 领取在线(时长)礼包 return self::drawOnlineGift(); case CmdCode::active_draw_reggift: # 6514 领取全服注册礼包 return self::drawRegGift(); case CmdCode::active_presentTili: # 6515 领取在线赠送体力 return self::drawTiliGift(); case CmdCode::active_get_regnum: # 6516 查询当前全服注册人数 return self::getRegNumber(); case CmdCode::active_shenmiaoDrawPrize: # 6505 什么抽奖 return self::shenmiaoDrawPrize(); case CmdCode::active_GetShenmiaoData: return self::GetShenmiaoData(); case CmdCode::active_BuyShenmiaoDrawTicket: return self::buyShenmiaoDrawTicket(); default: return Resp::err(ErrCode::cmd_err); } } /** * 每天重置 */ static function DailyReset() { self::DailyResetDay7Task(); self::ClearOnlineGiftTs(); self::ClearDailyTiliGift(); } // /** * 获取神庙的主界面信息 */ static function GetShenmiaoData() { $req = req(); //$shenmiaoInfo = ctx()->shenmiao; $shenmiaoInfo = new Info_ShenMiao(ctx()->shenmiao); $shenmiaoInfo->initActiveItem(); ctx()->shenmiao = $shenmiaoInfo; UserProc::updateUserInfo(); return Resp::ok(array(# # 返回值 'shenmiaoInfo' => $shenmiaoInfo, )); } /** * 购买神庙券 临时 * @return type */ static function buyShenmiaoDrawTicket() { $req = req(); list($costId, $num) = $req->paras; $dic = GameConfig::shop_getItem($costId); my_Assert($dic != null, ErrCode::err_const_no); $baseInfo = ctx()->baseInfo; $costNum = $dic->price * $num; my_Assert($baseInfo->cash >= $costNum, ErrCode::notenough_cash_msg); ctx()->base()->Consume_Cash($costNum); if ($costId == 801022) { $costId = 3320001; } else { $costId = 3330001; } StoreProc::AddMultiItemInStore($costId . ',' . $num); UserProc::updateUserInfo(); return Resp::ok(array(# # 返回值 'cash' => ctx()->baseInfo->cash, 'store' => ctx()->store, )); } /** * 神庙抽奖 */ static function ShenmiaoDrawPrize() { $req = req(); list($type, $num) = $req->paras; $shenmiaoInfo = ctx()->shenmiao; my_Assert(StlUtil::dictHasProperty($shenmiaoInfo->activeDic, $type), ErrCode::active_activeNoExistent); $list = array(); if (Enum_Active::NewWish == $type) { my_Assert($shenmiaoInfo->activeDic->$type->num < glc()->UserWishNumLimit, ErrCode::active_NewUserActiveNumLimit); my_Assert($num == 10, ErrCode::active_NewUserActiveNumLimit); $shenmiaoInfo->activeDic->$type->num += $num; $shenmiaoInfo->activeDic->$type->totalNum += $num; $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id); self::cost($req, $shenmo, $num); $tag = false; $n = 0; for ($index = 0; $index < $num; $index++) { $n += 1; $itemType = self::activeRandom($shenmo->per, $shenmo); if ($itemType >= 2) { $tag = true; } if ($n == 10 && $tag == false && $shenmiaoInfo->activeDic->$type->totalNum > 10) { $list[] = self::getActiveRandomItem(Enum_ActiveItemType::Sr, $shenmo); //self::randSsrUr($shenmo->per) } else { if ($shenmiaoInfo->activeDic->$type->totalNum <= 10) { $itemType = Enum_ActiveItemType::R; } $nId = self::getActiveRandomItem($itemType, $shenmo); $list[] = $nId; } } if ($shenmiaoInfo->activeDic->$type->totalNum == 10 && !in_array($shenmo->must, $list)) {//首次10连抽有必出--临时 $list[0] = $shenmo->must; } if ($shenmiaoInfo->activeDic->$type->totalNum >= glc()->UserWishNumLimit) { $shenmiaoInfo->isComNewWish = 1; StlUtil::dictRemove($shenmiaoInfo->activeDic, $type); } if ($num == 1) { StatisticsProc::TargetStatistics(Enum_TargetStatistics::newUserLotteryDraw_one); } else { StatisticsProc::TargetStatistics(Enum_TargetStatistics::newUserLotteryDraw_ten); } } else if (Enum_Active::OpenWish == $type) { $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id); if ($num == 1) { $shenmiaoInfo->activeDic->$type->num += $num; self::cost($req, $shenmo); $list[] = self::drawOneLottery($shenmo, $type); } else {//10连抽 self::cost($req, $shenmo, $num); $shenmiaoInfo->activeDic->$type->totalNum += $num; $list = self::drawTenLottery($shenmo, $type, $num); } if ($num == 1) { StatisticsProc::TargetStatistics(Enum_TargetStatistics::commonLotteryDraw_one); } else { StatisticsProc::TargetStatistics(Enum_TargetStatistics::commonLotteryDraw_ten); } } else {//不定期活动 $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id); if ($num == 1) { self::cost($req, $shenmo, $num); $shenmiaoInfo->activeDic->$type->num += $num; $list[] = self::drawOneLottery($shenmo, $type); } else { self::cost($req, $shenmo, $num); $shenmiaoInfo->activeDic->$type->totalNum += $num; $list = self::drawTenLottery($shenmo, $type, $num); } if ($num == 1) { if ($type == 4) { StatisticsProc::TargetStatistics(Enum_TargetStatistics::yanLingLotteryDraw_one); } elseif ($type == 5) { StatisticsProc::TargetStatistics(Enum_TargetStatistics::weaponLotteryDraw_one); } } else { if ($type == 4) { StatisticsProc::TargetStatistics(Enum_TargetStatistics::yanLingLotteryDraw_ten); } elseif ($type == 5) { StatisticsProc::TargetStatistics(Enum_TargetStatistics::weaponLotteryDraw_ten); } } } foreach ($list as $id) { $s = $id . ',1'; StoreProc::AddMultiItemInStore($s); } ctx()->shenmiao = $shenmiaoInfo; UserProc::updateUserInfo(); TaskProc::OnTempleLottery(); # 检测神庙抽奖任务 return Resp::ok(array(# # 返回值 'shenmiaoInfo' => $shenmiaoInfo, 'list' => $list, 'store' => ctx()->store, )); } /** * 1连抽 * @param type $shenmo * @param type $type * @param type $num * @return type */ public static function drawOneLottery($shenmo, $type) { $req = req(); $shenmiaoInfo = ctx()->shenmiao; $itemType = self::activeRandom($shenmo->per, $shenmo); if ($type == Enum_Active::OpenWish) { $aid = self::getActiveRandomItem($itemType, $shenmo); } else { $aid = self::getActiveRandomItem_3($itemType, $shenmo, $type); # 随机出的id } if ($shenmiaoInfo->activeDic->$type->num % glc()->Active_UR_Num == 0 && $itemType != Enum_ActiveItemType::Ssr) { if ($type == Enum_Active::OpenWish) { $aid = self::getActiveRandomItem(Enum_ActiveItemType::Ssr, $shenmo); } else { $aid = self::getActiveRandomItem_3(Enum_ActiveItemType::Ssr, $shenmo, $type); } } return $aid; } /** * 10连抽 * @param type $type * @param type $num */ public static function drawTenLottery($shenmo, $type, $num) { $req = req(); $shenmiaoInfo = ctx()->shenmiao; $tag = false; $n = 0; $list = array(); for ($index1 = 0; $index1 < $num; $index1++) { $n += 1; $itemType = self::activeRandom($shenmo->per, $shenmo); if ($itemType >= 2) { $tag = true; } if ($n == 10 && $tag == false) { if ($type == Enum_Active::OpenWish) { $list[] = self::getActiveRandomItem(Enum_ActiveItemType::Sr, $shenmo); //self::randSsrUr($shenmo->per) } else { $list[] = self::getActiveRandomItem_3(Enum_ActiveItemType::Sr, $shenmo, $type); } } else { if ($type == Enum_Active::OpenWish) { $list[] = self::getActiveRandomItem($itemType, $shenmo); } else { $list[] = self::getActiveRandomItem_3($itemType, $shenmo, $type); } } } if ($shenmiaoInfo->activeDic->$type->totalNum >= glc()->Active_UR_Num) { # 第90次必得 if ($type == Enum_Active::OpenWish) { $aid = self::getActiveRandomItem(Enum_ActiveItemType::Ssr, $shenmo); } else { $aid = self::getActiveRandomItem_3(Enum_ActiveItemType::Ssr, $shenmo, $type); } $list[0] = $aid; $shenmiaoInfo->activeDic->$type->totalNum = 0; } return $list; } public static function prizeTypeRand($str) { if (strpos($str, ';')) { # 包含;说明里面奖品类型不同获得的概率不同 $sList = explode(';', $str); $dic = new \stdClass(); $rand = rand(1, 100); $start = 0; $end = 0; foreach ($sList as $val) { $itemList = explode('-', $val); $end = $itemList[1] + $start; if ($rand > $start && $rand <= $end) { $id = self::randList(explode(',', $itemList[0])); break; } $start = $end; } } else { $id = self::randList(explode(',', $str)); } return $id; } /** * 抽奖消耗 */ public static function cost($req, $shenmo, $num = 1) { $sList = explode(',', $shenmo->cost); $costVal = $sList[1] * $num; if ($shenmo->discount != 0) { $costVal = $sList[1] * $num * $shenmo->discount / 100; } StoreProc::removeItemFromStore(ctx()->store, $sList[0], $costVal); } /** * * @param type $randCtx * @param sm_shenmiao $mo * @return int */ public static function activeRandom($randCtx, $mo) { $rand = rand(1, 10000); $type = 1; $list = explode(',', $randCtx); $start = 0; foreach ($list as $val) { $end = $val + $start; if ($rand > $start && $rand <= $end) { break; } $type += 1; $start = $end; } return $type; } /** * * @param type $arr * @return type */ public static function randList($arr) { $rand = rand(0, count($arr) - 1); return $arr[$rand]; } /** * * @param type $type * @param type $mo * @return type */ public static function getActiveRandomItem($type, $mo) { $id = 0; switch ($type) { case Enum_ActiveItemType::R: $id = self::prizeTypeRand($mo->rList); //$id = self::randList(explode(',', $mo->srList)); break; case Enum_ActiveItemType::Sr: $id = self::prizeTypeRand($mo->srList); //$id = self::randList(explode(',', $mo->ssrList)); break; case Enum_ActiveItemType::Ssr: $id = self::prizeTypeRand($mo->ssrList); //$id = self::randList(explode(',', $mo->urList)); break; default: break; } return $id; } /** * * @param type $type * @param sm_shenmiao $mo * @return type */ public static function getActiveRandomItem_3($type, $mo, $activeType) { $shenmiaoInfo = ctx()->shenmiao; $id = 0; switch ($type) { case Enum_ActiveItemType::R: $id = self::prizeTypeRand($mo->rList); //$id = self::randList(explode(',', $mo->srList)); break; case Enum_ActiveItemType::Sr: if ($mo->srUp != null) { $dic = new \stdClass(); $ssrList = explode(';', $mo->srUp); $tNum = 0; foreach ($ssrList as $val) { $sList = explode(',', $val); $sid = $sList[0]; $dic->$sid = $sList[1]; $tNum += $sList[1]; } if ($shenmiaoInfo->activeDic->$activeType->isUpSsr == 1) { $rand = rand(1, $tNum); $start = 0; foreach ($dic as $k => $val) { $end = $val + $start; if ($rand > $start && $rand <= $end) { # 随机到Up得id $id = $k; break; } $start = $end; } $shenmiaoInfo->activeDic->$activeType->isUpSsr = 0; } else { $rand = rand(1, 10000); $start = 0; $sNum = 0; $count = StlUtil::count($dic); foreach ($dic as $k => $val) { $sNum += 1; $end = $val + $start; if ($rand > $start && $rand <= $end) { // 随机到Up得id $id = $k; break; } if ($sNum >= $count) { // 随机到普通的id $shenmiaoInfo->activeDic->$activeType->isUpSsr = 1; $id = self::prizeTypeRand($mo->srList); //$id = self::randList(explode(',', $mo->ssrList)); break; } $start = $end; } } } else { $id = self::prizeTypeRand($mo->srList); //$id = self::randList(explode(',', $mo->ssrList)); } break; case Enum_ActiveItemType::Ssr: if ($mo->srUp != null) { $dic = new \stdClass(); $urList = explode(';', $mo->ssrUp); $tNum = 0; foreach ($urList as $val) { $sList = explode(',', $val); $sid = $sList[0]; $dic->$sid = $sList[1]; $tNum += $sList[1]; } if ($shenmiaoInfo->activeDic->$activeType->isUpUr == 1) { $rand = rand(1, $tNum); $start = 0; foreach ($dic as $k => $val) { $end = $val + $start; if ($rand > $start && $rand <= $end) { // 随机到Up得id $id = $k; break; } $start = $end; } $shenmiaoInfo->activeDic->$activeType->isUpUr = 0; } else { $rand = rand(1, 10000); $start = 0; $sNum = 0; $count = StlUtil::count($dic); foreach ($dic as $k => $val) { $sNum += 1; $end = $val + $start; if ($rand > $start && $rand <= $end) { $id = $k; break; } if ($sNum >= $count) { $shenmiaoInfo->activeDic->$activeType->isUpUr = 1; $id = self::prizeTypeRand($mo->ssrList); //$id = self::randList(explode(',', $mo->urList)); break; } $start = $end; } } } else { //$id = self::randList(explode(',', $mo->urList)); $id = self::prizeTypeRand($mo->ssrList); } break; default: break; } return $id; } /** * 从SSr 和 uR中得一个 * @param type $param */ public static function randSsrUr($randCtx) { $list = explode(',', $randCtx); $list = array_splice($list, 1); $total = $list[0] + $list[1]; $rand = rand(1, $total); $start = 0; //$type = Enum_ActiveItemType::Ssr; $type = 2; foreach ($list as $val) { $end = $val + $start; if ($rand > $start && $rand <= $end) { break; } $type += 1; $start = $end; } return $type; } /** * [6515] 领取 赠送体力 */ static function drawTiliGift() { $user = ctx(); $privateState = ctx()->privateData(); $base = $user->base(); $hour = date('G'); my_Assert(!in_array($hour, $privateState->dailyDrawedTiliGift), ErrCode::active_hasgetted); # 判断是否已领取 $arr = explode(',', glc()->activity_presentTili_times); # 判断是否满足领取条件 my_Assert(in_array($hour, $arr), ErrCode::active_illegal); # 不满足条件 $base->Add_tili(glc()->activity_presentTili_number); # 增加体力 $privateState->dailyDrawedTiliGift[] = $hour; UserProc::updateUserInfo(); # 回存 return Resp::ok(array(# # 返回值 'key' => 'ok', 'record' => $privateState->dailyDrawedTiliGift, 'tili' => $base->tili, 'time' => $user->privateState->TiliTime, )); } //// // // /** * [6516] 查询当前全服注册人数 */ static function getRegNumber() { return Resp::ok(array( 'num' => gMem()->get(MemKey_GameRun::Stat_UserCountByZone_int(req()->zoneid)) )); } /** * [6514] 领取全服注册礼包 */ static function drawRegGift() { $user = new Data_UserGame(ctx()); $privateState = new Info_PrivateState($user->privateState); $giftId = req()->paras[0]; # 礼包id $giftModel = GameConfig::activity_reggift_getItem($giftId); # 取礼包常亮数据 if (null == $giftModel) { return Resp::err(ErrCode::err_const_no); } if (in_array($giftId, $privateState->drawedRegGift)) { # 判断是否已领取 return Resp::err(ErrCode::active_hasgetted); } // 判断是否满足领取条件 if (gMem()->get(MemKey_GameRun::Stat_UserCountByZone_int(req()->zoneid)) < $giftModel->regNumber) { return Resp::err(ErrCode::active_illegal); # 不满足条件 } $err = StoreProc::AddMultiItemInStore($giftModel->rewardstr); # 发放奖励 if ($err) { return Resp::err($err); # 失败 } $privateState->drawedRegGift[] = $giftId; $user->privateState = $privateState; ctx($user); UserProc::updateUserInfo(); # 回存 return Resp::ok(array(# # 返回值 'key' => 'ok', 'store' => $user->store )); } // // /** * 【6504】查询当天在线时长信息 */ static function getTotayOnlineInfos() { return Resp::ok(array( "onlineGiftIDs" => ctx()->privateState->onlineGiftIDs, "onlineGiftts" => ctx()->privateState->onlineGiftts )); } /** * [6513] 领取连续在线礼包 */ static function drawOnlineGift() { $giftid = req()->paras[0]; # 提取参数: 礼包的编号 $user = ctx(); $privateState = ctx()->privateData(); $giftData = GameConfig::activity_onlinegift_getItem($giftid); # 在线礼包常量数据 my_Assert(null != $giftData, ErrCode::onlinegift_constno_err); # 防御找不到配置数据 my_Assert($privateState->onlineGiftts >= $giftData->onlineSec, # # 时间未到,不可以领取 ErrCode::onlinegift_timenotenough); my_default_Arr($privateState->onlineGiftIDs); # 防御未初始化领取记录 my_Assert(!in_array($giftid, $privateState->onlineGiftIDs), # # 判断礼包ID是否已经领取 ErrCode::active_hasgetted); $err = StoreProc::AddMultiItemInStore($giftData->rewardstr); # 发放奖励 my_Assert(ErrCode::ok == $err, $err); # 发放奖励失败 $privateState->onlineGiftIDs[] = $giftid; # 记录已领礼包ID UserProc::updateUserInfo(); # 回写用户数据 return Resp::ok(array( 'onlineGiftts' => $privateState->onlineGiftts, 'onlineGiftIDs' => $privateState->onlineGiftIDs, "reward" => $giftData->rewardstr, 'gold' => $user->base()->gold, 'cash' => $user->base()->cash, 'tili' => $user->base()->tili, 'store' => $user->store(), 'hero' => $user->heros() )); # 设置返回值 } /** * 清理/重置 在线礼包时间戳 */ static private function ClearOnlineGiftTs() { ctx()->privateState->onlineGiftts = 0; ctx()->privateState->onlineGiftIDs = array(); } // // /** * [6512]凭兑换码领取礼包 */ static function drawActivePackageByCode() { $user = new Data_UserGame(ctx()); $privateState = new Info_PrivateState($user->privateState); # 快速访问 list( $activeId, $codestring) = req()->paras; # 取参数 活动id, 兑换码 $active = GameConfig::activity_getItem($activeId); # 活动数据 my_Assert(null != $active, ErrCode::active_const_no_err); my_Assert($active->startts <= now() && $active->endts >= now(), ErrCode::active_time); # 校验开放时间 my_Assert(preg_match("/^[a-kmnp-z2-9]{10}$/", $codestring), ErrCode::active_activecode_format); # 基础格式校验(10个特定字符) $activeCode = CipheredBase32::Decode($codestring); # 解码 $codePlatStr = GameConstants::GetPlatStringByActivteCode($activeCode); # platstr my_Assert(GameConstants::AllPlatStr == $codePlatStr # # 忽略全平台礼包 || req()->getPlatStr() == $codePlatStr, # # 平台字符串必须相符 ErrCode::active_activecode_plat); # # 平台错误 my_Assert(is_int($activeCode->number) # # 编号为int值 && $activeCode->number >= 1 && $activeCode->number <= 50000, # # 检查 兑换码的编号范围0~50000 ErrCode::active_activecode_format); $packageID = $activeCode->package; # 礼包id $packageInfo = GameConfig::tokenGift_getItem($packageID); # 礼包常量数据 my_Assert(null != $packageInfo, ErrCode::err_const_no); # 防御 my_Assert($packageInfo->expirets >= now() && $packageInfo->startTs <= now(), ErrCode::active_activecode_outtime); # 激活码已经失效,或者礼包尚未开启 my_Assert(!in_array($packageID, $privateState->usedTokens), ErrCode::active_hasgetted); # 已经领取过该礼包了 my_Assert(!self::checkActiveCodeIsUsed($activeCode), ErrCode::active_activecode_used); # 检查 该激活码是否已经使用过了 $err = StoreProc::AddMultiItemInStore($packageInfo->reward); # 发放礼包 my_Assert(ErrCode::ok == $err, $err); # 防御发放礼包过程出错 ctx()->privateState->usedTokens[] = $packageID; # 记录领取记录 $ok = self::setActiveCodeUserRecord($activeCode, req()->uid); # 插入数据库 my_Assert($ok, ErrCode::err_db); # 数据库操作失败- 重试 UserProc::updateUserInfo(); # 回存玩家数据 $user = new Data_UserGame(ctx()); # 重新取一下玩家数据. $ret = array(# # 返回值 "plat" => $codePlatStr, "packageId" => $activeCode->package, "reward" => $packageInfo->reward, 'gold' => $user->base()->gold, 'cash' => $user->base()->cash, 'tili' => $user->base()->tili, 'store' => $user->store, 'hero' => $user->heros ); return Resp::ok($ret); # 返回成功信息 } /** * 检查兑换码是否已经使用过了 * @param ActiveCode $activeCode * @return boolean true : 已经用过了, false : 激活码尚未使用过. */ static function checkActiveCodeIsUsed($activeCode) { $sql = sprintf("`plat`='%d' and `package`='%d' and `number`='%d'", # # where 子句 $activeCode->plat, $activeCode->package, $activeCode->number); $rows = daoInst() ->select() ->from(self::tab_toke_gift) # 表名 ->where($sql) ->count(); return $rows > 0; } /** * 将兑换码添加到使用记录中 * @param ActiveCode $actvieCode * @param string $uid * @return boolean true: 操作成功, false: 操作失败 */ static function setActiveCodeUserRecord($actvieCode, $uid) { $actvieCode->uid = $uid; # 添加uid $ret = daoInst() ->insert(self::tab_toke_gift) # 表名 ->data($actvieCode) ->exec(); return $ret > 0; } // /** * [6503] 查询当前分区开放时间戳 */ private static function GetZonePublicTS() { $zoneInfo = GameConfig::zonelist_getItem(req()->zoneid); return Resp::ok($zoneInfo->publicTs); } // /** * [6508] */ public static function RecoveryTili() { $useTili = req()->paras[0]; ActiveProc::ChangeTili($useTili); UserProc::updateUserInfo(); $result = array( 'time' => ctx()->privateState->TiliTime, 'tili' => ctx()->baseInfo->tili ); $resp = Resp::ok($result); return $resp; } /** * 清理每天的赠送体力领取记录 */ private static function ClearDailyTiliGift() { ctx()->privateState->dailyDrawedTiliGift = ArrayInit(); } /** * 修改玩家体力 * @param int $useTili $useTili>0代表增加体力, $useTili<0代表消耗体力 */ public static function ChangeTili($useTili) { $user = ctx(); $moreTili = 0; # 超上限的体力值 // 如果没有tilitime这个值,说明是以前老用户新登录的,为了纠错在判断里面补值.(正常用户不会进入判断内部) if (!CommUtil::isPropertyExists($user->privateState, "TiliTime")) { $user->privateState->TiliTime = time() - 120; } if ($user->baseInfo->tili > 120) { # 如果该账户体力值本身是大于上限的,获取一下超出的体力值 $moreTili = $user->baseInfo->tili - 120; # 用moreTili保存一下额外的体力值 } $useTime = time() - $user->privateState->TiliTime; # 距离上次修改体力值的时间 if ($useTime > 300) { # 该账户超过了单位体力时间,需要重新计算体力值 if ($moreTili <= 0) { $user->baseInfo->tili += (int) ( (int) ($useTime / 300)); if ($user->baseInfo->tili > 120) { # 体力值上限 $user->baseInfo->tili = 120; } // 这代码真烂,以后用的时候再修复吧... -gwang 20200110154858 } $user->privateState->TiliTime = time(); } if ($useTili < 0) { # 如果是消耗体力 my_Assert(abs($useTili) < $user->baseInfo->tili, ErrCode::notenough_tili); # 体力不足 $user->baseInfo->tili += $useTili; # 扣除体力 } else if ($useTili > 0) { # 如果是购买增加体力 $user->baseInfo->tili += $useTili; } return ErrCode::ok; } // // // // /** * 重置7日签到相关计数器 */ static function DailyResetDay7Task() { ctx()->gates->Times = 0; $typeID = 6; # 7日活动 $ac = GameConfig::activity_getItem($typeID); my_Assert(null != $ac, ErrCode::err_const_no); $startDay = totalDays($ac->startts); $newLoginDays = array_filter(ctx()->privateState->LoginDays, # # 剔除不符合时间的登录记录 function ($tsday)use ($startDay) { return $startDay <= $tsday; } ); ctx()->privateState->LoginDays = $newLoginDays; # if (count(ctx()->privateState->LoginDays) < 7) { ctx()->privateState->LoginDays[] = totalDays(); } } /** * [6502] 领取七日签到奖励 */ static function Day7_DrawReward() { // 设计7日数据结构 list($day) = req()->paras; # 参数: 领取第x天的奖励 $user = ctx(); $private = new Info_PrivateState($user->privateState); # 私有数据 my_Assert(count($private->LoginDays) >= $day, ErrCode::active_day7_totaldays); my_Assert(!in_array($day, $private->day7_drawed), ErrCode::active_hasgetted); $day_rwd = GameConfig::activity_day7_getItem($day); # 查询奖励数据 my_Assert(null != $day_rwd, ErrCode::err_const_no); # 防御找不到配置 StoreProc::AddMultiItemInStore($day_rwd->reward); # 发放奖励 $private->day7_drawed[] = $day; # 添加领取记录 $user->privateState = $private; # 更新数据 UserProc::updateUserInfo(); # 回存 return Resp::ok(array( 'gold' => $user->baseInfo->gold, 'cash' => $user->baseInfo->cash, 'tili' => $user->baseInfo->tili, 'store' => $user->store, 'hero' => $user->heros )); # 返回值 } // // }