Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

167 game over without matadors is displayed wrong #168

Merged
merged 4 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jskat-base/src/main/java/org/jskat/control/SkatGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ public void dealCards() {
// Skat game has no cards, yet
deck = new CardDeck();

log.debug("shuffling...");
deck.shuffle();

log.debug(deck.toString());
}

log.info("shuffling...");
deck.shuffle();

doSleep(maxSleep);

log.debug("dealing...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ static SkatGameData parseGameSummary(final String gameSummary) {
final SkatGameData result = new SkatGameData();

final Pattern summaryPartPattern = Pattern.compile("(\\w+)\\[(.*?)\\]");
final Matcher summaryPartMatcher = summaryPartPattern
.matcher(gameSummary);
final Matcher summaryPartMatcher = summaryPartPattern.matcher(gameSummary);

while (summaryPartMatcher.find()) {

Expand Down Expand Up @@ -600,11 +599,11 @@ private static void parseResultToken(final SkatGameData gameData,
final int matadors = Integer.parseInt(token.substring(2));

gameData.getGameResult().setPlayWithJacks(matadors > 0);
gameData.getGameResult().setMultiplier(Math.abs(matadors));
gameData.getGameResult().setMatadors(Math.abs(matadors));

} else if ("overbid".equals(token)) {

gameData.getResult().setOverBidded(true);
gameData.getResult().setOverBid(true);

} else if (token.startsWith("p:")) {

Expand Down
20 changes: 10 additions & 10 deletions jskat-base/src/main/java/org/jskat/data/GameSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public final static class GameSummaryFactory {
* @return Game announcement
*/
public GameSummary getSummary() {
GameSummary result;
final GameSummary result;
if (validate()) {
result = tmpSummary;
tmpSummary = new GameSummary();
Expand Down Expand Up @@ -183,7 +183,7 @@ public void setDeclarer(final Player position) {
tmpSummary.declarer = position;
}

public void addRamschLooser(Player looser) {
public void addRamschLooser(final Player looser) {
tmpSummary.ramschLosers.add(looser);
}

Expand All @@ -210,11 +210,11 @@ private boolean validate() {
return true;
}

public void setContra(Boolean contra) {
public void setContra(final Boolean contra) {
tmpSummary.contra = contra;
}

public void setRe(Boolean re) {
public void setRe(final Boolean re) {
tmpSummary.re = re;
}
}
Expand Down Expand Up @@ -307,12 +307,12 @@ public int getFinalOpponentScore() {
}

/**
* Gets the multiplier for the game
* Gets the matadors for the game
*
* @return Multiplier for the game
* @return Matadors for the game
*/
public int getGameMultiplier() {
return gameResult.getMultiplier();
public int getMatadors() {
return gameResult.getMatadors();
}

/**
Expand Down Expand Up @@ -348,7 +348,7 @@ public final List<Trick> getTricks() {
@Override
public String toString() {

StringBuffer result = new StringBuffer();
final StringBuffer result = new StringBuffer();

result.append("Game summary: ").append(gameType);

Expand Down Expand Up @@ -414,7 +414,7 @@ public int hashCode() {
}

@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
Expand Down
13 changes: 10 additions & 3 deletions jskat-base/src/main/java/org/jskat/data/SkatGameData.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public boolean isOverBid() {
log.warn("Overbidding cannot happen in Ramsch games: gameType="
+ getGameType());
}
return result.isOverBidded();
return result.getOverBid();
}

/**
Expand Down Expand Up @@ -464,7 +464,7 @@ public void calcResult() {
} else {
if (rules.isOverbid(this)) {
result.setWon(false);
result.setOverBidded(true);
result.setOverBid(true);
result.setGameValue(rules.calcOverbidGameResult(this));
} else {
if (!result.isWon()) {
Expand All @@ -481,8 +481,8 @@ public void calcResult() {
}

if (GameType.GRAND_SUIT.contains(announcement.contract().gameType())) {
result.setMultiplier(rules.getMultiplier(this));
result.setPlayWithJacks(rules.isPlayWithJacks(this));
result.setMatadors(rules.getMatadors(this));
}

if (GameType.RAMSCH == announcement.contract().gameType()) {
Expand Down Expand Up @@ -718,6 +718,13 @@ public Map<Player, CardList> getDealtCards() {
Player.REARHAND, dealtCards.get(Player.REARHAND).getImmutableCopy());
}

public CardList getDealtDeclarerCardsAndSkat() {
final CardList declarerCards = new CardList(getDealtCards().get(getDeclarer()));
declarerCards.addAll(getDealtSkat());
return declarerCards;
}


/**
* Gets the dealt skat
*
Expand Down
102 changes: 54 additions & 48 deletions jskat-base/src/main/java/org/jskat/data/SkatGameResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
*/
public class SkatGameResult implements Cloneable {

private Integer gameValue;
private Integer multiplier;
private Integer finalDeclarerPoints;
private Integer finalOpponentPoints;
private Boolean playWithJacks;
private Boolean won;
private Boolean overBidded;
private Boolean schneider;
private Boolean schwarz;
private Boolean durchmarsch;
private Boolean jungfrau;
private int gameValue;
private int finalDeclarerPoints;
private int finalOpponentPoints;
private boolean playWithJacks;
private int matadors;
private boolean won;
private boolean overBid;
private boolean schneider;
private boolean schwarz;
private boolean durchmarsch;
private boolean jungfrau;

/**
* Constructor
*/
public SkatGameResult() {
gameValue = -1;
multiplier = 0;
matadors = 0;
finalDeclarerPoints = 0;
finalOpponentPoints = 0;
playWithJacks = false;
won = false;
overBidded = false;
overBid = false;
schneider = false;
schwarz = false;
durchmarsch = false;
Expand All @@ -42,12 +42,12 @@ public SkatGameResult() {
@Override
public SkatGameResult clone() {

SkatGameResult result = new SkatGameResult();
final SkatGameResult result = new SkatGameResult();
result.setGameValue(gameValue);
result.setMultiplier(multiplier);
result.setMatadors(matadors);
result.setPlayWithJacks(playWithJacks);
result.setWon(won);
result.setOverBidded(overBidded);
result.setOverBid(overBid);
result.setSchneider(schneider);
result.setSchwarz(schwarz);
result.setDurchmarsch(durchmarsch);
Expand Down Expand Up @@ -79,17 +79,17 @@ public void setWon(final boolean won) {
*
* @return TRUE, if the declarer did overbid
*/
public boolean isOverBidded() {
return overBidded;
public boolean getOverBid() {
return overBid;
}

/**
* Sets whether the declarer did overbid
*
* @param overBidded TRUE, if the declarer did overvid
* @param overBid TRUE, if the declarer did overvid
*/
public void setOverBidded(final boolean overBidded) {
this.overBidded = overBidded;
public void setOverBid(final boolean overBid) {
this.overBid = overBid;
}

/**
Expand Down Expand Up @@ -150,7 +150,7 @@ public boolean isDurchmarsch() {
*/
public void setDurchmarsch(final boolean durchmarsch) {
if (durchmarsch) {
setJungfrau(true);
setJungfrau(false);
}
this.durchmarsch = durchmarsch;
}
Expand Down Expand Up @@ -193,41 +193,39 @@ public void setGameValue(final int gameValue) {
}

/**
* Gets the multiplier<br>
* only meaningful in suit and grand games
* Gets whether the declarer played with or without jacks
*
* @return Multiplier
* @return TRUE, if the declarer played with jacks
*/
public int getMultiplier() {
return multiplier;
public boolean isPlayWithJacks() {
return playWithJacks;
}

/**
* Sets the multiplier<br>
* only meaningful in suit and grand games
* Sets whether the declarer played with or without jacks
*
* @param multiplier Multiplier
* @param playWithJacks TRUE, if the declarer played with jacks
*/
public void setMultiplier(final int multiplier) {
this.multiplier = multiplier;
public void setPlayWithJacks(final boolean playWithJacks) {
this.playWithJacks = playWithJacks;
}

/**
* Gets wether the declarer played with or without jacks
* Gets the number of matadors (Jacks and trump cards in a row without gaps).
*
* @return TRUE, if the declarer played with jacks
* @return Number of matadors
*/
public boolean isPlayWithJacks() {
return playWithJacks;
public int getMatadors() {
return matadors;
}

/**
* Sets whether the declarer played with or without jacks
* Sets the number of matadors.
*
* @param playWithJacks TRUE, if the declarer played with jacks
* @param matadors Number of matadors.
*/
public void setPlayWithJacks(final boolean playWithJacks) {
this.playWithJacks = playWithJacks;
public void setMatadors(final int matadors) {
this.matadors = matadors;
}

/**
Expand Down Expand Up @@ -273,10 +271,18 @@ public int getFinalDeclarerPoints() {
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(gameValue).append(", mult:").append(multiplier);
if (overBidded) {
sb.append(" (overbidded)");
final StringBuilder sb = new StringBuilder();
sb.append(gameValue);
if (matadors > 0) {
if (playWithJacks) {
sb.append(" with: ");
} else {
sb.append(" without: ");
}
sb.append(matadors).append(" play ").append(matadors + 1);
}
if (overBid) {
sb.append(" (overbid)");
}
if (durchmarsch) {
sb.append(" (Durchmarsch)");
Expand All @@ -296,12 +302,12 @@ public String toString() {
public int hashCode() {
return Objects
.hash(durchmarsch, finalDeclarerPoints, finalOpponentPoints, gameValue,
jungfrau, multiplier, overBidded, playWithJacks, schneider,
jungfrau, matadors, overBid, playWithJacks, schneider,
schwarz, won);
}

@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
Expand All @@ -318,8 +324,8 @@ public boolean equals(Object obj) {
Objects.equals(finalOpponentPoints, other.finalOpponentPoints) &&
Objects.equals(gameValue, other.gameValue) &&
Objects.equals(jungfrau, other.jungfrau) &&
Objects.equals(multiplier, other.multiplier) &&
Objects.equals(overBidded, other.overBidded) &&
Objects.equals(matadors, other.matadors) &&
Objects.equals(overBid, other.overBid) &&
Objects.equals(playWithJacks, other.playWithJacks) &&
Objects.equals(schneider, other.schneider) &&
Objects.equals(schwarz, other.schwarz) &&
Expand Down
Loading