public IEnumerable <OutPoint> GetAllRegisteredCoins() { lock (StateLock) { return(Rounds.SelectMany(x => x.CoinsRegistered).Select(x => x.OutPoint).ToArray()); } }
public IEnumerable <OutPoint> GetSpentCoins() { lock (StateLock) { return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).Where(x => !x.Unspent).Select(x => x.OutPoint).ToArray()); } }
public Money SumAllQueuedCoinAmounts() { lock (StateLock) { return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).Sum(x => x.Amount)); } }
public IEnumerable <Money> GetAllQueuedCoinAmounts() { lock (StateLock) { return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).Select(x => x.Amount).ToArray()); } }
public SmartCoin GetSingleOrDefaultCoin(OutPoint coinReference) { lock (StateLock) { return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).SingleOrDefault(x => x.OutPoint == coinReference)); } }
public bool Contains(IEnumerable <OutPoint> outpoints) { lock (StateLock) { foreach (OutPoint txo in outpoints) { if (WaitingList.Keys .Concat(Rounds.SelectMany(x => x.CoinsRegistered)) .Any(x => x.OutPoint == txo)) { return(true); } } } return(false); }
private void GameOver() { Winner = Rounds.SelectMany(r => r.Scores).GroupBy(s => s.Player) .Select(s => new { player = s.Key, score = s.Sum(x => x.Total) }) .OrderByDescending(s => s.score).FirstOrDefault()?.player; }
public List <Player> Opponents(Player player) => Rounds.SelectMany(r => r.Opponents(player)).ToList();
// players should only play each-other once public bool IsValidMatch(Player player1, Player player2) => !Rounds.SelectMany(round => round.Matches).Any(x => x.Players.Contains(player1) && x.Players.Contains(player2));
public IReadOnlyList <PlayerNumber> DefeatedOthers() => Rounds.SelectMany(it => it.Defeateds).ToArray();