Package game

Examples of game.Card


      // Populate a list of Cards with data from the file
      Card.Collection = new LinkedList<Card>();
      JSONArray objects = imgMap.getJSONArray("Objects");
      for (int i = 0; i < objects.length(); ++i) {
        JSONObject obj = objects.getJSONObject(i);
        Card.Collection.add(new Card(obj));
      }
     
      // Load other utility clips
      Card.Clips = new HashMap<String, OggClip>();
      Card.Clips.put("Start", Card.makeOGG("ogg/start.ogg"));
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

   */
  public void testCheckingForMatch()
  {
    assertFalse(state.checkForMatch(p1, p2));
    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);
    p2.getHand().addCards(list);
    assertTrue(state.checkForMatch(p1, p2));
  }
View Full Code Here

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

TOP

Related Classes of 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.