示例#1
0
文件: Player.cs 项目: ppaier/HFCSharp
 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
文件: Player.cs 项目: ppaier/HFCSharp
 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
文件: Player.cs 项目: ppaier/HFCSharp
        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
文件: Game.cs 项目: ppaier/HFCSharp
        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
文件: Player.cs 项目: ppaier/HFCSharp
        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
文件: Player.cs 项目: ppaier/HFCSharp
        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
文件: Deck.cs 项目: ppaier/HFCSharp
 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
文件: Deck.cs 项目: ppaier/HFCSharp
 public void Add(Deck deck)
 {
     foreach(Card card in deck.Cards)
         Cards.Add(card);
 }
示例#9
0
文件: Game.cs 项目: ppaier/HFCSharp
 private void ResetGame()
 {
     GameInProgress = false;
     OnPropertyChanged("GameInProgress");
     OnPropertyChanged("GameNotStarted");
     books = new Dictionary<Values, Player>();
     stock = new Deck();
     Hand.Clear();
 }
示例#10
0
文件: Player.cs 项目: ppaier/HFCSharp
 public void TakeCards(Deck deck)
 {
     cards.Add(deck);
 }