diff --git a/jskat-base/src/main/java/org/jskat/control/iss/MessageParser.java b/jskat-base/src/main/java/org/jskat/control/iss/MessageParser.java index 217cf216..dc89ec78 100644 --- a/jskat-base/src/main/java/org/jskat/control/iss/MessageParser.java +++ b/jskat-base/src/main/java/org/jskat/control/iss/MessageParser.java @@ -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()) { @@ -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:")) { diff --git a/jskat-base/src/main/java/org/jskat/data/GameSummary.java b/jskat-base/src/main/java/org/jskat/data/GameSummary.java index 3105807f..df667a29 100644 --- a/jskat-base/src/main/java/org/jskat/data/GameSummary.java +++ b/jskat-base/src/main/java/org/jskat/data/GameSummary.java @@ -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(); @@ -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); } @@ -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; } } @@ -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(); } /** @@ -348,7 +348,7 @@ public final List getTricks() { @Override public String toString() { - StringBuffer result = new StringBuffer(); + final StringBuffer result = new StringBuffer(); result.append("Game summary: ").append(gameType); @@ -414,7 +414,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } diff --git a/jskat-base/src/main/java/org/jskat/data/SkatGameData.java b/jskat-base/src/main/java/org/jskat/data/SkatGameData.java index cba4c9ef..37854156 100644 --- a/jskat-base/src/main/java/org/jskat/data/SkatGameData.java +++ b/jskat-base/src/main/java/org/jskat/data/SkatGameData.java @@ -303,7 +303,7 @@ public boolean isOverBid() { log.warn("Overbidding cannot happen in Ramsch games: gameType=" + getGameType()); } - return result.isOverBidded(); + return result.getOverBid(); } /** @@ -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()) { @@ -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()) { @@ -718,6 +718,13 @@ public Map 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 * diff --git a/jskat-base/src/main/java/org/jskat/data/SkatGameResult.java b/jskat-base/src/main/java/org/jskat/data/SkatGameResult.java index e0fb89a8..8c85fd03 100644 --- a/jskat-base/src/main/java/org/jskat/data/SkatGameResult.java +++ b/jskat-base/src/main/java/org/jskat/data/SkatGameResult.java @@ -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; @@ -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); @@ -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; } /** @@ -150,7 +150,7 @@ public boolean isDurchmarsch() { */ public void setDurchmarsch(final boolean durchmarsch) { if (durchmarsch) { - setJungfrau(true); + setJungfrau(false); } this.durchmarsch = durchmarsch; } @@ -193,41 +193,39 @@ public void setGameValue(final int gameValue) { } /** - * Gets the multiplier
- * 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
- * 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; } /** @@ -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)"); @@ -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; } @@ -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) && diff --git a/jskat-base/src/main/java/org/jskat/util/rule/GrandRule.java b/jskat-base/src/main/java/org/jskat/util/rule/GrandRule.java index 5eb4592e..dc0156c1 100644 --- a/jskat-base/src/main/java/org/jskat/util/rule/GrandRule.java +++ b/jskat-base/src/main/java/org/jskat/util/rule/GrandRule.java @@ -12,12 +12,17 @@ public class GrandRule extends SuitGrandRule { /** * {@inheritDoc} */ - @Override - public int getMultiplier(CardList cards, GameType gameType) { + public int getBaseMultiplier(final CardList cards, final GameType gameType) { if (gameType != GameType.GRAND) { throw new IllegalArgumentException("Wrong ruleset - " + gameType); } - int result = 1; + + return getMatadors(cards, gameType) + 1; + } + + public int getMatadors(final CardList cards, final GameType gameType) { + int result = 0; + if (cards.contains(Card.CJ)) { result++; if (cards.contains(Card.SJ)) { @@ -41,6 +46,7 @@ public int getMultiplier(CardList cards, GameType gameType) { } } } + return result; } } diff --git a/jskat-base/src/main/java/org/jskat/util/rule/NullRule.java b/jskat-base/src/main/java/org/jskat/util/rule/NullRule.java index 81426e92..5b19be24 100644 --- a/jskat-base/src/main/java/org/jskat/util/rule/NullRule.java +++ b/jskat-base/src/main/java/org/jskat/util/rule/NullRule.java @@ -121,12 +121,8 @@ public boolean hasSuit(final GameType gameType, final CardList hand, return result; } - /** - * {@inheritDoc} - */ @Override - public int getMultiplier( - @SuppressWarnings("unused") final SkatGameData gameData) { + public int getMatadors(final SkatGameData gameData) { return 0; } diff --git a/jskat-base/src/main/java/org/jskat/util/rule/RamschRule.java b/jskat-base/src/main/java/org/jskat/util/rule/RamschRule.java index 51add738..d82dc5c2 100644 --- a/jskat-base/src/main/java/org/jskat/util/rule/RamschRule.java +++ b/jskat-base/src/main/java/org/jskat/util/rule/RamschRule.java @@ -20,9 +20,9 @@ public class RamschRule extends SuitGrandRamschRule { */ @Override public int getGameValueForWonGame(final SkatGameData gameData) { - int highestPlayerPoints = getGetHighestPlayerPoints(gameData); + final int highestPlayerPoints = getGetHighestPlayerPoints(gameData); - return highestPlayerPoints * getMultiplier(gameData); + return highestPlayerPoints * getBaseMultiplier(gameData); } /** @@ -38,10 +38,10 @@ private static int getGetHighestPlayerPoints(final SkatGameData gameData) { int result = 0; - int foreHandPoints = gameData.getPlayerPoints(Player.FOREHAND); - int middleHandPoints = gameData.getPlayerPoints(Player.MIDDLEHAND); - int rearHandPoints = gameData.getPlayerPoints(Player.REARHAND); - int skatPoints = JSkatOptions.instance().getRamschSkatOwner() == RamschSkatOwner.LOSER ? gameData + final int foreHandPoints = gameData.getPlayerPoints(Player.FOREHAND); + final int middleHandPoints = gameData.getPlayerPoints(Player.MIDDLEHAND); + final int rearHandPoints = gameData.getPlayerPoints(Player.REARHAND); + final int skatPoints = JSkatOptions.instance().getRamschSkatOwner() == RamschSkatOwner.LOSER ? gameData .getSkat().getTotalValue() : 0; // FIXME (jan 18.11.2011) make this simpler @@ -91,7 +91,7 @@ public boolean isGameWon(final SkatGameData gameData) { public static final boolean isDurchmarsch(final Player player, final SkatGameData gameData) { if (gameData.getTricks().size() == 10) { - for (Trick t : gameData.getTricks()) { + for (final Trick t : gameData.getTricks()) { if (t.getTrickWinner() != player) { return false; } @@ -113,7 +113,7 @@ public static final boolean isDurchmarsch(final Player player, public static final boolean isJungfrau(final Player player, final SkatGameData gameData) { if (gameData.getTricks().size() == 10) { - for (Trick t : gameData.getTricks()) { + for (final Trick t : gameData.getTricks()) { if (t.getTrickWinner() == player) { return false; } @@ -126,8 +126,7 @@ public static final boolean isJungfrau(final Player player, /** * {@inheritDoc} */ - @Override - public int getMultiplier(final SkatGameData gameData) { + public int getBaseMultiplier(final SkatGameData gameData) { int multiplier = 1; @@ -142,6 +141,11 @@ public int getMultiplier(final SkatGameData gameData) { return multiplier; } + @Override + public int getMatadors(final SkatGameData gameData) { + return 0; + } + /** * {@inheritDoc} */ diff --git a/jskat-base/src/main/java/org/jskat/util/rule/SkatRule.java b/jskat-base/src/main/java/org/jskat/util/rule/SkatRule.java index 48f9533c..c39c36c8 100644 --- a/jskat-base/src/main/java/org/jskat/util/rule/SkatRule.java +++ b/jskat-base/src/main/java/org/jskat/util/rule/SkatRule.java @@ -83,12 +83,11 @@ public interface SkatRule { Player calculateTrickWinner(GameType gameType, Trick trick); /** - * calculates the multiplier of a card list with regard to the ruleset - * - * @param gameData Game data - * @return the multiplier for bidding and game announcement + * Calculates the number of matadors (Jacks and trump cards in a row without gaps). + *

+ * return Number of matadors */ - int getMultiplier(SkatGameData gameData); + int getMatadors(SkatGameData gameData); /** * Checks whether the game is played with jacks or without diff --git a/jskat-base/src/main/java/org/jskat/util/rule/SuitGrandRule.java b/jskat-base/src/main/java/org/jskat/util/rule/SuitGrandRule.java index b2fd0083..b92387ae 100644 --- a/jskat-base/src/main/java/org/jskat/util/rule/SuitGrandRule.java +++ b/jskat-base/src/main/java/org/jskat/util/rule/SuitGrandRule.java @@ -40,7 +40,7 @@ private static int getMinimumWinningScore(final SkatGameData gameData) { */ @Override public int getGameValueForWonGame(final SkatGameData gameData) { - int multiplier = getMultiplier(gameData); + int multiplier = getBaseMultiplier(gameData); log.debug("calcSuitResult: after Jacks and Trump: multiplier " + multiplier); @@ -111,43 +111,34 @@ public int calcGameResult(final SkatGameData gameData) { * @param gameData Game data * @return Multiplier */ - @Override - public int getMultiplier(final SkatGameData gameData) { - - int result = 0; - - final CardList declarerCards = getDeclarerCards(gameData); + public int getBaseMultiplier(final SkatGameData gameData) { + return getBaseMultiplier(gameData.getDealtDeclarerCardsAndSkat(), gameData.getGameType()); + } - result = getMultiplier(declarerCards, gameData.getGameType()); + /** + * Gets the multiplier for a {@link CardList} and a {@link GameType} + * + * @param cards Card list + * @param gameType Game type + * @return Multiplier + */ + protected abstract int getBaseMultiplier(CardList cards, GameType gameType); - return result; + @Override + public int getMatadors(final SkatGameData gameData) { + return getMatadors(gameData.getDealtDeclarerCardsAndSkat(), gameData.getGameType()); } - private CardList getDeclarerCards(final SkatGameData gameData) { - final CardList declarerCards = new CardList(gameData.getDealtCards().get(gameData.getDeclarer())); - declarerCards.addAll(gameData.getDealtSkat()); - return declarerCards; - } + public abstract int getMatadors(CardList cards, GameType gameType); /** * {@inheritDoc} */ @Override public boolean isPlayWithJacks(final SkatGameData gameData) { - final CardList declarerCards = getDeclarerCards(gameData); - - return declarerCards.contains(Card.CJ); + return gameData.getDealtDeclarerCardsAndSkat().contains(Card.CJ); } - /** - * Gets the multiplier for a {@link CardList} and a {@link GameType} - * - * @param cards Card list - * @param gameType Game type - * @return Multiplier - */ - public abstract int getMultiplier(CardList cards, GameType gameType); - /** * Checks whether a game was a schneider game
* schneider means one party made only 30 points or below diff --git a/jskat-base/src/main/java/org/jskat/util/rule/SuitRule.java b/jskat-base/src/main/java/org/jskat/util/rule/SuitRule.java index 1a16fd3e..4453fa53 100644 --- a/jskat-base/src/main/java/org/jskat/util/rule/SuitRule.java +++ b/jskat-base/src/main/java/org/jskat/util/rule/SuitRule.java @@ -10,12 +10,17 @@ public class SuitRule extends SuitGrandRule { /** * {@inheritDoc} */ - @Override - public int getMultiplier(final CardList cards, final GameType gameType) { + public int getBaseMultiplier(final CardList cards, final GameType gameType) { if (gameType == GameType.GRAND || gameType == GameType.RAMSCH || gameType == GameType.NULL) { throw new IllegalArgumentException("Wrong ruleset - " + gameType); } - int result = 1; + + return getMatadors(cards, gameType) + 1; + } + + public int getMatadors(final CardList cards, final GameType gameType) { + int result = 0; + if (cards.contains(Card.CJ)) { result++; if (cards.contains(Card.SJ)) { @@ -53,6 +58,7 @@ public int getMultiplier(final CardList cards, final GameType gameType) { } } } + return result; } } diff --git a/jskat-base/src/test/java/org/jskat/control/iss/MessageParserTest.java b/jskat-base/src/test/java/org/jskat/control/iss/MessageParserTest.java index 61242a6a..dae5fbb1 100644 --- a/jskat-base/src/test/java/org/jskat/control/iss/MessageParserTest.java +++ b/jskat-base/src/test/java/org/jskat/control/iss/MessageParserTest.java @@ -93,7 +93,7 @@ public void testParseGameSummary() { assertFalse(gameData.isGameWon()); assertThat(gameData.getResult().getGameValue()).isEqualTo(-54); assertThat(gameData.getResult().isPlayWithJacks()).isFalse(); - assertThat(gameData.getResult().getMultiplier()).isEqualTo(2); + assertThat(gameData.getResult().getMatadors()).isEqualTo(2); assertThat(gameData.getDeclarerScore()).isEqualTo(59); assertThat(gameData.getOpponentScore()).isEqualTo(61); assertFalse(gameData.isSchneider()); @@ -102,10 +102,11 @@ public void testParseGameSummary() { } private static void checkTrick(final Trick trick, - final Player trickForeHand, final Card firstCard, - final Card secondCard, final Card thirdCard, + final Player trickForeHand, + final Card firstCard, + final Card secondCard, + final Card thirdCard, final Player trickWinner) { - final int trickNo = trick.getTrickNumberInGame(); assertThat(trick.getForeHand()).isEqualTo(trickForeHand); assertThat(trick.getFirstCard()).isEqualTo(firstCard); assertThat(trick.getSecondCard()).isEqualTo(secondCard); @@ -161,7 +162,7 @@ public void testParseGameSummary002() { assertTrue(gameData.isGameWon()); assertThat(gameData.getResult().getGameValue()).isEqualTo(96); assertThat(gameData.getResult().isPlayWithJacks()).isTrue(); - assertThat(gameData.getResult().getMultiplier()).isEqualTo(3); + assertThat(gameData.getResult().getMatadors()).isEqualTo(3); assertThat(gameData.getDeclarerScore()).isEqualTo(85); assertThat(gameData.getOpponentScore()).isEqualTo(35); assertFalse(gameData.isSchneider()); @@ -235,7 +236,7 @@ public void testParseGameSummary_PassedGame() { assertFalse(gameData.isGameWon()); assertThat(gameData.getResult().getGameValue()).isEqualTo(0); assertThat(gameData.getResult().isPlayWithJacks()).isFalse(); - assertThat(gameData.getResult().getMultiplier()).isEqualTo(0); + assertThat(gameData.getResult().getMatadors()).isEqualTo(0); assertThat(gameData.getDeclarerScore()).isEqualTo(0); assertThat(gameData.getOpponentScore()).isEqualTo(0); assertFalse(gameData.isSchneider()); @@ -290,6 +291,16 @@ public void testParseGameSummary_CorruptData() { final SkatGameData gameData = MessageParser.parseGameSummary(gameSummary); } + @Test + public void testParseGameSummary_OverbidSuitGame() { + + final String gameSummary = "(;GM[Skat]PC[International Skat Server]CO[]SE[403949]ID[8650652]DT[2023-10-18/18:44:11/UTC]P0[kermit]P1[bonsai]P2[kermit:2]R0[]R1[0.0]R2[]MV[w DQ.CK.HT.CT.SK.C9.DA.D9.DK.S8.H9.S7.SA.H8.C7.CA.H7.CJ.CQ.D7.SQ.S9.C8.DT.SJ.HA.ST.D8.DJ.HJ.HQ.HK 1 18 0 p 2 20 1 y 2 22 1 y 2 23 1 y 2 24 1 y 2 27 1 y 2 30 1 y 2 33 1 y 2 35 1 y 2 36 1 p 2 s w HQ.HK 2 D.C8.ST 0 HT 1 H9 2 HA 2 DJ 0 D9 1 D7 2 HJ 0 DQ 1 CJ 1 CA 2 DT 0 C9 2 SJ 0 DK 1 H8 2 HK 0 S8 1 H7 2 HQ 0 SK 1 C7 2 SQ 0 CT 1 SA 1 S7 2 S9 0 CK 2 D8 0 DA 1 CQ ]R[d:2 loss v:-72 m:-1 overbid p:75 t:7 s:0 z:0 p0:0 p1:0 p2:0 l:-1 to:-1 r:0] ;)"; + + final SkatGameData gameData = MessageParser.parseGameSummary(gameSummary); + + assertThat(gameData.getResult().getMatadors()).isEqualTo(1); + } + @Test public void testParseTableUpdatePlayerLeft() { diff --git a/jskat-base/src/test/java/org/jskat/util/CardDeckTest.java b/jskat-base/src/test/java/org/jskat/util/CardDeckTest.java index c4f27a55..46c68444 100644 --- a/jskat-base/src/test/java/org/jskat/util/CardDeckTest.java +++ b/jskat-base/src/test/java/org/jskat/util/CardDeckTest.java @@ -1,4 +1,3 @@ - package org.jskat.util; @@ -48,7 +47,10 @@ public void addDoubleCard() { public void addTooMuchCards() { assertThrows(IllegalStateException.class, () -> { final CardDeck cards = new CardDeck( - "CJ SJ HJ CK CQ SK C7 C8 S7 H7 D7 DJ CA CT C9 SQ HA HK HQ S8 H8 H9 HT SA ST S9 D8 D9 DT DA DK DQ"); + "CJ SJ HJ CK CQ SK C7 C8 S7 H7", + "D7 DJ CA CT C9 SQ HA HK HQ S8", + "H8 H9 HT SA ST S9 D8 D9 DT DA", + "DK DQ"); cards.add(Card.CJ); }); } diff --git a/jskat-base/src/test/java/org/jskat/util/rule/RamschRuleTest.java b/jskat-base/src/test/java/org/jskat/util/rule/RamschRuleTest.java index 543f52ea..8c69dc38 100644 --- a/jskat-base/src/test/java/org/jskat/util/rule/RamschRuleTest.java +++ b/jskat-base/src/test/java/org/jskat/util/rule/RamschRuleTest.java @@ -20,7 +20,7 @@ public class RamschRuleTest extends AbstractJSkatTest { private SkatGameData data; - private static final SkatRule ramschRules = SkatRuleFactory.getSkatRules(GameType.RAMSCH); + private static final RamschRule ramschRules = (RamschRule) SkatRuleFactory.getSkatRules(GameType.RAMSCH); /** * {@inheritDoc} @@ -224,19 +224,19 @@ public void testCalcGameValue_AllPlayerEqualPoints() { @Test public void testGetMultiplierGeschoben() { - assertThat(ramschRules.getMultiplier(data)).isEqualTo(1); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(1); data.addGeschoben(); - assertThat(ramschRules.getMultiplier(data)).isEqualTo(2); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(2); data.addGeschoben(); - assertThat(ramschRules.getMultiplier(data)).isEqualTo(4); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(4); data.addGeschoben(); - assertThat(ramschRules.getMultiplier(data)).isEqualTo(8); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(8); } /** @@ -245,7 +245,7 @@ public void testGetMultiplierGeschoben() { @Test public void testMultiplierJungfrau() { - assertThat(ramschRules.getMultiplier(data)).isEqualTo(1); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(1); for (int i = 0; i < 10; i++) { final Trick trick = new Trick(0, Player.FOREHAND); @@ -259,7 +259,7 @@ public void testMultiplierJungfrau() { data.setJungfrauDurchmarsch(); - assertThat(ramschRules.getMultiplier(data)).isEqualTo(2); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(2); assertTrue(data.isJungfrau()); assertFalse(data.isDurchmarsch()); } @@ -270,7 +270,7 @@ public void testMultiplierJungfrau() { @Test public void testMultiplierGeschobenJungfrau() { - assertThat(ramschRules.getMultiplier(data)).isEqualTo(1); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(1); data.addGeschoben(); data.addGeschoben(); @@ -288,7 +288,7 @@ public void testMultiplierGeschobenJungfrau() { data.setJungfrauDurchmarsch(); - assertThat(ramschRules.getMultiplier(data)).isEqualTo(16); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(16); assertTrue(data.isJungfrau()); assertFalse(data.isDurchmarsch()); } @@ -299,7 +299,7 @@ public void testMultiplierGeschobenJungfrau() { @Test public void testMultiplierDurchmarsch() { - assertThat(ramschRules.getMultiplier(data)).isEqualTo(1); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(1); // all tricks are made by forehand player for (int i = 0; i < 10; i++) { @@ -310,7 +310,7 @@ public void testMultiplierDurchmarsch() { data.setJungfrauDurchmarsch(); - assertThat(ramschRules.getMultiplier(data)).isEqualTo(2); + assertThat(ramschRules.getBaseMultiplier(data)).isEqualTo(2); assertTrue(data.isJungfrau()); assertTrue(data.isDurchmarsch()); } diff --git a/jskat-base/src/test/java/org/jskat/util/rule/SuitRuleTest.java b/jskat-base/src/test/java/org/jskat/util/rule/SuitRuleTest.java index a7a20710..e07537b3 100644 --- a/jskat-base/src/test/java/org/jskat/util/rule/SuitRuleTest.java +++ b/jskat-base/src/test/java/org/jskat/util/rule/SuitRuleTest.java @@ -327,7 +327,7 @@ public void testOverbid() { assertThat(data.getResult().isWon()).isFalse(); assertThat(data.getResult().getGameValue()).isEqualTo(-54); - assertThat(data.getResult().isOverBidded()).isTrue(); + assertThat(data.getResult().getOverBid()).isTrue(); } /** @@ -355,13 +355,13 @@ public void testOverbidWithSchneider() { public void testGetMultiplier() { final var rule = new SuitRule(); - assertThat(rule.getMultiplier( + assertThat(rule.getMatadors( CardList.of(Card.SJ, Card.HJ, Card.DJ, Card.DT, Card.D8, Card.SQ, Card.S9, Card.HA, Card.HK, Card.HQ), GameType.DIAMONDS)) - .isEqualTo(2); - assertThat(rule.getMultiplier( + .isEqualTo(1); + assertThat(rule.getMatadors( CardList.of(Card.HJ, Card.DJ, Card.DT, Card.D8, Card.SQ, Card.S9, Card.HA, Card.HK, Card.HQ, Card.H7), GameType.DIAMONDS)) - .isEqualTo(3); + .isEqualTo(2); } } diff --git a/jskat-swing-gui/src/main/java/org/jskat/gui/swing/table/GameInformationPanel.java b/jskat-swing-gui/src/main/java/org/jskat/gui/swing/table/GameInformationPanel.java index 75b02e79..69e38a29 100644 --- a/jskat-swing-gui/src/main/java/org/jskat/gui/swing/table/GameInformationPanel.java +++ b/jskat-swing-gui/src/main/java/org/jskat/gui/swing/table/GameInformationPanel.java @@ -28,22 +28,22 @@ class GameInformationPanel extends JPanel { private int gameNumber; private GameState gameState; private GameType gameType; - private int multiplier; private boolean playWithJacks; + private int matadors; private boolean handGame; private boolean ouvertGame; private boolean schneiderAnnounced; private boolean schneider; private boolean schwarzAnnounced; private boolean schwarz; - private boolean overBidded; + private boolean overBid; private boolean contra; private boolean re; private int trick; private boolean gameWon; private int declarerPoints; private int opponentPoints; - private Set ramschLoosers; + private Set ramschLosers; /** * Constructor @@ -97,7 +97,7 @@ void setGameContract(final GameContract contract) { private void resetGameData() { gameType = null; - multiplier = 0; + matadors = 0; playWithJacks = false; handGame = false; ouvertGame = false; @@ -105,14 +105,14 @@ private void resetGameData() { schneider = false; schwarzAnnounced = false; schwarz = false; - overBidded = false; + overBid = false; contra = false; re = false; trick = 1; gameWon = false; declarerPoints = 0; opponentPoints = 0; - ramschLoosers = new HashSet<>(); + ramschLosers = new HashSet<>(); } private void refreshText() { @@ -152,7 +152,7 @@ private void appendGameOverDetails(final StringBuffer text) { if (gameType == GameType.RAMSCH) { text.append(" - "); - final Iterator iterator = ramschLoosers.iterator(); + final Iterator iterator = ramschLosers.iterator(); if (iterator.hasNext()) { text.append(strings.getPlayerString(iterator.next())); } @@ -164,8 +164,7 @@ private void appendGameOverDetails(final StringBuffer text) { } else if (gameType != GameType.NULL && gameType != GameType.PASSED_IN) { text.append(" - "); - text.append( - declarerPoints + " " + strings.getString("versus") + " "); + text.append(declarerPoints + " " + strings.getString("versus") + " "); text.append(opponentPoints + " " + strings.getString("points")); } } @@ -178,15 +177,15 @@ private void appendGameType(final StringBuffer text) { if (gameType != null) { text.append(" [" + strings.getGameType(gameType)); - if (gameState.equals(GameState.GAME_OVER) && multiplier > 0) { + if (gameState.equals(GameState.GAME_OVER) && matadors > 0) { if (playWithJacks) { text.append(" " + strings.getString("with")); } else { text.append(" " + strings.getString("without")); } - text.append(" " + (multiplier - 1)); + text.append(" " + matadors); text.append(" " + strings.getString("play")); - text.append(" " + multiplier); + text.append(" " + (matadors + 1)); } if (handGame) { @@ -217,7 +216,7 @@ private void appendGameType(final StringBuffer text) { text.append(" " + strings.getString("re")); } - if (overBidded) { + if (overBid) { text.append(" " + strings.getString("overbidded")); } @@ -233,13 +232,13 @@ private void appendGameNumber(final StringBuffer text) { void setGameSummary(final GameSummary summary) { - multiplier = summary.getGameMultiplier(); playWithJacks = summary.isGamePlayedWithJacks(); + matadors = summary.getMatadors(); gameWon = summary.isGameWon(); declarerPoints = summary.getFinalDeclarerPoints(); opponentPoints = summary.getFinalOpponentScore(); - ramschLoosers = summary.getRamschLosers(); - overBidded = summary.gameResult.isOverBidded(); + ramschLosers = summary.getRamschLosers(); + overBid = summary.gameResult.getOverBid(); schneider = summary.gameResult.isSchneider(); schwarz = summary.gameResult.isSchwarz(); refreshText();