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"
minSdkVersion 24
targetSdkVersion 29
versionCode 6
versionName "0.2.2"
versionCode 7
versionName "0.2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {

View File

@ -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;