Adds a data-driven event system (#47 schema, #48 activation, #49 TOTW): - EventDefinition JSON schema (event_type, effects, date range, is_manual) - data/events/totw_week1.json — TOTW event active by date range (2024–2030), injects 5 TOTW cards into the market as [EVENT] listings - data/events/seasonal_events.json — Spring Festival and Icon Weekend, manual-activation-only example events - migrations/0004_events.sql — events override table (NULL/1/0 per event) - services/event — load_event_definitions, compute_is_active (date range + manual override), get_active_events, get_all_with_status, activate/deactivate - routes/events — GET /events, GET /events/:id, POST .../activate, .../deactivate - services/market::refresh_npc_listings now accepts event_defs, injects bonus market cards from active events at 2× premium price - 5 new integration tests (events list, single, activate/deactivate cycle, 404 on unknown, market injection verification); 19/19 passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum EventType {
|
||||
Totw,
|
||||
Seasonal,
|
||||
Special,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PackWeightBoost {
|
||||
pub rarity: String,
|
||||
pub multiplier: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct EventEffects {
|
||||
pub pack_weight_boosts: Vec<PackWeightBoost>,
|
||||
pub bonus_market_cards: Vec<String>,
|
||||
pub unlocks_sbc_ids: Vec<String>,
|
||||
pub unlocks_objective_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct EventDefinition {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub event_type: EventType,
|
||||
pub starts_at: Option<String>,
|
||||
pub expires_at: Option<String>,
|
||||
pub is_manual: bool,
|
||||
pub effects: EventEffects,
|
||||
}
|
||||
|
||||
/// Event definition bundled with its current runtime active status.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EventWithStatus {
|
||||
#[serde(flatten)]
|
||||
pub definition: EventDefinition,
|
||||
pub is_active: bool,
|
||||
pub activated_at: Option<String>,
|
||||
pub deactivated_at: Option<String>,
|
||||
}
|
||||
Reference in New Issue
Block a user