syntax = "proto3";

package freeexile.season;

// Enum defining the realm/league archetype
enum LeagueType {
  LEAGUE_TYPE_UNSPECIFIED = 0;
  LEAGUE_TYPE_STANDARD = 1;       // Permanent Realm (Thái Hư Giới) - Never resets
  LEAGUE_TYPE_CHALLENGE = 2;      // Standard Seasonal League (Thiên Đạo Luân Hồi) - Resets every 3-4 months
  LEAGUE_TYPE_HARDCORE = 3;       // 1-life seasonal league (Tử Sinh Luân Hồi) - Death migrates to Standard
  LEAGUE_TYPE_SOLO_SELF_FOUND = 4;// SSF (Độc Hành Tu Chân) - No party/trade, voluntary migration allowed
}

// Lifecycle state machine of a seasonal league
enum LeagueStatus {
  LEAGUE_STATUS_UNSPECIFIED = 0;
  LEAGUE_STATUS_UPCOMING = 1;     // Announced, countdown active, pre-downloading assets
  LEAGUE_STATUS_ACTIVE = 2;       // In progress, full gameplay, trading, ranking active
  LEAGUE_STATUS_FREEZING = 3;     // Pre-reset freeze (trading locked, sessions alerted)
  LEAGUE_STATUS_MIGRATING = 4;    // Background data pipeline migrating characters & stash to Standard
  LEAGUE_STATUS_ARCHIVED = 5;     // Season ended, historical leaderboards archived
}

// Core League Metadata
message LeagueInfo {
  string league_id = 1;           // Unique slug, e.g. "season_01_minh_nguyet", "standard"
  string display_name = 2;        // Human-readable localized title
  LeagueType league_type = 3;
  LeagueStatus status = 4;
  uint64 start_time_epoch_ms = 5;
  uint64 end_time_epoch_ms = 6;
  string big_update_version = 7;  // Engine version required, e.g. "v1.2.0"
  map<string, string> mechanic_flags = 8; // League-specific mechanics (e.g. "blood_altar": "enabled")
  uint32 active_players = 9;
}

// Stash tab model with PoE-style Remove-Only flag
message StashTabItem {
  string item_uuid = 1;
  string item_name = 2;
  string item_type = 3;
  uint32 item_level = 4;
  string rarity = 5;
  uint32 stack_count = 6;
  string raw_json_properties = 7;
}

message StashTab {
  string tab_id = 1;
  string tab_name = 2;
  string league_id = 3;
  bool is_remove_only = 4;        // True if migrated from past season (Can withdraw, cannot deposit)
  string color_hex = 5;
  uint32 slot_capacity = 6;
  repeated StashTabItem items = 7;
}

// Player character summary within a specific league
message SeasonCharacterSummary {
  string character_id = 1;
  string account_id = 2;
  string character_name = 3;
  string league_id = 4;
  uint32 level = 5;
  string martial_class = 6;
  bool is_alive = 7;              // False if died in Hardcore
  uint64 created_at_ms = 8;
  uint64 last_played_ms = 9;
}

// Request & Response Messages
message GetLeaguesRequest {
  string account_id = 1;
}

message GetLeaguesResponse {
  repeated LeagueInfo available_leagues = 1;
  string current_active_season_id = 2;
}

message CreateSeasonCharacterRequest {
  string account_id = 1;
  string character_name = 2;
  string martial_class = 3;
  string league_id = 4;           // Target league to create character in
}

message CreateSeasonCharacterResponse {
  bool success = 1;
  string message = 2;
  SeasonCharacterSummary character = 3;
}

// Migration broadcast to all online clients
message SeasonMigrationNotice {
  string expiring_league_id = 1;
  string target_standard_league_id = 2;
  uint64 freeze_timestamp_ms = 3;
  string maintenance_message = 4;
}
