caelum0x 80349345d1 feat: match-found screen, backend rate limiting + readiness, lifesteal
Web (web/): add a dedicated "Match Found" experience — when matchmaking
polling reports "matched", the Queue transitions to a MatchFound view
showing the Photon sessionId + deckId, an Enter Battle stub (no realtime
client yet), and Back to Menu that resets queue state. +3 tests (14 total).

Backend (services/): security + ops hardening.
- @fastify/rate-limit: env-driven global default plus stricter per-route
  limits on all /auth/* endpoints and POST /economy/purchase/validate,
  returning 429 { error: "rate_limited" } via the shared error handler.
- GET /ready readiness probe checking Postgres (SELECT 1) + Redis (ping),
  200 ready / 503 not_ready; GET /health stays as liveness.
- Env limits set high in both vitest configs so existing suites don't trip;
  dedicated test asserts the 429 boundary and both /ready outcomes.
  43 unit + 8 integration tests green.

Game (Assets/, Unity C#): add a lifesteal stat on CharacterConfig, wired
into Unit.ExecuteHit (heals attacker by damage*lifesteal via a new clamped
Health.Heal), and a new sustain-bruiser champion "Reaper". Unverified in
editor (no Unity toolchain available).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 18:29:12 +03:00

54 lines
1.7 KiB
C#

using System;
using UnityEngine;
namespace FPClash
{
/// <summary>Hit points + damage/death events. Shared by units and towers.</summary>
public class Health : MonoBehaviour
{
public float Max { get; private set; } = 100f;
public float Current { get; private set; } = 100f;
public bool IsAlive => Current > 0f;
public float Fraction => Max > 0f ? Mathf.Clamp01(Current / Max) : 0f;
/// <summary>(amount, source) fired whenever damage is applied to a live target.</summary>
public event Action<float, object> Damaged;
/// <summary>(source) fired once when hp reaches zero.</summary>
public event Action<object> Died;
/// <summary>fired on Reset/respawn.</summary>
public event Action Revived;
public void Configure(float max)
{
Max = Mathf.Max(1f, max);
Current = Max;
}
public void ApplyDamage(float amount, object source)
{
if (!IsAlive || amount <= 0f) return;
Current = Mathf.Max(0f, Current - amount);
Damaged?.Invoke(amount, source);
if (Current <= 0f)
Died?.Invoke(source);
}
/// <summary>
/// Restores health, clamped to Max. Mirrors ApplyDamage's guards (ignored
/// when dead or amount is non-positive). Health bars poll Fraction, so no
/// explicit refresh event is required.
/// </summary>
public void Heal(float amount)
{
if (!IsAlive || amount <= 0f) return;
Current = Mathf.Min(Max, Current + amount);
}
public void Revive()
{
Current = Max;
Revived?.Invoke();
}
}
}