diff --git a/app/build.gradle b/app/build.gradle index d20cb4b..f594447 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "fr.ynerant.tarot" minSdkVersion 24 targetSdkVersion 29 - versionCode 6 - versionName "0.2.2" + versionCode 7 + versionName "0.2.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/fr/ynerant/tarot/Game.java b/app/src/main/java/fr/ynerant/tarot/Game.java index 6f4554c..afc5170 100644 --- a/app/src/main/java/fr/ynerant/tarot/Game.java +++ b/app/src/main/java/fr/ynerant/tarot/Game.java @@ -287,10 +287,12 @@ public class Game { if (p != attacker && p != follower) playerScore = -score; else { - if (p == attacker) - playerScore += getGameType().getAttackMultiplier() * score; - if (p == follower) - playerScore += getGameType().getFollowMultiplier() * score; + if (p == attacker && p == follower) + playerScore += (getGameType().getNbPlayers() - 1) * score; + else if (p == attacker) + playerScore += (getGameType().getNbPlayers() - 1 - (follower == null ? 0 : 2)) * score; + else + playerScore += score; } scores.put(p, playerScore); @@ -405,9 +407,8 @@ public class Game { g.calculateScores(); - for (Player p : g.getPlayers()) { + for (Player p : g.getPlayers()) p.addScore(g.getGameType(), g.getPoints(p)); - } } } catch (IOException ex) { @@ -418,23 +419,7 @@ public class Game { } public enum GameType { - THREE_PLAYERS(2, 0), FOUR_PLAYERS(3, 0), FIVE_PLAYERS(2, 1), SIX_PLAYERS(3, 1); - - private final int attackMultiplier; - private final int followMultiplier; - - GameType(int attack, int follow) { - this.attackMultiplier = attack; - this.followMultiplier = follow; - } - - public int getAttackMultiplier() { - return attackMultiplier; - } - - public int getFollowMultiplier() { - return followMultiplier; - } + THREE_PLAYERS, FOUR_PLAYERS, FIVE_PLAYERS, SIX_PLAYERS; public int getNbPlayers() { return ordinal() + 3;