Beispiel #1
0
 private IEnumerator Start()
 {
     this.set_Validator(new global::h.N());
     if (SceneManager.GetActiveScene().name != Constants.Px())
     {
         EditDeckProvider provider = DataProvider.Get <EditDeckProvider>();
         if (provider.get_Mode() == DeckEditorModes.Quest || provider.get_Mode() == DeckEditorModes.Conquest || provider.get_Mode() == DeckEditorModes.Chaos)
         {
             Archetypes        archetypes = Finder.FindOrThrow <Archetypes>();
             AdventureProvider adventure  = AdventureProvider.Find();
             while (adventure.SelectedAdventure.get_DeckInfo() == null)
             {
                 yield return(null);
             }
             global::g.a a = new global::g.a(provider, archetypes, adventure.SelectedAdventure);
             this.subscriptionProvider.set_Data(a.get_Composition());
             global::d.M one  = Finder.FindOrThrow <AccountProvider>().get_Account().GetOne <global::d.M>();
             int         num  = (int)((ArenaTiers)9 - ((provider.get_Mode() == DeckEditorModes.Quest) ? one.get_PvERank() : one.get_PvPRank()));
             string      text = "rank=" + num + "\n";
             foreach (ArchetypeID key in adventure.SelectedAdventure.get_Collection().A)
             {
                 if (archetypes.get_All().ContainsKey(key))
                 {
                     text = text + archetypes.get_All()[key].GetOne <NameData>().get_Name() + "\r\n";
                 }
             }
             try
             {
                 File.WriteAllText((provider.get_Mode() == DeckEditorModes.Quest) ? "decks\\arena-solo.txt" : "decks\\arena.txt", text);
             }
             catch
             {
             }
             archetypes = null;
             adventure  = null;
             archetypes = null;
             adventure  = null;
         }
         provider = null;
         provider = null;
     }
     else
     {
         AsyncTournamentsProvider  asyncTournamentsProvider = AsyncTournamentsProvider.Find();
         AsyncTournamentDefinition selectedTournament       = asyncTournamentsProvider.get_SelectedTournament();
         if (selectedTournament != null && !selectedTournament.Run.AllowDeckSwitching)
         {
             Archetypes archetypes2 = Finder.FindOrThrow <Archetypes>();
             AsyncTournamentProgress tournamentProgress = asyncTournamentsProvider.GetTournamentProgress(selectedTournament.ID);
             if (tournamentProgress != null)
             {
                 SerializableDeck deck = tournamentProgress.Deck;
                 global::A.I      i    = new global::A.I(asyncTournamentsProvider, archetypes2, selectedTournament, deck);
                 this.subscriptionProvider.set_Data(i.get_Composition());
             }
         }
     }
     yield break;
     yield break;
 }
Beispiel #2
0
 private void loadDeck(DeckComponent deck)
 {
     this.current_deck.Clear();
     if (deck != null)
     {
         Archetypes archetypes = Finder.FindOrThrow <Archetypes>();
         Directory.CreateDirectory("decks");
         foreach (KeyValuePair <DeckID, DeckComponent> keyValuePair in Finder.FindOrThrow <Decks>().get_All())
         {
             Pile pile2;
             if (keyValuePair.Key != null && keyValuePair.Value.get_Piles().TryGetValue(Constants.K(), out pile2))
             {
                 string to_write = "";
                 foreach (KeyValuePair <ArchetypeID, int> keyValuePair2 in pile2)
                 {
                     to_write = string.Concat(new object[]
                     {
                         to_write,
                         archetypes.get_All()[keyValuePair2.Key].GetOne <NameData>().get_Name(),
                         " ",
                         keyValuePair2.Value,
                         "\r\n"
                     });
                 }
                 File.WriteAllText(Path.Combine("decks", keyValuePair.Value.get_Name() + ".txt"), to_write);
             }
         }
         Pile pile3;
         if (deck.get_Piles().TryGetValue(Constants.K(), out pile3))
         {
             foreach (KeyValuePair <ArchetypeID, int> keyValuePair3 in pile3)
             {
                 ArchetypeComponent archetypeComponent;
                 if (this.local_collection_avatars.get_All().TryGetValue(keyValuePair3.Key, out archetypeComponent))
                 {
                     this.tryToMove(keyValuePair3.Key, keyValuePair3.Value);
                 }
                 else
                 {
                     Debug.LogError(Constants.Fx() + keyValuePair3.Key);
                 }
             }
         }
         foreach (global::H.L l in this.current_deck.get_Stacks())
         {
             l.GetOne <global::g.p>().MarkAsRead();
         }
         ArchetypeComponent avatar = deck.GetAvatar(this.local_collection_avatars);
         this.deck_avatars.SetAvatar(avatar);
     }
     if (deck != null)
     {
         this.deck_name.SetName(deck.GetOne <DeckNameData>().get_Name(), deck.GetOne <global::E.y>().get_HasAutoName());
     }
     this.deck_editor_saver.set_UnsavedChanges(false);
 }
        protected override IEnumerator execute()
        {
            DeckEditScene    scene         = Finder.FindOrThrow <DeckEditScene>();
            EditDeckProvider sceneProvider = DataProvider.Get <EditDeckProvider>();
            CommandExecutor  executor      = Finder.FindOrThrow <CommandExecutor>();
            bool             flag          = true;
            LocalizedString  failure       = null;

            if (flag && scene.get_Tutorial() != null)
            {
                global::h.L request = new global::h.L();
                Coroutine   coroutine;
                scene.get_Tutorial().EndorseRequest(request, out coroutine);
                if (coroutine != null)
                {
                    yield return(coroutine);
                }
                flag    = !request.get_Denied();
                request = null;
            }
            if (flag)
            {
                if (scene.get_Validator().IsSaveValid(out failure))
                {
                    SaveDeckToServer save = new SaveDeckToServer(this.deckSave.editor.AsSerializableDeck());
                    yield return(executor.Execute(save));

                    if (save.get_Success())
                    {
                        DeckComponent deckComponent = Finder.FindOrThrow <Decks>().get_All()[save.get_SavedDeck().A];
                        if (!scene.get_Validator().DeckMeetsMinimumCount())
                        {
                            DataComposition dataComposition = global::h.o.Create(global::L.LT(Constants.FN()), global::L.LT(Constants.Fn(), new object[]
                            {
                                scene.get_Validator().DeckCountMinimum()
                            }), false, new string[]
                            {
                                Constants.FO()
                            });
                            dataComposition.Add <global::e.b>(new global::e.b(Constants.Fo()));
                            ShowDialog command = new ShowDialog(this.dialogPrefab, dataComposition);
                            yield return(executor.Execute(command));
                        }
                        this.Success = true;
                        this.deckSave.set_UnsavedChanges(false);
                        Archetypes archetypes = Finder.FindOrThrow <Archetypes>();
                        Pile       pile;
                        if (deckComponent != null && deckComponent.get_Piles().TryGetValue(Constants.K(), out pile))
                        {
                            string text = "";
                            foreach (KeyValuePair <ArchetypeID, int> keyValuePair2 in pile)
                            {
                                text = string.Concat(new object[]
                                {
                                    text,
                                    archetypes.get_All()[keyValuePair2.Key].GetOne <NameData>().get_Name(),
                                    " ",
                                    keyValuePair2.Value,
                                    "\r\n"
                                });
                            }
                            File.WriteAllText(Path.Combine("decks", deckComponent.get_Name() + ".txt"), text);
                        }
                        deckComponent = null;
                        pile          = null;
                        deckComponent = null;
                        pile          = null;
                    }
                    else
                    {
                        DataComposition dataComposition2 = global::h.o.Create(global::L.LT(Constants.FP()), global::L.LT(Constants.Fp()), false, new string[]
                        {
                            global::L.LT(Constants.FO())
                        });
                        dataComposition2.Add <global::e.b>(new global::e.b(Constants.Fo()));
                        ShowDialog command2 = new ShowDialog(this.dialogPrefab, dataComposition2);
                        yield return(executor.Execute(command2));

                        yield return(executor.Execute(new ChangeScene(sceneProvider.get_SceneToExitTo())));
                    }
                    save = null;
                }
            }
            else
            {
                this.Success = false;
                if (failure != null)
                {
                    yield return(executor.Execute(new FailFeedbackCommand(failure)));
                }
            }
            yield break;
            yield break;
        }