Esempio n. 1
0
  public Hand deal(Game game) {

    // always shuffle before dealing!
    shuffle();

    // create a new hand
    Hand hand = game.newHand();

    // deal five cards to each player
    for (Team.Player player : game.getPlayers()) {
      hand.setCards(player, useNextCards(5));
    }

    // set the up card
    hand.setUpCard(useNextCard());

    return hand;
  }
Esempio n. 2
0
  private void findCreatableLinks() {
    sortHandBySuit();
    for (int i = 0; i < hand.size() - 3; i++) {
      Hand co = new Hand(hand.subList(i, i + 3));
      if (co.isTriplet()) canBeTriplets.addAll(co.getCards());
      if (co.isNaturalSequence()) canBeNaturalSequences.addAll(co.getCards());
      if (co.isSequence()) canBeSequences.addAll(co.getCards());
    }

    for (int i = 0; i < hand.size() - 5; i++) {
      Hand co = new Hand(hand.subList(i, i + 5));
      if (co.canBePent()) canBePents.addAll(co.getCards());
    }

    for (int i = 0; i < hand.size() - 4; i++) {
      Hand co = new Hand(hand.subList(i, i + 4));
      if (co.canBeQuad()) canBeQuads.addAll(co.getCards());
    }
  }
Esempio n. 3
0
  private void findExistingLinks() {
    sortHandByRank();
    for (int i = 0; i < hand.size() - 3; i++) {
      Hand co = new Hand(hand.subList(i, i + 3));
      if (co.canBeTriplet()) avTriplets.addAll(co.getCards());
      if (co.canBeNaturalSequence()) avNaturalSequences.addAll(co.getCards());
      if (co.canBeSequence()) avSequences.addAll(co.getCards());
    }

    for (int i = 0; i < hand.size() - 5; i++) {
      Hand co = new Hand(hand.subList(i, i + 5));
      if (co.isPent()) avPents.addAll(co.getCards());
    }

    for (int i = 0; i < hand.size() - 4; i++) {
      Hand co = new Hand(hand.subList(i, i + 4));
      if (co.isQuad()) avQuad.addAll(co.getCards());
    }
  }