EventProc.php 3.7 KB

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