Exemple #1
0
        // Reserve 1 Card to your hand and take 1 gold.
        // Hand limit
        // Disk limit
        // You may discard the aquired gold (but why would you?)
        public void ReserveCard(string id, GemType?discard, Noble noble = null)
        {
            ThrowIfGameOver();

            // Verify reserve limit (3)
            if (CurrentPlayer.Reserve.Count == 3)
            {
                throw new InvalidOperationException($"Too many cards already reserved.");
            }

            // Verify card is available
            if (Board.AvailableCards.Where(c => c.Id == id).SingleOrDefault() == null)
            {
                throw new InvalidOperationException($"Card id {id} not found.");
            }

            // Verify disk limit 10 (if gold available then it will be taken and a discard must be specified).
            //  discard must not be specified if current disks < 10.
            if (Board.Bank.Available[GemType.Gold] > 0 && CurrentPlayer.TotalDisks == 10)
            {
                if (!discard.HasValue)
                {
                    throw new InvalidOperationException("Discard required.");
                }
                // Verify player owns discard or is discarding the gold aquired.
                if (CurrentPlayer.Disks[discard.Value] == 0)
                {
                    throw new InvalidOperationException($"{discard.Value} is not available to discard.");
                }
            }

            ClaimNoble(noble);

            // Move card from available to reserve
            var card = Board.AvailableCards.Where(c => c.Id == id).Single();

            Board.TakeCard(card);
            CurrentPlayer.AddReserve(card);

            // Discard specified
            if (discard.HasValue)
            {
                CurrentPlayer.RemoveDisks(discard.Value, 1);
                Board.Bank.Return(discard.Value, 1);
            }

            // Gain gold
            if (Board.Bank.Available[GemType.Gold] > 0)
            {
                Board.Bank.Take(GemType.Gold, 1);
                CurrentPlayer.AddDisks(GemType.Gold, 1);
            }

            _passCount = 0;

            AdvanceGame();
        }
Exemple #2
0
        // Draw secretly from any deck
        // Reserve 1 Card to your hand and take 1 gold.
        // Hand limit
        // Disk limit
        // Empty deck
        // You may discard the aquired gold (byt why would you?)
        public void ReserveSecret(int level, GemType?discard, Noble noble = null)
        {
            ThrowIfGameOver();

            // Verify reserve limit (3)
            if (CurrentPlayer.Reserve.Count == 3)
            {
                throw new InvalidOperationException($"Too many cards already reserved.");
            }


            // Verify level 1-3
            if (level < 1 || level > 3)
            {
                throw new InvalidOperationException($"Invlaid level {level} selected.");
            }

            // Verify level has cards
            if (Board.CheckLevelDeckIsEmpty(level))
            {
                throw new InvalidOperationException($"Level {level} deck is empty.");
            }

            // Verify disk limit 10 (if gold available then it will be taken and a discard must be specified).
            //  discard must not be specified if current disks < 10.
            if (Board.Bank.Available[GemType.Gold] > 0 && CurrentPlayer.TotalDisks == 10)
            {
                if (!discard.HasValue)
                {
                    throw new InvalidOperationException("Discard required.");
                }
                // Verify player owns discard or is discarding the gold aquired.
                if (CurrentPlayer.Disks[discard.Value] == 0)
                {
                    throw new InvalidOperationException($"{discard.Value} is not available to discard.");
                }
            }

            ClaimNoble(noble);

            // Move card from deck to reserve
            var card = Board.TakeSecret(level);

            CurrentPlayer.AddReserve(card);

            // Discard specified
            if (discard.HasValue)
            {
                CurrentPlayer.RemoveDisks(discard.Value, 1);
                Board.Bank.Return(discard.Value, 1);
            }

            // Gain gold
            if (Board.Bank.Available[GemType.Gold] > 0)
            {
                Board.Bank.Take(GemType.Gold, 1);
                CurrentPlayer.AddDisks(GemType.Gold, 1);
            }

            _passCount = 0;

            AdvanceGame();
        }