'datetime', ]; /** * Get the character that owns this cooldown. */ public function character(): BelongsTo { return $this->belongsTo(Character::class); } /** * Check if this cooldown has expired */ public function hasExpired(): bool { $cooldownSeconds = config("game.cooldowns.{$this->action_type}", config('game.cooldowns.default', 60)); $secondsSinceAction = now()->diffInSeconds($this->last_action_at); return $secondsSinceAction >= $cooldownSeconds; } /** * Get remaining cooldown time in seconds */ public function getRemainingSecondsAttribute(): int { $cooldownSeconds = config("game.cooldowns.{$this->action_type}", config('game.cooldowns.default', 60)); $secondsSinceAction = now()->diffInSeconds($this->last_action_at); return max(0, $cooldownSeconds - $secondsSinceAction); } /** * Update the cooldown to now */ public function refresh(): void { $this->last_action_at = now(); $this->save(); } }