Exemplo n.º 1
0
        private void ClaimNoble(Noble noble)
        {
            if (noble == null)
            {
                // If no noble is specified, try selecting one who's requirements have or will be met.
                // Most of the time there won't be any. Sometimes there will be one. Rarely there will be multiple.
                noble = Board.Nobles.Where(n => Utilities.RequirementsMet(n.Requirements, CurrentPlayer.Bonuses)).FirstOrDefault();
            }
            else
            {
                // Verify noble is available
                if (!Board.Nobles.Contains(noble))
                {
                    throw new InvalidOperationException($"Noble {noble.Id} not found.");
                }

                // Verify noble requirements have been met
                if (!Utilities.RequirementsMet(noble.Requirements, CurrentPlayer.Bonuses))
                {
                    throw new InvalidOperationException($"The requirements for noble {noble.Id} have not been met.");
                }
            }

            // Claim it
            if (noble != null)
            {
                Board.TakeNoble(noble);
                CurrentPlayer.AddNoble(noble);
            }
        }