12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace loyalsoft;
- /**
- * 事件模块.
- * @version
- * 1.0.0 Created at 2017-8-28. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-8-28, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
- class EventProc {
- public static function procMain($req) {
- switch ($req->cmd) {
- case CmdCode::cmd_event_GetNotifications: # 7201 拉取角标通知列表
- return self::GetCornerSignNotifications($req);
- default:
- return Resp::err(ErrCode::cmd_err);
- }
- }
- /**
- * [7201] 拉取角标通知
- * @param req $req
- */
- static function GetCornerSignNotifications($req) {
- // 这里直接返回, 将来开发对应的触发逻辑, 给数组中添加相应的值
- $arr = array_values(array_unique($req->userInfo->game->privateState->cornerSignNotifications)); # 返回值去重
- $req->userInfo->game->privateState->cornerSignNotifications = []; # 清理记录
- UserProc::updateUserInfo();
- return Resp::ok(array("notifications" => $arr)); # 返回
- }
- static function Init() {
- Event::register('onpay', array(new Data_UserProfile(req()->userInfo->game->profile), "OnPay"));
- }
- /**
- * 收到请求
- */
- static function OnRequest() {
-
- }
- /**
- * 处理完毕准备返回
- */
- static function AfterResponse() {
-
- }
- /**
- * 当天第一次登录
- */
- static function OnNewDay() {
-
- }
- /**
- * 当周第一次登录(周一)
- */
- static function OnNewWeek() {
-
- }
- /**
- * 当玩家等级变更
- * @param type $old
- * @param type $new
- */
- static function OnUserLevelup($old, $new) {
- // 处理逻辑,
- $ubs = req()->userInfo->game->privateState->unlockedBuild;
- foreach (GameConfig::build() as $id => $b) {
- isEditor() and $b = new \sm_build();
- if (!in_array($id, $ubs)) { # 尚未解锁的建筑,判断,已解锁的跳过
- if ($b->playerLevelLimit <= $new) { # 符合解锁条件
- req()->userInfo->game->privateState->unlockedBuild[] = $id; # 插入解锁记录
- NormalEventProc::OnUnlockBuild($id, null); # 插入事件
- }
- }
- }
- // NormalEventProc::OnHelloWorld($arg1, $arg2); # 添加升级事件,算了这个暂时没人关注
- }
- }
|