This commit is contained in:
2026-09-01 11:59:00 +02:00
parent b2c1d67283
commit 9cf127b16d
10 changed files with 509 additions and 33 deletions
+14 -2
View File
@@ -11,8 +11,12 @@ use Illuminate\Validation\ValidationException;
class RoomEmoteService
{
public function throwPaperBall(Room $room, Player $player, int $targetPlayerId): void
{
public function throwPaperBall(
Room $room,
Player $player,
int $targetPlayerId,
int $chargePercentage,
): void {
if ($targetPlayerId === $player->id) {
throw ValidationException::withMessages([
'target_player_id' => 'Du kannst dich nicht selbst abwerfen.',
@@ -39,11 +43,19 @@ class RoomEmoteService
RateLimiter::hit($rateLimitKey, 10);
$chargeLevel = match (true) {
$chargePercentage >= 300 => 3,
$chargePercentage >= 200 => 2,
$chargePercentage >= 100 => 1,
default => 0,
};
PaperBallThrown::dispatch(
Str::uuid()->toString(),
$room->id,
$player->id,
$targetPlayerId,
$chargeLevel,
);
}
}