Beispiel #1
0
 private string GetOpponentGroupMethod(DataModel.Game g)
 {
     if (this.gropuByOpponent == "opponentDeckTag")
     {
         return(g.OpponentDeckTag == null ? "<none>" : g.OpponentDeckTag);
     }
     else
     {
         return(ClassAttributesHelper.Classes[g.OpponentClass.Value].ToString());
     }
 }
Beispiel #2
0
 /// <summary>
 /// change deck for game
 /// </summary>
 /// <param name="obj"></param>
 private void MoveGameToDeckExecute(object obj)
 {
     DataModel.Game game = obj as DataModel.Game;
     if (game != null)
     {
         game.Deck             = SelectedDeck;
         game.DeckVersionId    = SelectedVersion.VersionId;
         IsDeckSelectorVisible = false;
     }
     else
     {
         throw new ArgumentException("Must pass game object");
     }
 }
        public void CommandButtonCreateExecute(object parameter)
        {
            GameOutcome?outcome = EnumManager.ParseEnumString <GameOutcome>(parameter as string);

            this.ErrorMessage = null;
            if (tracker.ActiveDeck == null)
            {
                this.ErrorMessage += "Please select active deck" + Environment.NewLine;
            }
            if (!this.Game.OpponentClass.HasValue)
            {
                this.ErrorMessage += "Please select opponent class" + Environment.NewLine;
            }
            this.ErrorMessage = this.ErrorMessage?.Trim();

            if ((tracker.ActiveDeck != null) &&
                (outcome.HasValue) &&
                this.Game.OpponentClass.HasValue)
            {
                UpdateGameData(outcome);

                DataModel.Game addedGame = this.Game;
                tracker.Games.Add(this.Game);

                messanger.Send(
                    new Utils.Messages.EditDeck()
                {
                    Deck = game.Deck
                },
                    Utils.Messages.EditDeck.Context.StatsUpdated);

                trackerFactory.GetFileManager().SaveDatabase();

                this.Game = new DataModel.Game();

                //restore values that are likely the same,  like game type, player rank etc
                this.Game.Type             = addedGame.Type;
                this.Game.PlayerRank       = addedGame.PlayerRank;
                this.Game.PlayerLegendRank = addedGame.PlayerLegendRank;

                this.BeginEdit();

                this.UpdateBindings();

                RaisePropertyChangedEvent(String.Empty);
            }
        }
        public void IEditableObjectImplementation001_CancelEdit()
        {
            Mock <IDeckClassSelectorViewModel> deckClassSelector = new Mock <IDeckClassSelectorViewModel>();

            EditGameViewModel model = new EditGameViewModel();

            DataModel.Game game = new DataModel.Game();

            model.Game = game;

            model.Game.ClearEventInvocations("PropertyChanged");

            PopulateObject(game, StartProp);

            TestContext.WriteLine("Begin Edit");
            model.BeginEdit();

            PopulateObject(game, EditProp);

            TestContext.WriteLine("Cancel Edit");
            model.CancelEdit();

            foreach (PropertyInfo p in game.GetType().GetProperties())
            {
                if (p.CanWrite)
                {
                    if (p.Name == "DeckId")
                    {
                        //deck id is handled different way, depends on Deck
                        DataModel.Deck staringDeck = (DataModel.Deck)StartProp[typeof(DataModel.Deck)];
                        Assert.AreEqual(staringDeck.DeckId, p.GetValue(game), "Failed validation of prop {0} of type {1}", p.Name, p.PropertyType);
                    }
                    else
                    {
                        Assert.AreEqual(StartProp[p.PropertyType], p.GetValue(game), "Failed validation of prop {0} of type {1}", p.Name, p.PropertyType);
                    }
                }
            }
        }
 public void EndEdit()
 {
     savedState = Game;
 }
 public void BeginEdit()
 {
     savedState = Game.Clone() as DataModel.Game;
 }