| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Module\Pet\Events;
- use Illuminate\Broadcasting\InteractsWithSockets;
- use Illuminate\Foundation\Events\Dispatchable;
- use Illuminate\Queue\SerializesModels;
- /**
- * 宠物战斗事件
- *
- * 当宠物参与战斗时触发此事件,允许其他系统响应宠物战斗的结果。
- * 此事件可用于记录战斗日志、更新宠物状态、处理战斗奖励等。
- */
- class PetBattleEvent
- {
- use Dispatchable, InteractsWithSockets, SerializesModels;
- /**
- * 用户ID
- *
- * @var int
- */
- public int $userId;
- /**
- * 宠物ID
- *
- * @var int
- */
- public int $petId;
- /**
- * 战斗类型
- * 1: 偷菜战斗
- * 2: 守护战斗
- * 3: 争霸赛战斗
- *
- * @var int
- */
- public int $battleType;
- /**
- * 对手ID(可为空)
- *
- * @var int|null
- */
- public ?int $opponentId;
- /**
- * 战斗结果
- * 0: 失败
- * 1: 胜利
- *
- * @var int
- */
- public int $result;
- /**
- * 战斗奖励
- *
- * @var array|null
- */
- public ?array $reward;
- /**
- * 创建一个新的事件实例
- *
- * @param int $userId 用户ID
- * @param int $petId 宠物ID
- * @param int $battleType 战斗类型
- * @param int|null $opponentId 对手ID
- * @param int $result 战斗结果
- * @param array|null $reward 战斗奖励
- * @return void
- */
- public function __construct(int $userId, int $petId, int $battleType, ?int $opponentId, int $result, ?array $reward = null)
- {
- $this->userId = $userId;
- $this->petId = $petId;
- $this->battleType = $battleType;
- $this->opponentId = $opponentId;
- $this->result = $result;
- $this->reward = $reward;
- }
- }
|