#nullable enable
using System;

namespace IGP.UnitySDK.GameKit
{
    /// <summary>
    /// One match result sent to the attached Host Session. JSON must be at most 64 KiB.
    /// Host owns acceptance and persistence; sending does not confirm either.
    /// </summary>
    [Serializable]
    public sealed class IGPMatchResultReport
    {
        public int schemaVersion = 2;
        /// <summary>Business idempotency key. Keep unchanged when explicitly retrying the same report.</summary>
        public string reportId = string.Empty;
        public string matchId = string.Empty;
        public string? sessionId;
        /// <summary>Required Arena room ID for this match report.</summary>
        public string roomId = string.Empty;
        /// <summary>COMPLETED, ABORTED, or FORFEITED.</summary>
        public string result = "COMPLETED";
        /// <summary>Nonnegative Unix milliseconds.</summary>
        public long startedAtUnixMs;
        /// <summary>Unix milliseconds, at least startedAtUnixMs.</summary>
        public long finishedAtUnixMs;
        /// <summary>All participants, including departed players; 1 to 256 unique IDs and exactly one isSelf.</summary>
        public IGPMatchPlayerResult[] players = Array.Empty<IGPMatchPlayerResult>();
        /// <summary>Game-defined JSON object; omitted when null.</summary>
        public object? metadata;
    }

    /// <summary>Game-reported participant result. Host owns identity and result validation.</summary>
    [Serializable]
    public sealed class IGPMatchPlayerResult
    {
        public string playerId = string.Empty;
        /// <summary>Whether this participant is the authenticated player making this report.</summary>
        public bool isSelf;
        public int? team;
        public int? placement;
        public long score;
        public bool? winner;
        /// <summary>Game-defined JSON statistics object; omitted when null.</summary>
        public object? statistics;
    }
}
