Beispiel #1
0
    protected void EnsureTicketDisplayValid()
    {
        for (int i = 0; i < TicketDisplay.Length; i++)
        {
            if (TicketDisplay[i] == null && TicketDeck.CanDraw())
            {
                TicketDisplay[i] = TicketDeck.Draw();
            }
        }

        var isDeckBigEnough = TicketDeck.CanDraw(TicketDisplay.Length - RuleSet.TicketAnyShownMaximum,
                                                 c => c.Color != Color.Any);

        if (isDeckBigEnough)
        {
            while (TicketDisplay.Count(c => c.Color == Color.Any) >= RuleSet.TicketAnyShownMaximum)
            {
                TicketDeck.Discard.AddRange(TicketDisplay);
                var index = 0;
                foreach (var item in TicketDeck.Draw(TicketDisplay.Length))
                {
                    TicketDisplay[index++] = item;
                }
            }
        }
    }
Beispiel #2
0
    public bool Claim(TrainCard pick, Player player, int claimsLeft)
    {
        if (pick == null)
        {
            if (!TicketDeck.CanDraw())
            {
                throw new ArgumentException("There is nothing left to draw");
            }

            player.Tickets.Add(TicketDeck.Draw());
            return(claimsLeft > 0);
        }

        player.Tickets.Add(pick);

        TicketDisplay[TicketDisplay.FindIndex(pick)] = null;

        EnsureTicketDisplayValid();

        return(pick.Color != Color.Any && TicketDisplay.Any(c => c?.Color != Color.Any) && claimsLeft > 0);
    }