Example #1
0
 public void PerformUIPlayerAction(ActionType actionType, CardViewModel card, PileViewModel pile)
 {
     this.uiRequestAction = new PlayerAction();
     this.uiRequestAction.ActionType = actionType;
     this.uiRequestAction.Card = card != null ? card.CardModel : null;
     this.uiRequestAction.Pile = pile != null ? pile.PileModel : null;
     this.state = ClientState.WaitingForOpponent;
     this.uiPlayerActionWaitHandle.Set();
 }
Example #2
0
 private void ShowPileDetails(PileViewModel pile)
 {
     if (pile.TopCard != null)
     {
         this.CardDetailsPopup.DataContext = pile.TopCard.CardInfo;
         this.CardDetailsPopup.Visibility = Visibility.Visible;
     }
 }
Example #3
0
        public void OnInitialized()
        {
            ViewModelDispatcher.BeginInvoke(new Action(delegate()
            {
                foreach (Player player in this.gameModel.Players)
                {
                    this.players.Add(new PlayerViewModel(player, this));
                }

                foreach (Pile pile in this.gameModel.SupplyPiles)
                {
                    PileViewModel pvm = new PileViewModel(pile, this);
                    this.piles.Add(pvm);
                    if (pile.Card is Copper || pile.Card is Silver || pile.Card is Gold || pile.Card is Potion || pile.Card is Platinum)
                    {
                        this.basicTreasurePiles.Add(pvm);
                    }
                    else if (pile.Card is Curse || pile.Card is Estate || pile.Card is Duchy || pile.Card is Province || pile.Card is Colony)
                    {
                        this.basicVictoryPiles.Add(pvm);
                    }
                    else
                    {
                        this.kingdomPiles.Add(pvm);
                    }
                }

                foreach (Pile pile in this.gameModel.ExtraPiles)
                {
                    PileViewModel pvm = new PileViewModel(pile, this);
                    this.piles.Add(pvm);
                    this.kingdomPiles.Add(pvm);
                }

                foreach (PileViewModel pile in this.kingdomPiles)
                {
                    if (this.kingdomPiles1.Count < 10)
                    {
                        this.kingdomPiles1.Add(pile);
                    }
                    else
                    {
                        this.kingdomPiles2.Add(pile);
                    }

                    if (this.kingdomPiles1of3.Count < 5)
                    {
                        this.kingdomPiles1of3.Add(pile);
                    }
                    else if(this.kingdomPiles2of3.Count < 5)
                    {
                        this.kingdomPiles2of3.Add(pile);
                    }
                    else
                    {
                        this.kingdomPiles3of3.Add(pile);
                    }
                }
                foreach (CardModel prize in this.gameModel.Prizes)
                {
                    this.prizes.Add(new CardViewModel(prize));
                }
                this.OnPropertyChanged("Players");
                this.OnPropertyChanged("CurrentPlayer");
                this.OnPropertyChanged("Prizes");
                new CollectionSynchronizer(this.gameModel.Trash, this.trash);

                if (this.GameInitialized != null)
                {
                    this.GameInitialized(this, EventArgs.Empty);
                }
            }));
        }