70 lines
2.2 KiB
C#
70 lines
2.2 KiB
C#
namespace Faraon.Core.Models;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
public record GameLogItem(
|
|
string Icon,
|
|
string Text,
|
|
string? SubText,
|
|
DateTime Time,
|
|
string? PlayerName = null,
|
|
string? PlayerAvatar = null,
|
|
string? AccentColor = null
|
|
);
|
|
|
|
public class GameMatchStats
|
|
{
|
|
public DateTime StartTime { get; set; } = DateTime.UtcNow;
|
|
public DateTime? EndTime { get; set; }
|
|
public TimeSpan Duration => (EndTime ?? DateTime.UtcNow) - StartTime;
|
|
public int TotalTurns { get; set; }
|
|
public int TotalAcesPlayed { get; set; }
|
|
public int TotalSevensPlayed { get; set; }
|
|
public int TotalCardsBurned { get; set; }
|
|
public int MaxPenaltyDrawnInOneTurn { get; set; }
|
|
public string? MaxPenaltyPlayerName { get; set; }
|
|
|
|
public Dictionary<string, int> CardsPlayedPerPlayer { get; } = new();
|
|
public Dictionary<string, int> CardsDrawnPerPlayer { get; } = new();
|
|
public Dictionary<string, int> BurnsPerPlayer { get; } = new();
|
|
|
|
public void RecordCardPlayed(Player player, int count = 1)
|
|
{
|
|
CardsPlayedPerPlayer[player.Name] = CardsPlayedPerPlayer.GetValueOrDefault(player.Name) + count;
|
|
}
|
|
|
|
public void RecordCardDrawn(Player player, int count = 1)
|
|
{
|
|
CardsDrawnPerPlayer[player.Name] = CardsDrawnPerPlayer.GetValueOrDefault(player.Name) + count;
|
|
if (count > MaxPenaltyDrawnInOneTurn)
|
|
{
|
|
MaxPenaltyDrawnInOneTurn = count;
|
|
MaxPenaltyPlayerName = player.Name;
|
|
}
|
|
}
|
|
|
|
public void RecordBurn(Player player)
|
|
{
|
|
TotalCardsBurned += 4;
|
|
BurnsPerPlayer[player.Name] = BurnsPerPlayer.GetValueOrDefault(player.Name) + 1;
|
|
}
|
|
|
|
public string GetMvpPlayerName()
|
|
{
|
|
string best = "Nikto";
|
|
int bestScore = -999;
|
|
foreach (var (name, played) in CardsPlayedPerPlayer)
|
|
{
|
|
int burns = BurnsPerPlayer.GetValueOrDefault(name);
|
|
int drawn = CardsDrawnPerPlayer.GetValueOrDefault(name);
|
|
int score = (played * 2) + (burns * 10) - drawn;
|
|
if (score > bestScore)
|
|
{
|
|
bestScore = score;
|
|
best = name;
|
|
}
|
|
}
|
|
return best;
|
|
}
|
|
} |