using System.ComponentModel.DataAnnotations;
namespace AnsonBot.Core;
///
/// One continuous period a player was connected to the server.
/// A session with a null is still open.
///
public class PlaySession
{
public int Id { get; set; }
/// Stable identity for the player. Steam ID where available.
[MaxLength(64)]
public string PlayerId { get; set; } = "";
/// Display name at the time of this session; players can rename.
[MaxLength(128)]
public string Name { get; set; } = "";
public DateTime StartedUtc { get; set; }
/// Null while the player is still online.
public DateTime? EndedUtc { get; set; }
///
/// Updated on every successful poll. If the bot dies without closing the
/// session, this is the best available estimate of when the player left.
///
public DateTime LastSeenUtc { get; set; }
public TimeSpan Duration => (EndedUtc ?? DateTime.UtcNow) - StartedUtc;
}