From 764924ed63532ba433f55d166a2075a7131868ab Mon Sep 17 00:00:00 2001 From: ynerant Date: Fri, 6 Dec 2019 20:42:10 +0100 Subject: [PATCH] =?UTF-8?q?Corrig=C3=A9=20un=20bug=20concernant=20les=20pa?= =?UTF-8?q?rties=20=C3=A0=205-6=20joueurs=20=C3=A0=201=20contre=204-5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +-- app/src/main/java/fr/ynerant/tarot/Game.java | 31 +++++--------------- 2 files changed, 10 insertions(+), 25 deletions(-) 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;