EventProc.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. $e->isValidValue($ctype);
  28. unset( req()->userInfo->game->privateState->cornerSignNotifications[$ctype]);
  29. UserProc::updateUserInfo();
  30. $arr = array_values(array_unique(req()->userInfo->game->privateState->cornerSignNotifications)); # 返回值去重
  31. // req()->userInfo->game->privateState->cornerSignNotifications = []; # 清理记录
  32. return Resp::ok(array("notifications" => $arr)); # 返回
  33. }
  34. /**
  35. * [7201] 拉取角标通知
  36. */
  37. static function GetCornerSignNotifications() {
  38. // 这里直接返回, 将来开发对应的触发逻辑, 给数组中添加相应的值
  39. $arr = array_values(array_unique(req()->userInfo->game->privateState->cornerSignNotifications)); # 返回值去重
  40. // req()->userInfo->game->privateState->cornerSignNotifications = []; # 清理记录
  41. UserProc::updateUserInfo();
  42. return Resp::ok(array("notifications" => $arr)); # 返回
  43. }
  44. static function Init() {
  45. Event::register('onpay', array(new Data_UserProfile(req()->userInfo->game->profile), "OnPay"));
  46. }
  47. /**
  48. * 收到请求
  49. */
  50. static function OnRequest() {
  51. }
  52. /**
  53. * 处理完毕准备返回
  54. */
  55. static function AfterResponse() {
  56. }
  57. /**
  58. * 当天第一次登录
  59. */
  60. static function OnNewDay() {
  61. }
  62. /**
  63. * 当周第一次登录(周一)
  64. */
  65. static function OnNewWeek() {
  66. }
  67. /**
  68. * 当玩家等级变更
  69. * @param type $old
  70. * @param type $new
  71. */
  72. static function OnUserLevelup($old, $new) {
  73. // 处理逻辑,
  74. $ubs = req()->userInfo->game->privateState->unlockedBuild;
  75. foreach (GameConfig::build() as $id => $b) {
  76. isEditor() and $b = new \sm_build();
  77. if (!in_array($id, $ubs)) { # 尚未解锁的建筑,判断,已解锁的跳过
  78. if ($b->playerLevelLimit <= $new) { # 符合解锁条件
  79. req()->userInfo->game->privateState->unlockedBuild[] = $id; # 插入解锁记录
  80. StatisticsProc::TargetStatistics(Enum_TargetStatistics::unlockbuidId, $id);
  81. if ($id == 1000) {
  82. $college = new Info_College();
  83. $college->setFunUnluckTs();
  84. }
  85. StatisticsProc::unlockBuild($id); # 统计全服玩家解锁建筑
  86. NormalEventProc::OnUnlockBuild($id, null); # 插入事件
  87. }
  88. }
  89. }
  90. $map = req()->userInfo->game->map;
  91. foreach ($map->mainlands as $id => $mlnd) { # 检查解锁
  92. $mlnd = new Ins_Mainland($mlnd);
  93. foreach ($mlnd->getZoneMos() as $zoneid => $zone) {
  94. isEditor()and $zone = new \sm_gate_zone();
  95. if ($zone->playerLevelLimit <= $new) {
  96. if (!CommUtil::isPropertyExists($mlnd->normal, $zoneid)) {
  97. NormalEventProc::OnUnlockMap($zoneid, 0);
  98. } else {
  99. // 此区域已经解锁,走顺序关卡模式,除非有其他任务卡或者什么东西直接解锁了某个关卡
  100. }
  101. }
  102. }
  103. }
  104. NormalEventProc::OnUserLvlUp($old, $new); # 添加升级事件,算了这个暂时没人关注
  105. }
  106. }