Пример #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");
 }
Пример #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());
     }
 }
Пример #3
0
        public Player(String name, Random random, TextBox textBoxOnForm)
        {
            Name = name;
            this.random = random;
            this.textBoxOnForm = textBoxOnForm;

            cards = new Deck(new Card[] { });
            textBoxOnForm.Text += name + " has just joined the game" + Environment.NewLine;
        }
Пример #4
0
        public Game(string playerName, IEnumerable<string> opponentNames, TextBox tbProgress)
        {
            this.tbProgress = tbProgress;
            Random random = new Random();
            players = new List<Player>();
            players.Add(new Player(playerName, random, tbProgress));
            round = 1;
            foreach (string p in opponentNames)
                players.Add(new Player(p, random, tbProgress));

            books = new Dictionary<Values, Player>();
            stock = new Deck();
            Deal();
            players[0].SortHand();
        }
Пример #5
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.");
            }
        }
Пример #6
0
        public void AskForACard(List<Player> players, int myIndex, Deck stock, Values value)
        {
            textBoxOnForm.Text += Name + " asks if anyone has a " + value.ToString() + Environment.NewLine;
            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());
                textBoxOnForm.Text += Name + " had to draw from the stock." + Environment.NewLine;
            }
        }
Пример #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;
 }
Пример #8
0
 public void Add(Deck deck)
 {
     foreach(Card card in deck.Cards)
         Cards.Add(card);
 }
Пример #9
0
 private void ResetGame()
 {
     GameInProgress = false;
     OnPropertyChanged("GameInProgress");
     OnPropertyChanged("GameNotStarted");
     books = new Dictionary<Values, Player>();
     stock = new Deck();
     Hand.Clear();
 }
Пример #10
0
 public void TakeCards(Deck deck)
 {
     cards.Add(deck);
 }