33 lines
981 B
C#
33 lines
981 B
C#
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
|
using JetBrains.Annotations;
|
|
using MongoDB.Bson;
|
|
using Realms;
|
|
|
|
namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
|
{
|
|
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
|
|
public class Session : RealmObject
|
|
{
|
|
[PrimaryKey]
|
|
public ObjectId ID { get; set; }
|
|
public float Time { get; set; }
|
|
public IList<float> Percentiles { get; }
|
|
public IList<Puzzle> PuzzlesSolved { get; }
|
|
|
|
public float MeanPercentile => Percentiles.Count == 0 ? .5f : Probability.Mean(Percentiles.ToArray());
|
|
|
|
[UsedImplicitly]
|
|
public Session()
|
|
{
|
|
ID = ObjectId.GenerateNewId();
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"Session {ID}: {PuzzlesSolved.Count} puzzles solved in {Time.ToTimeSpan():m':'ss}";
|
|
}
|
|
}
|
|
} |