using System.Collections.Generic;
namespace TestRegimentedRummyScoring
static void Main(string[] args)
PlayerGame playerGame = new PlayerGame();
playerGame.PlayerHands = new List<PlayerHand>
new PlayerHand { Round = 1, Score = 10 },
new PlayerHand { Round = 2, Score = 20 },
new PlayerHand { Round = 3, Score = 30 },
new PlayerHand { Round = 4, Score = 40, Reset = true },
new PlayerHand { Round = 5, Score = 50 },
new PlayerHand { Round = 6, Score = 60 }
Console.WriteLine($"Players score was {playerGame.GetPlayerScore()}");
public int Round { get; set; }
public int Score { get; set; }
public bool Reset { get; set; } = false;
public List<PlayerHand> PlayerHands { get; set; }
PlayerHands = new List<PlayerHand> { };
public int GetPlayerScore()
var ResetIndex = PlayerHands.OrderBy(t => t.Round).LastOrDefault(t => t.Reset == true);
return PlayerHands.Where(t => t.Round >= ResetIndex.Round).Sum(t => t.Score);
return PlayerHands.Sum(t => t.Score);