local DR = select(2, ...)

local Constants = {
  VERSION = {
    SCHEMA = 1,
    PROTOCOL = 3,
  },
  COMMS = {
    PREFIX = "DROLLSV1",
    RETRY_MAX = 5,
    RETRY_BASE_SECONDS = 0.5,
    MESSAGE = {
      ACK = "DR_ACK",
      VERSION_ANNOUNCE = "DR_VERSION_ANNOUNCE",
      REQUEST_SNAPSHOT = "DR_REQUEST_SNAPSHOT",
      INIT_SESSION = "DR_INIT_SESSION",
      SUBMIT_ROLL = "DR_SUBMIT_ROLL",
      CANCEL_ROLL = "DR_CANCEL_ROLL",
      STATE_SNAPSHOT = "DR_STATE_SNAPSHOT",
      RESOLVE_RESULT = "DR_RESOLVE_RESULT",
      ROLLOFF_START = "DR_ROLLOFF_START",
      ROLLOFF_RESULT = "DR_ROLLOFF_RESULT",
      REWARD = "DR_REWARD",
      RAID_ACTIVE = "DR_RAID_ACTIVE",
      ROSTER_SYNC = "DR_ROSTER_SYNC",
      ROSTER_REQUEST = "DR_ROSTER_REQUEST",
      AUDIT_APPEND = "DR_AUDIT_APPEND",
      PING = "DR_PING",
      PONG = "DR_PONG",
    },
  },
  ROLL = {
    CATEGORY = {
      PASS = 0,
      TMOG = 1,
      OFFSPEC = 2,
      UPGRADE = 3,
      BIS = 4,
      TIER_2P = 5,
      TIER_4P = 6,
    },
    -- Needed items roll 1-200, greed/off-spec 1-100, cosmetic 1-50.
    RANGE = {
      [1] = { min = 1, max = 50 },
      [2] = { min = 1, max = 100 },
      [3] = { min = 1, max = 200 },
      [4] = { min = 1, max = 200 },
      [5] = { min = 1, max = 200 },
      [6] = { min = 1, max = 200 },
    },
    -- Contention order: BiS > 4-piece > 2-piece > Major Upgrade > Offspec > Tmog.
    PRIORITY = {
      [4] = 6, -- BIS
      [6] = 5, -- 4-piece
      [5] = 4, -- 2-piece
      [3] = 3, -- Upgrade
      [2] = 2, -- Offspec
      [1] = 1, -- Tmog
    },
    -- Roll power only multiplies NEED rolls; transmog/offspec/greed are
    -- standard flat rolls, and winning them costs no power.
    WEIGHTED = {
      [3] = true,
      [4] = true,
      [5] = true,
      [6] = true,
    },
    -- Defaults tuned via Monte Carlo simulation: power 1-200, everyone starts
    -- at 100, winners drop to floor(power x 0.60) at reward confirmation.
    -- Boss kills in designated raids restore +5 (raiders) / +12.5 (bench);
    -- a full 8-boss clear reproduces +40/+100 weekly totals. Weekly-reset
    -- accrual is available for other teams but disabled by default.
    WINNER_PENALTY_FACTOR = 0.60,
    BOSS_REGAIN = 5,
    BENCH_BOSS_REGAIN = 12.5,
    WEEKLY_REGAIN = 0,
    MIN_WEIGHT = 1,
    MAX_WEIGHT = 200,
    START_WEIGHT = 100,
  },
  SESSION = {
    STATE = {
      DRAFT = "DRAFT",
      OPEN = "OPEN",
      COLLECTING = "COLLECTING",
      RESOLVING = "RESOLVING",
      ROLLOFF = "ROLLOFF",
      AWARDED = "AWARDED",
      REWARDED = "REWARDED",
      ARCHIVED = "ARCHIVED",
    },
    MAJOR_TRANSITIONS = {
      OPEN = true,
      COLLECTING = true,
      RESOLVING = true,
      ROLLOFF = true,
      AWARDED = true,
      REWARDED = true,
      ARCHIVED = true,
    },
  },
  DEFERRED_TRADE = {
    STATUS = {
      TO_TRADE = "to_trade",
      TRADED = "traded",
      TIMEOUT = "timeout",
      CANCELLED = "cancelled",
    },
  },
  LIMITS = {
    AUDIT_EVENTS = 10000,
    LOG_ENTRIES = 2000,
    SEEN_MESSAGE_IDS = 4000,
  },
}

Constants.COMMS.RELIABLE = {
  [Constants.COMMS.MESSAGE.INIT_SESSION] = true,
  [Constants.COMMS.MESSAGE.STATE_SNAPSHOT] = true,
  [Constants.COMMS.MESSAGE.RESOLVE_RESULT] = true,
  [Constants.COMMS.MESSAGE.ROLLOFF_START] = true,
  [Constants.COMMS.MESSAGE.ROLLOFF_RESULT] = true,
  [Constants.COMMS.MESSAGE.REWARD] = true,
  [Constants.COMMS.MESSAGE.ROSTER_SYNC] = true,
}

DR:RegisterModule("Core.Constants", Constants)
