コード例 #1
0
 private void deleteDeckToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (DecksListCtrl.SelectedItem != null)
     {
         var result = MessageBox.Show(
             string.Format("Delete deck '{0}' history?", DecksListCtrl.SelectedItem.MyDeckName),
             "Delete Deck",
             MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             if (DecksListCtrl.SelectedItem.IsExpedition() || DecksListCtrl.SelectedItem.MyDeckName == GameRecord.DefaultConstructedDeckName)
             {
                 var deckSignature = DecksListCtrl.SelectedItem.GetDeckSignature();
                 DecksListCtrl.RemoveFromDeckList(DecksListCtrl.SelectedItem);
                 GameHistory.DeleteGamesAndFilesBySignature(deckSignature);
             }
             else
             {
                 var deckName = DecksListCtrl.SelectedItem.MyDeckName;
                 DecksListCtrl.RemoveFromDeckList(DecksListCtrl.SelectedItem);
                 GameHistory.DeleteGamesAndFilesByName(deckName);
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Receives notification that game state has ended
        /// </summary>
        /// <param name="gameNumber"></param>
        /// <param name="gameRecord"></param>
        public void OnGameEnded(int gameNumber, GameRecord gameRecord)
        {
            // Game ended. Grab game result
            Log.WriteLine("Game no. {0} Result: {1}", gameNumber, gameRecord.Result);

            if (string.IsNullOrEmpty(Constants.PlayBackDeckPath) && gameRecord.OpponentDeck.Count > 0)
            {
                var gameLog = CurrentPlayState.StopGameLog();
                if (gameRecord.IsExpedition())
                {
                    gameRecord.NumWins   = CurrentExpedition.NumberOfWins + (gameRecord.Result == "Win" ? 1 : 0);
                    gameRecord.NumLosses = CurrentExpedition.NumberOfLosses + (gameRecord.Result != "Win" ? 1 : 0);
                }
                GameHistory.AddGameRecord(gameRecord, true, gameLog);
                Utilities.CallActionSafelyAndWait(DecksListCtrl, new Action(() =>
                {
                    DecksListCtrl.AddToDeckList(gameRecord, true);
                }));
            }

            OnPlayerDeckSet(new List <CardWithCount>(), "");
        }
コード例 #3
0
        /// <summary>
        /// Runs after all sets are downloaded and processed.
        /// Initializes the StaticDeck windows and deck tracking objects.
        /// </summary>
        public async void OnAllSetsDownloaded()
        {
            await Task.Run(() => CardLibrary.LoadAllCards(MyProgressDisplay));

            await Task.Run(() => GameHistory.LoadAllGames(MyProgressDisplay));

            DeckControl.DeckScale deckScale = DeckControl.DeckScale.Medium;
            if (Properties.Settings.Default.DeckDrawSize == 0)
            {
                deckScale = DeckControl.DeckScale.Small;
            }
            if (Properties.Settings.Default.DeckDrawSize == 2)
            {
                deckScale = DeckControl.DeckScale.Large;
            }

            double deckOpacity = Properties.Settings.Default.DeckTransparency / 100.0;

            PlayerActiveDeckWindow = CreateDeckWindow("No Active Deck", deckScale, deckOpacity,
                                                      Properties.Settings.Default.ShowPlayerDeck,
                                                      Properties.Settings.Default.PlayerDeckLocation.X,
                                                      Properties.Settings.Default.PlayerDeckLocation.Y);
            PlayerDrawnCardsWindow = CreateDeckWindow("Drawn Cards", deckScale, deckOpacity,
                                                      Properties.Settings.Default.ShowPlayerDrawnCards,
                                                      Properties.Settings.Default.PlayerDrawnCardsLocation.X,
                                                      Properties.Settings.Default.PlayerDrawnCardsLocation.Y);
            PlayerGraveyardWindow = CreateDeckWindow("Graveyard", deckScale, deckOpacity,
                                                     Properties.Settings.Default.ShowPlayerGraveyard,
                                                     Properties.Settings.Default.PlayerPlayedCardsLocation.X,
                                                     Properties.Settings.Default.PlayerPlayedCardsLocation.Y);
            OpponentGraveyardWindow = CreateDeckWindow("Opponent Graveyard", deckScale, deckOpacity,
                                                       Properties.Settings.Default.ShowOpponentGraveyard,
                                                       Properties.Settings.Default.OpponentPlayedCardsLocation.X,
                                                       Properties.Settings.Default.OpponentPlayedCardsLocation.Y);

            PlayerActiveDeckWindow.HideZeroCountCards = Properties.Settings.Default.HideZeroCountInDeck;

            ActiveLogWindow = new LogWindow();
            ActiveLogWindow.CreateControl();
            if (Properties.Settings.Default.ActiveLogWindowBounds.Width > 0 &&
                Properties.Settings.Default.ActiveLogWindowBounds.Left > 0)
            {
                ActiveLogWindow.StartPosition = FormStartPosition.Manual;
                ActiveLogWindow.SetBounds(
                    Properties.Settings.Default.ActiveLogWindowBounds.X,
                    Properties.Settings.Default.ActiveLogWindowBounds.Y,
                    Properties.Settings.Default.ActiveLogWindowBounds.Width,
                    Properties.Settings.Default.ActiveLogWindowBounds.Height,
                    BoundsSpecified.All);
            }

            {
                // Show and hide active log window to make sure it's loaded ahead of time
                ActiveLogWindow.Show();
                ActiveLogWindow.Hide();
            }
            Log.SetLogWindow(ActiveLogWindow);

            // Special debigging window is shown if D key is held during load
            if (!string.IsNullOrEmpty(Constants.PlayBackDeckPath) || Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                OverlayWindow = new GameBoardWatchWindow();
                OverlayWindow.Show();
            }

            CurrentPlayState = new CardsInPlayWorker(this);
            if (string.IsNullOrEmpty(Constants.PlayBackDeckPath))
            {
                CurrentExpedition = new Expedition(this);
            }

            // Hide the progress display and make all the other UI elements visible
            MyProgressDisplay.Visible         = false;
            DecksListCtrl.Visible             = true;
            HighlightedGameLogControl.Visible = true;
            TheMenuBar.Visible = true;

            // Load all games. We do this in reverse as AddDeckToList expects them
            // in chronological order
            for (int i = GameHistory.Games.Count - 1; i >= 0; i--)
            {
                DecksListCtrl.AddToDeckList(GameHistory.Games[i]);
            }

            Utilities.CallActionSafelyAndWait(DecksListCtrl, new Action(() => { DecksListCtrl.SwitchDeckView(false); }));

            CurrentPlayState.Start(string.IsNullOrEmpty(Constants.PlayBackDeckPath)
                ? null : Constants.GetLocalGamesPath() + "\\" + Constants.PlayBackDeckPath);
        }