Package Project1.Game

Examples of Project1.Game.Card


    else {
      R6.setSelected(true);
    }
  }
  private void updateArgs() {
    GameSize newSize;
    if (R8.isSelected()) {
      newSize = GameSize.C8;
    }
    else if (R7.isSelected()) {
      newSize = GameSize.C7;
View Full Code Here


    // Show the face
    this.setIcon(Child.getImage());
    current = Child.getImage();
   
    // Determine the type of match
    Matching MatchType;
    if (Game.get().FlippedCard == null) {
      MatchType = Matching.Reveal;
    }
    else if (Game.get().FlippedCard != this) {
      if (Game.get().FlippedCard.getCard() == this.getCard()) {
View Full Code Here

        }
      }
    }
    if (cTotal - cHerobrine == 0 ) {
      // Award the winner the game and exit
      Player victor =
        Player1.getScore() > Player2.getScore()
        ? Player1
        : Player2;
     
      victor.giveWin();
      GamePanel.get().updateLabels();
     
      // Play victory sound (eat for a second then burp) :)
      try {
        Card.Clips.get("Eat").loop();
        TimeUnit.SECONDS.sleep(1);
        Card.Clips.get("Eat").stop();
      } catch (InterruptedException ie) {
        Card.Clips.get("Eat").stop();
      }
      Card.Clips.get("Burp").play();
     
      // Show Congratulatory Message
      JOptionPane.showMessageDialog(
        MainFrame.get(),
        "Congratulations " + victor.getName() + "!",
        "You Won",
        JOptionPane.INFORMATION_MESSAGE
      );
     
      // Set ActiveGame to null
View Full Code Here

     * Makes sure the correct card is chosen normally
     */
    @Test
    public void testCheating()
    {
        Card cd = new Card(7, 's');
        PlayerController.previousCard = cd;
       
        Cheating cheat = new Cheating();
        Hand hand = new Hand(10);
        //System.out.println(hand);
        ArrayList<Card> cards = new ArrayList<Card>();
        cards.add(new Card(6, 'c'));
        cards.add(new Card(5, 'c'));
        cards.add(new Card(10, 'c'));
        cards.add(new Card(8, 'c'));
        cards.add(new Card(1, 'c'));
        cards.add(new Card(3, 'c'));
        cards.add(new Card(7, 'c'));
        hand.addCards(cards);
       
        assertEquals(cards.get(3), cheat.getNextCard(hand));
    }
View Full Code Here

       
        Cheating cheat = new Cheating();
        Hand hand = new Hand(10);
        //System.out.println(hand);
        ArrayList<Card> cards = new ArrayList<Card>();
        cards.add(new Card(6, 'c'));
        cards.add(new Card(5, 'c'));
        cards.add(new Card(10, 'c'));
        cards.add(new Card(8, 'c'));
        cards.add(new Card(1, 'c'));
        cards.add(new Card(3, 'c'));
        cards.add(new Card(2, 'c'));
        hand.addCards(cards);
       
        assertEquals(cards.get(0), cheat.getNextCard(hand));
    }
View Full Code Here

     * Makes sure the correct card is chosen if the last card can't be beaten
     */
    @Test
    public void testCheatingEqualValue()
    {
        Card cd = new Card(10, 's');
        PlayerController.previousCard = cd;
       
        Cheating cheat = new Cheating();
        Hand hand = new Hand(10);
        //System.out.println(hand);
        ArrayList<Card> cards = new ArrayList<Card>();
        cards.add(new Card(6, 'c'));
        cards.add(new Card(5, 'c'));
        cards.add(new Card(10, 'c'));
        cards.add(new Card(8, 'c'));
        cards.add(new Card(1, 'c'));
        cards.add(new Card(3, 'c'));
        cards.add(new Card(2, 'c'));
        hand.addCards(cards);
       
        assertEquals(cards.get(2), cheat.getNextCard(hand));
    }
View Full Code Here

     * Makes sure the correct card is chosen when the opponent will win
     */
    @Test
    public void testCheatingOppnentWins()
    {
        Card cd = new Card(12, 's');
        PlayerController.previousCard = cd;
       
        Cheating cheat = new Cheating();
        Hand hand = new Hand(10);
        //System.out.println(hand);
        ArrayList<Card> cards = new ArrayList<Card>();
        cards.add(new Card(6, 'c'));
        cards.add(new Card(5, 'c'));
        cards.add(new Card(10, 'c'));
        cards.add(new Card(8, 'c'));
        cards.add(new Card(1, 'c'));
        cards.add(new Card(3, 'c'));
        cards.add(new Card(2, 'c'));
        hand.addCards(cards);
       
        assertEquals(cards.get(0), cheat.getNextCard(hand));
    }
View Full Code Here

    assertEquals(8, goFish.getPlayer().getHand().getSize());
    assertEquals(8, goFish.getComputer().getHand().getSize());
   
    //Force a card into the computers hand for the player to ask for
    //For testing puposes I will use a card not possible to get from the deck
    goFish.getComputer().getHand().addCard(new Card(15, 'c'));
    goFish.askForCard(15);
    //Player gains a card, computer loses one
    assertEquals(9, goFish.getPlayer().getHand().getSize());
    assertEquals(8, goFish.getComputer().getHand().getSize());
    assertTrue(goFish.getPlayer().getHand().contains(new Card(15, 'c')));
    assertFalse(goFish.getComputer().getHand().contains(new Card(15, 'c')));
   
    //Force a card into the players hand for the computer to ask for
    //For testing puposes I will use a card not possible to get from the deck
    goFish.getPlayer().getHand().addCard(new Card(16, 'c'));
    goFish.askForCard(16);
    //Computer gains a card, player loses one
    assertEquals(9, goFish.getPlayer().getHand().getSize());
    assertEquals(9, goFish.getComputer().getHand().getSize());
    assertFalse(goFish.getPlayer().getHand().contains(new Card(16, 'c')));
    assertTrue(goFish.getComputer().getHand().contains(new Card(16, 'c')));
  }
View Full Code Here

   * For testing cards that cannot be obtained from the deck will be used
   */
  public void testCheckForMatch()
  {
    ArrayList<Card> list = new ArrayList<Card>();
    List<Card> l = Arrays.asList(new Card[] {new Card(14, 'c'), new Card(14, 'd'), new Card(14, 'h'), new Card(14, 's')});
    list.addAll(l);
    //Test player
    goFish.getPlayer().getHand().addCards(list);
    assertTrue(goFish.checkForMatch());
   
View Full Code Here

  /**
   * Test to make sure a card can be asked for
   */
  public void testAskForCard()
  {
    p1.getHand().addCard(new Card(15, 'h'));
    state.askForCard(new GoFish(), p1, p2, 15);
    assertTrue(p2.getHand().contains(new Card(15, 'h')));
    assertFalse(p1.getHand().contains(new Card(15, 'h')));
  }
View Full Code Here

TOP

Related Classes of Project1.Game.Card

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.