-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#15 Kombinációban levő kártyák kigyűjtése listába
Az 'orderedCardList' változó visszaadja a legjobb 5 lapot rendezett formában;
- Loading branch information
Showing
20 changed files
with
393 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.git_egylet.tools; | ||
|
||
import com.wcs.poker.gamestate.Card; | ||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author imate | ||
*/ | ||
public class RankComparator implements Comparator<Card> { | ||
|
||
private static final List<String> ranks = Arrays.asList("2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"); | ||
|
||
@Override | ||
public int compare(Card c1, Card c2) { | ||
return ranks.indexOf(c2.getRank()) - ranks.indexOf(c1.getRank()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package org.leanpoker.player.checkCards; | ||
|
||
import com.wcs.poker.gamestate.Card; | ||
import org.git_egylet.tools.Tools; | ||
import static org.leanpoker.player.checkCards.Check.*; | ||
|
||
/** | ||
|
@@ -13,18 +14,42 @@ public class CheckDrill extends Check { | |
protected void check() { | ||
for (String rank : ranks) { | ||
if (countRank(rank) == 3) { | ||
hand = Hand.DRILL; | ||
handRank = HandRank.DRILL; | ||
highRank1 = rank; | ||
} | ||
} | ||
|
||
//myCardsOfHand kiszámítása: | ||
if (hand != null) { | ||
for (Card card : cards) { | ||
if (card.isInMyHand() && card.getRank().equals(highRank1)) { | ||
myCardsOfHand++; | ||
} | ||
if (handRank != null) { | ||
calcMyCardsOfHand(); | ||
makeOrderedCardList(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void calcMyCardsOfHand() { | ||
for (Card card : cards) { | ||
if (card.isInMyHand() && card.getRank().equals(highRank1)) { | ||
myCardsOfHand++; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void makeOrderedCardList() { | ||
for (Card card : cards) { | ||
if (card.isEqualRank(highRank1)) { | ||
orderedCardList.add(card); | ||
//cards.remove(card); ez sajnos nem jött be (ConcurrentModificationException) | ||
This comment has been minimized.
Sorry, something went wrong.
thomastrinn
Contributor
|
||
} | ||
} | ||
cards = Tools.orderCards(cards); | ||
int i = 0; | ||
Card actCard; | ||
while (orderedCardList.size() < 5) { | ||
actCard = cards.get(i); | ||
if (!actCard.isEqualRank(highRank1)) { | ||
orderedCardList.add(actCard); | ||
} | ||
i++; | ||
This comment has been minimized.
Sorry, something went wrong.
thomastrinn
Contributor
|
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package org.leanpoker.player.checkCards; | ||
|
||
import com.wcs.poker.gamestate.Card; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import static org.leanpoker.player.checkCards.Check.*; | ||
|
||
/** | ||
|
@@ -24,19 +26,40 @@ protected void check() { | |
for (String rank : ranks) { | ||
if (countRank(rank) == 2) { | ||
highRank2 = rank; | ||
hand = Hand.FULL; | ||
handRank = HandRank.FULL; | ||
} | ||
} | ||
} | ||
|
||
//myCardsOfHand kiszámítása: | ||
if (hand != null) { | ||
for (Card card : cards) { | ||
if (card.isInMyHand() && (card.getRank().equals(highRank1) || card.getRank().equals(highRank2))) { | ||
myCardsOfHand++; | ||
} | ||
if (handRank != null) { | ||
calcMyCardsOfHand(); | ||
makeOrderedCardList(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void calcMyCardsOfHand() { | ||
for (Card card : cards) { | ||
if (card.isInMyHand() && (card.getRank().equals(highRank1) || card.getRank().equals(highRank2))) { | ||
myCardsOfHand++; | ||
} | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
thomastrinn
Contributor
|
||
} | ||
|
||
@Override | ||
protected void makeOrderedCardList() { | ||
List<Card> drillCards = new ArrayList<>(); | ||
List<Card> pairCards = new ArrayList<>(); | ||
for (Card card : cards) { | ||
if (card.isEqualRank(highRank1)) { | ||
drillCards.add(card); | ||
} | ||
if (card.isEqualRank(highRank2)) { | ||
pairCards.add(card); | ||
} | ||
} | ||
orderedCardList.addAll(drillCards); | ||
orderedCardList.addAll(pairCards); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package org.leanpoker.player.checkCards; | ||
|
||
import com.wcs.poker.gamestate.Card; | ||
import static org.leanpoker.player.checkCards.Check.*; | ||
import org.git_egylet.tools.Tools; | ||
|
||
/** | ||
* | ||
|
@@ -11,13 +10,26 @@ public class CheckHighCard extends Check { | |
|
||
@Override | ||
protected void check() { | ||
for (String rank : ranks) { | ||
for (Card card : cards) { | ||
if (card.isInMyHand() && card.isEqualRank(rank)) { | ||
highRank1 = rank; | ||
hand = Hand.HIGH_CARD; | ||
myCardsOfHand = 1; | ||
} | ||
handRank = HandRank.HIGH_CARD; | ||
makeOrderedCardList(); | ||
highRank1 = orderedCardList.get(0).getRank(); | ||
highRank2 = orderedCardList.get(1).getRank(); | ||
} | ||
|
||
@Override | ||
protected void calcMyCardsOfHand() { | ||
} | ||
|
||
@Override | ||
protected void makeOrderedCardList() { | ||
cards = Tools.orderCards(cards); | ||
int i = 0; | ||
if (cards.size() == 2) { | ||
orderedCardList.addAll(cards); | ||
} else { | ||
while (orderedCardList.size() < 5) { | ||
orderedCardList.add(cards.get(i)); | ||
i++; | ||
This comment has been minimized.
Sorry, something went wrong.
thomastrinn
Contributor
|
||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Igen... ezek itt nagyon mágikus inicializálások... :) Látom leszármazottban lesznek felhasználva, jó kis myCardsOfHand++-ok beficcennek.
Valahogy picit idegenkedek egy ilyentől.