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"); }
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()); } }
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; }
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(); }
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."); } }
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; } }
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; }
public void Add(Deck deck) { foreach(Card card in deck.Cards) Cards.Add(card); }
private void ResetGame() { GameInProgress = false; OnPropertyChanged("GameInProgress"); OnPropertyChanged("GameNotStarted"); books = new Dictionary<Values, Player>(); stock = new Deck(); Hand.Clear(); }
public void TakeCards(Deck deck) { cards.Add(deck); }