123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?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() {
- switch (req()->cmd) {
- case CmdCode::cmd_event_GetNotifications: # 7201 拉取角标通知列表
- return self::GetCornerSignNotifications();
- case CmdCode::cmd_event_ClearNotifications: # 7202 清理指定类型的角标
- return self::ClearCornerSignNotification();
- default:
- return Resp::err(ErrCode::cmd_err);
- }
- }
- /**
- * [7202] 清理指定类型的角标记录
- */
- static function ClearCornerSignNotification() {
- $ctype = req()->paras[0];
- $e = new OperateEventType();
- if ($e->isValidValue($ctype)) {
- StlUtil::arrayRemove(ctx()->privateState->cornerSignNotifications, $ctype); # 移除角标
- UserProc::updateUserInfo();
- }
- $arr = array_values(array_unique(ctx()->privateState->cornerSignNotifications)); # 返回值去重
- ctx()->privateState->cornerSignNotifications = $arr; # 更新记录
- return Resp::ok(array("notifications" => $arr)); # 返回
- }
- /**
- * [7201] 拉取角标通知
- */
- static function GetCornerSignNotifications() {
- // 这里直接返回, 将来开发对应的触发逻辑, 给数组中添加相应的值
- $arr = array_values(array_unique(ctx()->privateState->cornerSignNotifications)); # 返回值去重
- ctx()->privateState->cornerSignNotifications = $arr; # 更新记录
- UserProc::updateUserInfo();
- return Resp::ok(array("notifications" => $arr)); # 返回
- }
- static function Init() {
- Event::register('onpay', array(new Data_UserProfile(ctx()->profile), "OnPay"));
- }
- /**
- * 收到请求
- */
- static function OnRequest() {
-
- }
- /**
- * 处理完毕准备返回
- */
- static function AfterResponse() {
-
- }
- /**
- * 当天第一次登录
- */
- static function OnNewDay() {
- CornerSignEventProc::OnNewDay();
- }
- /**
- * 当周第一次登录(周一)
- */
- static function OnNewWeek() {
-
- }
- /**
- * 当玩家等级变更
- * @param type $old
- * @param type $new
- */
- static function OnUserLevelup($old, $new) {
- // 处理逻辑,
- $ubs = ctx()->privateState->unlockedBuild;
- foreach (GameConfig::build() as $id => $b) {
- isEditor() and $b = new \sm_build();
- if (!in_array($id, $ubs)) { # 尚未解锁的建筑,判断,已解锁的跳过
- if ($b->playerLevelLimit <= $new) { # 符合解锁条件
- ctx()->privateState->unlockedBuild[] = $id; # 插入解锁记录
- StatisticsProc::TargetStatistics(Enum_TargetStatistics::unlockbuidId, $id);
- if ($id == 1000) {
- $college = new Info_College();
- $college->setFunUnluckTs();
- }
- StatisticsProc::unlockBuild($id); # 统计全服玩家解锁建筑
- NormalEventProc::OnUnlockBuild($id, null); # 插入事件
- }
- }
- }
- // $map = ctx()->map;
- // foreach ($map->mainlands as $id => $mlnd) { # 检查解锁
- // $mlnd = new Ins_Mainland($mlnd);
- // foreach ($mlnd->getZoneMos() as $zoneid => $zone) {
- // isEditor()and $zone = new \sm_gate_zone();
- // if ($zone->playerLevelLimit <= $new) {
- // if (!CommUtil::isPropertyExists($mlnd->normal, $zoneid)) {
- // NormalEventProc::OnUnlockMap($zoneid, 0);
- // } else {
- // // 此区域已经解锁,走顺序关卡模式,除非有其他任务卡或者什么东西直接解锁了某个关卡
- // }
- // }
- // }
- // }
- NormalEventProc::OnUserLvlUp($old, $new); # 添加升级事件,算了这个暂时没人关注
- }
- }
|