コード例 #1
0
ファイル: Player.cs プロジェクト: djvorr/SSE
        public Card pickCard(Board b)
        {
            //b.Show();

            while(!b.picked)
            {
                System.Threading.Thread.Sleep(500);
            }

            return b.getPickedCard();
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: djvorr/SSE
        public void gameLoop()
        {
            int i = 0;
            while(!table.noMoreTurns())
            {
                Board b = new Board();

                Seat s = table.takeTurn();
                Player p;
                CPU cpu;
                if (s.GetType() == typeof(Player))
                {
                    b.drawHand(player.hand);
                    b.enableCards();
                    b.ShowDialog();
                    b.disenableCards();

                    p = (Player)s;
                    Card c = p.pickCard(b);
                    //MessageBox.Show(c.getPlain());
                    table.addToField(c);
                    b.drawBoard(table.getField());
                    //b.ShowDialog();
                    Hand h = p.hand;
                    h.removeCard(c.getSuit(), c.getFace());
                    p.pickAccepted(c);
                    table.turnOrder[table.getLast()].hand = h;

                }
                else
                {
                    cpu = (CPU)s;
                    Card c = cpu.pickCard(table.getHighest());
                    //MessageBox.Show(c.getPlain());
                    table.addToField(c);
                    b.drawBoard(table.getField());
                    //b.ShowDialog();
                    //System.Threading.Thread.Sleep(5000);
                    //b.Close();
                    //table.getLast().pickAccepted(c);
                    Hand h = cpu.hand;
                    h.removeCard(c.getSuit(), c.getFace());
                    cpu.pickAccepted(c);
                    table.turnOrder[table.getLast()].hand = h;
                }

                i++;

                if(i % 4 == 0)
                {
                    string str = "";
                    foreach(Card c in table.getField())
                    {
                        str = str + c.getPlain() + " ";
                    }

                    b.clearButtons();
                    b.disenableCards();
                    b.ShowDialog();

                    table.setField(new List<Card>());

                    //MessageBox.Show(str);
                }
            }
        }
コード例 #3
0
ファイル: UnitTest2.cs プロジェクト: djvorr/SSE
        public void TestDrawHand()
        {
            List<Card> cards = new List<Card>();
            Card c = new Card('H', "10");
            cards.Add(c);
            Card c1 = new Card('C', "K");
            cards.Add(c1);
            Card c2 = new Card('D', "K");
            cards.Add(c2);
            Card c3 = new Card('S', "9");
            cards.Add(c3);

            Hand hand = new Hand(cards);
            Board board = new Board();
            board.clearButtons();
            board.drawHand(hand);

            List<Button> buttons = board.getHand();

            Assert.IsTrue(buttons[0].Text.Length > 0, "Button 0 card not loaded.");
            Assert.IsTrue(buttons[1].Text.Length > 0, "Button 1 card not loaded.");
            Assert.IsTrue(buttons[2].Text.Length > 0, "Button 2 card not loaded.");
            Assert.IsTrue(buttons[3].Text.Length > 0, "Button 3 card not loaded.");
            Assert.IsTrue(buttons[4].Text.Length == 0, "Button 4 card loaded.");
            Assert.IsTrue(buttons[5].Text.Length == 0, "Button 5 card loaded.");

            cards.Add(c3);
            cards.Add(c3);

            hand = new Hand(cards);
            board.drawHand(hand);
            buttons = board.getHand();

            Assert.IsTrue(buttons[5].Text.Length > 0, "Button 5 card not loaded.");

            cards.Clear();

            hand = new Hand(cards);
            board.drawHand(hand);
            buttons = board.getHand();

            Assert.IsTrue(buttons[0].Text.Length == 0, "Button 0 wrongly loaded.");
            Assert.IsTrue(buttons[5].Text.Length == 0, "Button 5 wrongly loaded.");
        }