コード例 #1
0
ファイル: Hand.java プロジェクト: Migals/Lab-2
	public static Hand EvalHand(ArrayList<Card> SeededHand) {

		Deck d = new Deck();
		Hand h = new Hand(d);
		h.CardsInHand = SeededHand;

		return h;
	}
コード例 #2
0
ファイル: Hand.java プロジェクト: apgross1/Lab5
  public static Hand EvalHand(ArrayList<CardDomainModel> SeededHand) {

    Deck d = new Deck();
    Hand h = new Hand(d);
    h.setCardsInHand(SeededHand);

    return h;
  }
コード例 #3
0
ファイル: Hand.java プロジェクト: Migals/Lab-2
		public int compare(Hand h1, Hand h2) {

			int result = 0;

			result = h2.getHandStrength() - h1.getHandStrength();

			if (result != 0) {
				return result;
			}

			result = h2.getHighPairStrength() - h1.getHighPairStrength();
			if (result != 0) {
				return result;
			}

			result = h2.getLowPairStrength() - h1.getLowPairStrength();
			if (result != 0) {
				return result;
			}

			result = h2.getKicker() - h1.getKicker();
			if (result != 0) {
				return result;
			}

			return 0;
		}
コード例 #4
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void Straight() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.JACK, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.QUEEN, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.KING, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.NINE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.Straight.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.KING.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker() == null);
  }
コード例 #5
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void FullHouse_2() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TWO, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.FullHouse.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TWO.getRank());
    assertTrue(h.getLowPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getKicker() == null);
  }
コード例 #6
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void FourOfAKind_2() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.KING, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.FourOfAKind.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 1);
  }
コード例 #7
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void RoyalFlush() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.JACK, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.QUEEN, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.KING, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.ACE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.RoyalFlush.getHandStrength());
  }
コード例 #8
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void FourOfAKind_1() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.NINE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.FourOfAKind.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 1);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());

    //	Check to see if the kicker is a NINE
    assertTrue(c1.getRank().getRank() == eRank.NINE.getRank());
  }
コード例 #9
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void HighCard() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.KING, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.THREE, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.ACE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.HighCard.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.ACE.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 4);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());
    Card c2 = h.getKicker().get(eCardNo.SecondCard.getCardNo());
    Card c3 = h.getKicker().get(eCardNo.ThirdCard.getCardNo());
    Card c4 = h.getKicker().get(eCardNo.FourthCard.getCardNo());

    //	Check value of kicker
    assertTrue(c1.getRank().getRank() == eRank.KING.getRank());

    //	Check value of kicker
    assertTrue(c2.getRank().getRank() == eRank.TEN.getRank());

    //	Check value of kicker
    assertTrue(c3.getRank().getRank() == eRank.THREE.getRank());

    //	Check value of kicker
    assertTrue(c4.getRank().getRank() == eRank.TWO.getRank());
  }
コード例 #10
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void TwoPair() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.ACE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.TwoPair.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getLowPairStrength() == eRank.TWO.getRank());
    assertTrue(h.getKicker().size() == 1);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());

    //	Check to see if the first kicker is a THREE
    assertTrue(c1.getRank().getRank() == eRank.ACE.getRank());
  }
コード例 #11
0
ファイル: Hand_Test.java プロジェクト: phafycz/SpringBorgata
  @Test
  public void ThreeOfAKind_2() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.KING, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.NINE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.ThreeOfAKind.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 2);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());
    Card c2 = h.getKicker().get(eCardNo.SecondCard.getCardNo());

    //	Check to see if the first kicker is a KING
    assertTrue(c1.getRank().getRank() == eRank.KING.getRank());

    //	Check to see if the second kicker is a NINE
    assertTrue(c2.getRank().getRank() == eRank.NINE.getRank());
  }
コード例 #12
0
ファイル: Hand.java プロジェクト: apgross1/Lab5
        public int compare(Hand h1, Hand h2) {

          int result = 0;

          result = h2.getHandStrength() - h1.getHandStrength();

          if (result != 0) {
            return result;
          }

          result = h2.getHiHand() - h1.getHiHand();
          if (result != 0) {
            return result;
          }

          result = h2.getLoHand() - h1.getLoHand();
          if (result != 0) {
            return result;
          }

          if (h2.getKicker().get(eCardNo.FirstCard.getCardNo()) != null) {
            if (h1.getKicker().get(eCardNo.FirstCard.getCardNo()) != null) {
              result =
                  h2.getKicker().get(eCardNo.FirstCard.getCardNo()).getRank().getRank()
                      - h1.getKicker().get(eCardNo.FirstCard.getCardNo()).getRank().getRank();
            }
            if (result != 0) {
              return result;
            }
          }

          if (h2.getKicker().get(eCardNo.SecondCard.getCardNo()) != null) {
            if (h1.getKicker().get(eCardNo.SecondCard.getCardNo()) != null) {
              result =
                  h2.getKicker().get(eCardNo.SecondCard.getCardNo()).getRank().getRank()
                      - h1.getKicker().get(eCardNo.SecondCard.getCardNo()).getRank().getRank();
            }
            if (result != 0) {
              return result;
            }
          }
          if (h2.getKicker().get(eCardNo.ThirdCard.getCardNo()) != null) {
            if (h1.getKicker().get(eCardNo.ThirdCard.getCardNo()) != null) {
              result =
                  h2.getKicker().get(eCardNo.ThirdCard.getCardNo()).getRank().getRank()
                      - h1.getKicker().get(eCardNo.ThirdCard.getCardNo()).getRank().getRank();
            }
            if (result != 0) {
              return result;
            }
          }

          if (h2.getKicker().get(eCardNo.FourthCard.getCardNo()) != null) {
            if (h1.getKicker().get(eCardNo.FourthCard.getCardNo()) != null) {
              result =
                  h2.getKicker().get(eCardNo.FourthCard.getCardNo()).getRank().getRank()
                      - h1.getKicker().get(eCardNo.FourthCard.getCardNo()).getRank().getRank();
            }
            if (result != 0) {
              return result;
            }
          }
          return 0;
        }