Beispiel #1
0
        static void Main(string[] args)
        {
            IClueGame game = new ClueGame(new SortedSet <string> {
                "dad", "mom", "james", "brynn", "autumn", "daniel"
            }, ClueMasterDetective.CARDS_ALL);

            var solver = new ClueSolver(game);

            solver.AddEntirePlayerHand("dad", game.PlayerHand("dad"));

            var selectedItem = "";

            while (selectedItem != MENUITEM_EXIT)
            {
                var selectedNumber = ShowMenu("Main Menu", "Option", MENU_ITEMS);
                selectedItem = MENU_ITEMS[selectedNumber - 1];
                switch (selectedItem)
                {
                case MENUITEM_SHOW_ENVELOPE_CARDS:
                    ShowPlayerPossibilities(solver, game.EnvelopePlayer);
                    break;

                case MENUITEM_SHOW_HANDS:
                    ShowHands(game);
                    break;

                case MENUITEM_SHOW_CARD_POSSIBILITIES:
                    ShowCardPossibilities(solver);
                    break;

                case MENUITEM_SHOW_PLAYER_POSSIBILITIES:
                    ShowPlayersPossibilities(game, solver);
                    break;

                case MENUITEM_SHOW_SUGGESTION_HISTORY:
                    ShowSuggestionHistory(game);
                    break;

                case MENUITEM_MAKE_REVELATION:
                    var player = GetPlayer(game);
                    if (player != null)
                    {
                        var card = GetCard(game);
                        if (card.HasValue)
                        {
                            var revelation = new Revelation(player, card.Value);
                            solver.AddRevelation(revelation);
                        }
                    }
                    break;

                case MENUITEM_MAKE_SUGGESTION:
                    var suggester = GetPlayer(game);
                    if (suggester != null)
                    {
                        var cards = GetOneOfEachCard(game).ToList();
                        if (cards.Count > 0)
                        {
                            var suggestion  = new Suggestion(suggester, cards);
                            var revelations = game.MakeSuggestion(suggestion);
                            solver.AddSuggestionResults(suggestion, revelations);
                        }
                    }
                    break;

                case MENUITEM_MAKE_SUGGESTION_WITH_RESPONSES:
                    var swrSuggester = GetPlayer(game);
                    if (swrSuggester != null)
                    {
                        var cards = GetOneOfEachCard(game).ToList();
                        if (cards.Count > 0)
                        {
                            var suggestion = new Suggestion(swrSuggester, cards);

                            // get revelations
                            var helpers     = GetPlayerList(game);
                            var revelations = new List <Revelation>();
                            foreach (var helper in helpers)
                            {
                                revelations.Add(new Revelation(helper, null));
                            }

                            solver.AddSuggestionResults(suggestion, revelations);
                        }
                    }
                    break;
                }
            }

            Console.WriteLine($"Input was {selectedItem}");
        }