Sanguosha.UI.Controls.PlayerViewModel.AskForCardChoice C# (CSharp) Method

AskForCardChoice() public method

public AskForCardChoice ( Prompt prompt, List sourceDecks, List resultDeckNames, List resultDeckMaximums, ICardChoiceVerifier verifier, int timeOutSeconds, AdditionalCardChoiceOptions options, CardChoiceRearrangeCallback callback ) : void
prompt Sanguosha.Core.UI.Prompt
sourceDecks List
resultDeckNames List
resultDeckMaximums List
verifier ICardChoiceVerifier
timeOutSeconds int
options Sanguosha.Core.UI.AdditionalCardChoiceOptions
callback CardChoiceRearrangeCallback
return void
        public void AskForCardChoice(Prompt prompt, List<DeckPlace> sourceDecks,
                                     List<string> resultDeckNames,
                                     List<int> resultDeckMaximums,
                                     ICardChoiceVerifier verifier,
                                     int timeOutSeconds,
                                     AdditionalCardChoiceOptions options,
                                     CardChoiceRearrangeCallback callback)
        {
            if (ViewModelBase.IsDetached) return;
            Trace.Assert(!Player.IsDead);
            if (this != GameModel.MainPlayerModel && (verifier.Helper == null || !verifier.Helper.ShowToAll))
            {
                TimeOutSeconds = timeOutSeconds;
                CardChoiceAnsweredEvent(null);
                return;
            }
            Trace.Assert(resultDeckMaximums.Count == resultDeckNames.Count);

            Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
            {
                GameModel.CurrentActivePlayer = this;
                if (!IsPlayable)
                {
                    Trace.Assert(currentUsageVerifier == null);
                    TimeOutSeconds = timeOutSeconds;
                    CardChoiceAnsweredEvent(null);
                }
                if (GameModel.MainPlayerModel != this)
                {
                    prompt.ResourceKey = prompt.ResourceKey + Prompt.NonPlaybleAppendix;
                    prompt.Values.Insert(0, Player);
                }
                if (options != null && options.IsWuGu)
                {
                    // Trace.Assert(GameModel.WuGuModel != null);
                    TimeOutSeconds = timeOutSeconds;
                    // @todo: Fix this to show wugu on reconnection
                    if (GameModel != null && GameModel.WuGuModel != null)
                    {
                        GameModel.WuGuModel.IsEnabled = IsPlayable;
                        GameModel.WuGuModel.Prompt = LogFormatter.Translate(prompt);
                    }
                }
                else if (options != null && options.IsTwoSidesCardChoice)
                {
                    if (GameModel != null && GameModel.TwoSidesCardChoiceModel != null)
                    {
                        GameModel.TwoSidesCardChoiceModel.IsEnabled = IsPlayable;
                        GameModel.TwoSidesCardChoiceModel.Prompt = LogFormatter.Translate(prompt);
                        bool isMainPlayer =
                            GameModel.TwoSidesCardChoiceModel.GroupOfPlayer[GameModel.MainPlayerModel.Id] == GameModel.TwoSidesCardChoiceModel.GroupOfPlayer[Id];
                        if (isMainPlayer)
                        {
                            GameModel.TwoSidesCardChoiceModel.TimeOutSeconds1 = timeOutSeconds;
                        }
                        else
                        {
                            GameModel.TwoSidesCardChoiceModel.TimeOutSeconds2 = timeOutSeconds;
                        }
                    }
                }
                else
                {
                    _currentChoiceOptions = options;
                    _ConstructCardChoiceModel(sourceDecks, resultDeckNames, resultDeckMaximums, options, verifier, timeOutSeconds, callback);
                    CardChoiceModel.Prompt = LogFormatter.Translate(prompt);
                    if (!IsPlayable)
                    {
                        CardChoiceModel.DisplayOnly = true;
                        prompt.Values.Insert(0, Player);
                        CurrentCardChoiceRearrangeCallback = null;
                    }
                    else
                    {
                        CurrentCardChoiceRearrangeCallback = callback;
                    }
                    IsCardChoiceQuestionShown = true;
                }
            });
        }