private void _ConstructCardChoiceModel(List<DeckPlace> sourceDecks, List<string> resultDeckNames, List<int> resultDeckMaximums, AdditionalCardChoiceOptions options, ICardChoiceVerifier verifier, int timeOutSeconds, CardChoiceRearrangeCallback callback) { bool isSingleResult = (resultDeckMaximums.Sum() == 1); var choiceModel = new CardChoiceViewModel(); int numLines = sourceDecks.Count; foreach (var deck in sourceDecks) { if (Game.CurrentGame.Decks[deck].Count == 0) { continue; } CardChoiceLineViewModel line = new CardChoiceLineViewModel(); line.DeckName = deck.DeckType.Name; line.IsResultDeck = false; int i = 0; int numCards = Game.CurrentGame.Decks[deck].Count; int maxColumns = Math.Max(numCards / 2 + 1, 5); bool firstRow = true; foreach (var card in Game.CurrentGame.Decks[deck]) { if (numLines == 1 && isSingleResult && i >= maxColumns && firstRow) { Trace.Assert(choiceModel.CardStacks.Count == 0); choiceModel.CardStacks.Add(line); line = new CardChoiceLineViewModel(); line.DeckName = deck.DeckType.Name; line.IsResultDeck = false; firstRow = false; } CardViewModel model = new CardViewModel() { Card = card, IsSelectionMode = isSingleResult, IsEnabled = true }; line.Cards.Add(model); i++; } choiceModel.CardStacks.Add(line); } if (!isSingleResult) { int k = 0; foreach (var deckName in resultDeckNames) { CardChoiceLineViewModel line = new CardChoiceLineViewModel(); line.DeckName = deckName; if (options != null) { if (options.Rearrangeable != null) { line.Rearrangable = options.Rearrangeable[k]; } if (options.DefaultResult != null) { foreach (var card in options.DefaultResult[k]) { line.Cards.Add(new CardViewModel() { Card = card }); } } } line.Capacity = resultDeckMaximums[k++]; line.IsResultDeck = true; choiceModel.CardStacks.Add(line); } } if (options != null && options.Options != null) { for (int i = 0; i < options.Options.Count; i++) { MultiChoiceCommand command = new MultiChoiceCommand(ExecuteCardChoiceCommand) { CanExecuteStatus = false, ChoiceKey = options.Options[i], ChoiceIndex = i }; choiceModel.MultiChoiceCommands.Add(command); } } else { MultiChoiceCommand command = new MultiChoiceCommand(ExecuteCardChoiceCommand) { CanExecuteStatus = false, ChoiceKey = new OptionPrompt("Confirm") }; choiceModel.MultiChoiceCommands.Add(command); } if (options != null && options.IsCancellable) { MultiChoiceCommand command = new MultiChoiceCommand(CancelCardChoiceCommand) { IsCancel = true, ChoiceKey = new OptionPrompt("Cancel") }; choiceModel.MultiChoiceCommands.Add(command); } choiceModel.Verifier = verifier; choiceModel.TimeOutSeconds = timeOutSeconds; CardChoiceModel = choiceModel; }
public void DisplayPrivateDeck(Player player, PrivateDeckViewModel model) { var choiceModel = new CardChoiceViewModel(); choiceModel.CanClose = true; choiceModel.Prompt = PromptFormatter.Format(new CardChoicePrompt("PrivateDeck", player, model.TraslatedName)); var lineViewModel = new CardChoiceLineViewModel(); lineViewModel.DeckName = model.Name; lineViewModel.Cards = model.Cards; choiceModel.CardStacks.Add(lineViewModel); choiceModel.DisplayOnly = true; deckDisplayWindow.DataContext = choiceModel; deckDisplayWindow.Show(); }
private void _ConstructCardChoiceModel(List<DeckPlace> sourceDecks, List<string> resultDeckNames, List<int> resultDeckMaximums, List<bool> rearrangeable, int timeOutSeconds, CardChoiceRearrangeCallback callback) { if (resultDeckMaximums.Sum() != 1) { throw new NotImplementedException(); } CardChoiceModel.CardStacks.Clear(); int numLines = sourceDecks.Count; foreach (var deck in sourceDecks) { if (Game.CurrentGame.Decks[deck].Count == 0) { continue; } CardChoiceLineViewModel line = new CardChoiceLineViewModel(); line.DeckName = deck.DeckType.Name; int i = 0; int numCards = Game.CurrentGame.Decks[deck].Count; int maxColumns = Math.Max(numCards / 2 + 1, 5); bool firstRow = true; foreach (var card in Game.CurrentGame.Decks[deck]) { if (numLines == 1 && i >= maxColumns && firstRow) { Trace.Assert(CardChoiceModel.CardStacks.Count == 0); CardChoiceModel.CardStacks.Add(line); line = new CardChoiceLineViewModel(); line.DeckName = deck.DeckType.Name; firstRow = false; } CardViewModel model = new CardViewModel() { Card = card, IsSelectionMode = true, IsEnabled = true }; model.OnSelectedChanged += cardChoice_OnSelectedChanged; line.Cards.Add(model); i++; } CardChoiceModel.CardStacks.Add(line); } CardChoiceModel.TimeOutSeconds = timeOutSeconds; }