Beispiel #1
0
        public override UpdateResult Update()
        {
            var arenaInfo = _gameDataProvider.GetArenaInfo();

            if (arenaInfo == null)
            {
                return(UpdateResult.Continue);
            }
            var numCards = arenaInfo.Deck.Cards.Sum(x => x.Count);

            if (numCards == MaxDeckSize)
            {
                if (_prevSlot == MaxDeckSize)
                {
                    OnCardPicked(arenaInfo);
                }
                DeckComplete?.Invoke(new ArenaDeckComlpeteEventArgs(arenaInfo));
                if (arenaInfo.Rewards?.Any() ?? false)
                {
                    RunComplete?.Invoke(new ArenaRunCompleteEventArgs(arenaInfo));
                }
                return(UpdateResult.Break);
            }
            if (HasChanged(arenaInfo, arenaInfo.CurrentSlot))
            {
                var choices = _gameDataProvider.GetDraftChoices();
                if (choices == null || choices.Length == 0)
                {
                    return(UpdateResult.Continue);
                }
                if (arenaInfo.CurrentSlot > _prevSlot)
                {
                    if (ChoicesHaveChanged(choices) || _sameChoices)
                    {
                        _sameChoices = false;
                        ChoicesChanged?.Invoke(new ArenaChoicesChangedEventArgs(choices, arenaInfo.Deck));
                    }
                    else
                    {
                        _sameChoices = true;
                        return(UpdateResult.Continue);
                    }
                }
                if (_prevSlot == 0 && arenaInfo.CurrentSlot == 1)
                {
                    OnHeroPicked(arenaInfo);
                }
                else if (_prevSlot > 0 && arenaInfo.CurrentSlot > _prevSlot)
                {
                    OnCardPicked(arenaInfo);
                }
                _prevSlot    = arenaInfo.CurrentSlot;
                _prevInfo    = arenaInfo;
                _prevChoices = choices;
            }
            return(UpdateResult.Continue);
        }
 private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     //update ui once worker complete his work
     mDebug     = false;
     mDebugWait = false;
     mDoStep    = false;
     RunComplete?.Invoke(this, EventArgs.Empty);
     System.Windows.MessageBox.Show("Расчет окончен!", MainWindowViewModel.PROGRAM_CAPTION, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
 }
Beispiel #3
0
 internal void OnArenaRunComplete(ArenaRunCompleteEventArgs args)
 {
     Update(args.Info);
     State = ArenaState.Complete;
     RunComplete?.Invoke(args);
 }