private static void ShowPlayerPossibilities(ClueSolver solver, string player) { Console.WriteLine($"{player}"); foreach (var constraint in solver.GetPlayerConstraints(player)) { Console.Write($" {constraint.NumberOfOwnedCandidates}:".PadRight(10)); Console.Write(string.Join(", ", constraint.Candidates)); Console.WriteLine(); } }
private static void ShowPlayersPossibilities(IClueGame game, ClueSolver solver) { Console.WriteLine(); Console.WriteLine("BY PLAYER"); Console.WriteLine("--------------------"); Console.WriteLine(); foreach (var player in game.AllPlayers) { ShowPlayerPossibilities(solver, player); } }
private static void ShowCardPossibilities(ClueSolver solver) { Console.WriteLine(); Console.WriteLine("BY CARD"); Console.WriteLine("--------------------"); foreach (var category in solver.Game.CardsByCategory.Keys) { Console.WriteLine(); Console.WriteLine($"{category.ToUpperInvariant()}"); foreach (Card card in solver.Game.CardsByCategory[category]) { Console.Out.Write($"{card}:".PadRight(20)); Console.Write(string.Join(", ", solver.GetPotentialOwners(card))); Console.WriteLine(); } } }
private void ShowPossibleOwners(ClueSolver game) { var allCards = new SortedSet <Card>(); foreach (ISet <Card> cards in game.Cards.Values) { allCards.UnionWith(cards); } foreach (Card card in allCards) { Console.Out.WriteLine(card); foreach (string name in game.GetPotentialOwners(card)) { Console.Out.WriteLine($"\t{name}"); } } }
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}"); }