PetLevelUpEvent.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Module\Pet\Events;
  3. use Illuminate\Broadcasting\InteractsWithSockets;
  4. use Illuminate\Foundation\Events\Dispatchable;
  5. use Illuminate\Queue\SerializesModels;
  6. /**
  7. * 宠物升级事件
  8. *
  9. * 当宠物升级时触发此事件,允许其他系统响应宠物等级的变化。
  10. * 此事件可用于更新宠物属性、解锁新技能、记录升级日志等。
  11. */
  12. class PetLevelUpEvent
  13. {
  14. use Dispatchable, InteractsWithSockets, SerializesModels;
  15. /**
  16. * 用户ID
  17. *
  18. * @var int
  19. */
  20. public int $userId;
  21. /**
  22. * 宠物ID
  23. *
  24. * @var int
  25. */
  26. public int $petId;
  27. /**
  28. * 旧等级
  29. *
  30. * @var int
  31. */
  32. public int $oldLevel;
  33. /**
  34. * 新等级
  35. *
  36. * @var int
  37. */
  38. public int $newLevel;
  39. /**
  40. * 新解锁的技能列表
  41. *
  42. * @var array
  43. */
  44. public array $unlockedSkills;
  45. /**
  46. * 创建一个新的事件实例
  47. *
  48. * @param int $userId 用户ID
  49. * @param int $petId 宠物ID
  50. * @param int $oldLevel 旧等级
  51. * @param int $newLevel 新等级
  52. * @param array $unlockedSkills 新解锁的技能列表
  53. * @return void
  54. */
  55. public function __construct(int $userId, int $petId, int $oldLevel, int $newLevel, array $unlockedSkills = [])
  56. {
  57. $this->userId = $userId;
  58. $this->petId = $petId;
  59. $this->oldLevel = $oldLevel;
  60. $this->newLevel = $newLevel;
  61. $this->unlockedSkills = $unlockedSkills;
  62. }
  63. }