1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- namespace loyalsoft;
- /**
- * Description of ActiveProc
- *
- * @author c'y'zhao
- */
- class ActiveProc {
- /**
- * 逻辑分发
- * 所有的Proc中必须有这样一个方法
- * @param Req $req
- */
- public static function procMain($req) {
- switch ($req->cmd) {
- case CmdCode::active_day7_drawreward: # 6101 签到
- return ActiveProc::Day7_DrawReward();
- case CmdCode::active_day7_accumulateDrawreward: # 6102 7日累充
- return ActiveProc::Day7__accumulateDrawreward();
-
- default:
- Err(ErrCode::cmd_err);
- }
- }
-
- /**
- * 7日累充领奖
- */
- public static function Day7__accumulateDrawreward() {
- list($typeId) = req()->paras; # 参数: 领取第x天的奖励
- $user = ctx();
-
- my_Assert($user->privateState->day7_accumulate >= $typeId, ErrCode::active_day7_expired);
- my_Assert(!in_array($typeId, $user->privateState->day7_accumulateDrawed), ErrCode::active_hasgetted);
- $day_rwd = GameConfig::active_day7_accumulate_getItem($typeId); # 查询奖励数据
- my_Assert(null != $day_rwd, ErrCode::err_const_no); # 防御找不到配置
- StoreProc::AddMultiItemInStore($day_rwd->reward); # 发放奖励
- $user->privateState->day7_accumulateDrawed[] = $typeId;
-
- ctx($user);
- UserProc::updateUserInfo(); # 回存
- return Resp::ok(array(
- 'gold' => $user->baseInfo->gold,
- 'cash' => $user->baseInfo->cash,
- 'tili' => $user->baseInfo->tili,
- 'store' => $user->store,
- ));
- }
-
- /**
- * 7日签到 数据更新
- */
- public static function DailyResetDay7Task() {
- if(count(ctx()->privateState->LoginDays) >= 7){
- ctx()->privateState->LoginDays = array();
- ctx()->privateState->day7_drawed = array();
- }
- $index = count(ctx()->privateState->LoginDays)+1;
- ctx()->privateState->LoginDays[] = $index;
- ctx()->privateState->day7_accumulate += 1;
- }
- /**
- * 7日签到
- * @return type
- */
- public static function Day7_DrawReward() {
- list($day) = req()->paras; # 参数: 领取第x天的奖励
- $user = ctx();
-
- my_Assert(in_array($day,$user->privateState->LoginDays), ErrCode::active_day7_expired);
- my_Assert(!in_array($day, $user->privateState->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); # 发放奖励
- $user->privateState->day7_drawed[] = $day; # 添加领取记录
-
- ctx($user);
- UserProc::updateUserInfo(); # 回存
- return Resp::ok(array(
- 'gold' => $user->baseInfo->gold,
- 'cash' => $user->baseInfo->cash,
- 'tili' => $user->baseInfo->tili,
- 'store' => $user->store,
- ));
- }
- }
|