12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?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();
-
- default:
- Err(ErrCode::cmd_err);
- }
- }
-
-
- /**
- * 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,
- ));
- }
- }
|