示例#1
0
 public IEnumerable <OutPoint> GetAllRegisteredCoins()
 {
     lock (StateLock)
     {
         return(Rounds.SelectMany(x => x.CoinsRegistered).Select(x => x.OutPoint).ToArray());
     }
 }
示例#2
0
 public IEnumerable <OutPoint> GetSpentCoins()
 {
     lock (StateLock)
     {
         return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).Where(x => !x.Unspent).Select(x => x.OutPoint).ToArray());
     }
 }
示例#3
0
 public Money SumAllQueuedCoinAmounts()
 {
     lock (StateLock)
     {
         return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).Sum(x => x.Amount));
     }
 }
示例#4
0
 public IEnumerable <Money> GetAllQueuedCoinAmounts()
 {
     lock (StateLock)
     {
         return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).Select(x => x.Amount).ToArray());
     }
 }
示例#5
0
 public SmartCoin GetSingleOrDefaultCoin(OutPoint coinReference)
 {
     lock (StateLock)
     {
         return(WaitingList.Keys.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).SingleOrDefault(x => x.OutPoint == coinReference));
     }
 }
示例#6
0
        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);
        }
示例#7
0
 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;
 }
示例#8
0
 public List <Player> Opponents(Player player) => Rounds.SelectMany(r => r.Opponents(player)).ToList();
示例#9
0
 // 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));
示例#10
0
 public IReadOnlyList <PlayerNumber> DefeatedOthers()
 => Rounds.SelectMany(it => it.Defeateds).ToArray();