EventProc.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 事件模块.
  5. * @version
  6. * 1.0.0 Created at 2017-8-28. by --gwang
  7. * @author gwang (mail@wanggangzero.cn)
  8. * @copyright ? 2017-8-28, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  9. */
  10. class EventProc {
  11. public static function procMain() {
  12. switch (req()->cmd) {
  13. case CmdCode::cmd_event_GetNotifications: # 7201 拉取角标通知列表
  14. return self::GetCornerSignNotifications();
  15. case CmdCode::cmd_event_ClearNotifications: # 7202 清理指定类型的角标
  16. return self::ClearCornerSignNotification();
  17. default:
  18. return Resp::err(ErrCode::cmd_err);
  19. }
  20. }
  21. /**
  22. * [7202] 清理指定类型的角标记录
  23. */
  24. static function ClearCornerSignNotification() {
  25. $ctype = req()->paras[0];
  26. $e = new OperateEventType();
  27. if ($e->isValidValue($ctype)) {
  28. StlUtil::arrayRemove(ctx()->privateState->cornerSignNotifications, $ctype); # 移除角标
  29. UserProc::updateUserInfo();
  30. }
  31. $arr = array_values(array_unique(ctx()->privateState->cornerSignNotifications)); # 返回值去重
  32. ctx()->privateState->cornerSignNotifications = $arr; # 更新记录
  33. return Resp::ok(array("notifications" => $arr)); # 返回
  34. }
  35. /**
  36. * [7201] 拉取角标通知
  37. */
  38. static function GetCornerSignNotifications() {
  39. // 这里直接返回, 将来开发对应的触发逻辑, 给数组中添加相应的值
  40. $arr = array_values(array_unique(ctx()->privateState->cornerSignNotifications)); # 返回值去重
  41. ctx()->privateState->cornerSignNotifications = $arr; # 更新记录
  42. UserProc::updateUserInfo();
  43. return Resp::ok(array("notifications" => $arr)); # 返回
  44. }
  45. static function Init() {
  46. Event::register('onpay', array(new Data_UserProfile(ctx()->profile), "OnPay"));
  47. }
  48. /**
  49. * 收到请求
  50. */
  51. static function OnRequest() {
  52. }
  53. /**
  54. * 处理完毕准备返回
  55. */
  56. static function AfterResponse() {
  57. }
  58. /**
  59. * 当天第一次登录
  60. */
  61. static function OnNewDay() {
  62. CornerSignEventProc::OnNewDay();
  63. }
  64. /**
  65. * 当周第一次登录(周一)
  66. */
  67. static function OnNewWeek() {
  68. }
  69. /**
  70. * 当玩家等级变更
  71. * @param type $old
  72. * @param type $new
  73. */
  74. static function OnUserLevelup($old, $new) {
  75. // 处理逻辑,
  76. $ubs = ctx()->privateState->unlockedBuild;
  77. foreach (GameConfig::build() as $id => $b) {
  78. isEditor() and $b = new \sm_build();
  79. if (!in_array($id, $ubs)) { # 尚未解锁的建筑,判断,已解锁的跳过
  80. if ($b->playerLevelLimit <= $new) { # 符合解锁条件
  81. ctx()->privateState->unlockedBuild[] = $id; # 插入解锁记录
  82. StatisticsProc::TargetStatistics(Enum_TargetStatistics::unlockbuidId, $id);
  83. if ($id == 1000) {
  84. $college = new Info_College();
  85. $college->setFunUnluckTs();
  86. }
  87. StatisticsProc::unlockBuild($id); # 统计全服玩家解锁建筑
  88. NormalEventProc::OnUnlockBuild($id, null); # 插入事件
  89. }
  90. }
  91. }
  92. // $map = ctx()->map;
  93. // foreach ($map->mainlands as $id => $mlnd) { # 检查解锁
  94. // $mlnd = new Ins_Mainland($mlnd);
  95. // foreach ($mlnd->getZoneMos() as $zoneid => $zone) {
  96. // isEditor()and $zone = new \sm_gate_zone();
  97. // if ($zone->playerLevelLimit <= $new) {
  98. // if (!CommUtil::isPropertyExists($mlnd->normal, $zoneid)) {
  99. // NormalEventProc::OnUnlockMap($zoneid, 0);
  100. // } else {
  101. // // 此区域已经解锁,走顺序关卡模式,除非有其他任务卡或者什么东西直接解锁了某个关卡
  102. // }
  103. // }
  104. // }
  105. // }
  106. NormalEventProc::OnUserLvlUp($old, $new); # 添加升级事件,算了这个暂时没人关注
  107. }
  108. }