Exemplo n.º 1
0
 public Player(String name, Random random, Game game)
 {
     Name = name;
     this.random = random;
     this.game = game;
     cards = new Deck(new Card[] { });
     game.AddProgress(name + " has just joined the game");
 }
Exemplo n.º 2
0
 public void AskForACard(List<Player> players, int myIndex, Deck stock)
 {
     if (stock.Count > 0)
     {
         if (cards.Count == 0)
             cards.Add(stock.Deal());
         AskForACard(players, myIndex, stock, GetRandomValue());
     }
 }
Exemplo n.º 3
0
        public void AskForACard(List<Player> players, int myIndex, Deck stock, Values value)
        {
            game.AddProgress(Name + " asks if anyone has a " + value.ToString());
            int numberOfFoundCards = 0;
            for(int i=0; i<players.Count; ++i)
            {
                if(i != myIndex)
                {
                    Deck foundCards = players[i].DoYouHaveAny(value);
                    numberOfFoundCards += foundCards.Count;
                    TakeCards(foundCards);
                }
            }

            if (numberOfFoundCards == 0 && stock.Count > 0)
            {
                TakeCard(stock.Deal());
                game.AddProgress(Name + " had to draw from the stock.");
            }
        }
Exemplo n.º 4
0
 private void ResetGame()
 {
     GameInProgress = false;
     OnPropertyChanged("GameInProgress");
     OnPropertyChanged("GameNotStarted");
     books = new Dictionary<Values, Player>();
     stock = new Deck();
     Hand.Clear();
 }
Exemplo n.º 5
0
 public void TakeCards(Deck deck)
 {
     cards.Add(deck);
 }
Exemplo n.º 6
0
 public void Add(Deck deck)
 {
     foreach(Card card in deck.Cards)
         Cards.Add(card);
 }
Exemplo n.º 7
0
 public Deck PullOutValues(Values value)
 {
     Deck deckToReturn = new Deck(new Card[] { });
     for(int i = Cards.Count-1; i>= 0; --i)
     {
         if (Cards[i].Value == value)
             deckToReturn.Add(Deal(i));
     }
     return deckToReturn;
 }