Corrigé un bug concernant les parties à 5-6 joueurs à 1 contre 4-5

This commit is contained in:
ynerant 2019-12-06 20:42:10 +01:00
parent c924564bf1
commit 764924ed63
2 changed files with 10 additions and 25 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.ynerant.tarot" applicationId "fr.ynerant.tarot"
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 29 targetSdkVersion 29
versionCode 6 versionCode 7
versionName "0.2.2" versionName "0.2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {

View File

@ -287,10 +287,12 @@ public class Game {
if (p != attacker && p != follower) if (p != attacker && p != follower)
playerScore = -score; playerScore = -score;
else { else {
if (p == attacker) if (p == attacker && p == follower)
playerScore += getGameType().getAttackMultiplier() * score; playerScore += (getGameType().getNbPlayers() - 1) * score;
if (p == follower) else if (p == attacker)
playerScore += getGameType().getFollowMultiplier() * score; playerScore += (getGameType().getNbPlayers() - 1 - (follower == null ? 0 : 2)) * score;
else
playerScore += score;
} }
scores.put(p, playerScore); scores.put(p, playerScore);
@ -405,11 +407,10 @@ public class Game {
g.calculateScores(); g.calculateScores();
for (Player p : g.getPlayers()) { for (Player p : g.getPlayers())
p.addScore(g.getGameType(), g.getPoints(p)); p.addScore(g.getGameType(), g.getPoints(p));
} }
} }
}
catch (IOException ex) { catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@ -418,23 +419,7 @@ public class Game {
} }
public enum GameType { public enum GameType {
THREE_PLAYERS(2, 0), FOUR_PLAYERS(3, 0), FIVE_PLAYERS(2, 1), SIX_PLAYERS(3, 1); THREE_PLAYERS, FOUR_PLAYERS, FIVE_PLAYERS, SIX_PLAYERS;
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;
}
public int getNbPlayers() { public int getNbPlayers() {
return ordinal() + 3; return ordinal() + 3;