EventProc.php 3.3 KB

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