Skip to content

Commit

Permalink
Remove TextMakerFr redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mw3y committed May 24, 2024
1 parent 1c5531a commit e307444
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/ch/epfl/chacun/TextMakerFr.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ private String joinAnimalsWithQuantities(Map<Animal.Kind, Integer> animals) {
.toList());
}

/**
* Returns a string with the name of the player and the points he's earned.
* @param player the player
* @param points the points
* @return the string with the name of the player and the points he's earned
*/
private String hasEarned(PlayerColor player, int points) {
return STR."\{playerName(player)} a remporté \{points(points)}";
}

/**
* Returns a string with the names of the players and the points they've earned.
* @param players the players
* @param points the points
* @return the string with the names of the players and the points they've earned
*/
private String hasEarnedPlural(Set<PlayerColor> players, int points) {
return STR."\{joinPlayerNames(players)} \{conjugateEarn(players)} \{points(points)}";
}

@Override
public String playerName(PlayerColor playerColor) {
return players.get(playerColor);
Expand All @@ -142,15 +162,15 @@ public String playerClosedForestWithMenhir(PlayerColor player) {
public String playersScoredForest(Set<PlayerColor> scorers, int points, int mushroomGroupCount, int tileCount) {
String mushrooms = mushroomGroupCount > 0 ?
STR." et de \{accord("groupe", mushroomGroupCount)} de champignons" : "";
return STR."\{joinPlayerNames(scorers)} \{conjugateEarn(scorers)} \{points(points)} en tant " +
return STR."\{hasEarnedPlural(scorers, points)} en tant " +
STR."qu'\{pluralize("occupant·e", scorers)} " +
STR."\{pluralize("majoritaire", scorers)} d'une forêt " +
STR."composée de \{accord("tuile", tileCount)}\{mushroomGroupCount > 0 ? mushrooms : ""}.";
}

@Override
public String playersScoredRiver(Set<PlayerColor> scorers, int points, int fishCount, int tileCount) {
return STR."\{joinPlayerNames(scorers)} \{conjugateEarn(scorers)} \{points(points)} en tant qu'" +
return STR."\{hasEarnedPlural(scorers, points)} en tant qu'" +
STR."\{pluralize("occupant·e", scorers)} " +
STR."\{pluralize("majoritaire", scorers)} d'une rivière " +
STR."composée de \{accord("tuile", tileCount)}" +
Expand All @@ -159,43 +179,43 @@ public String playersScoredRiver(Set<PlayerColor> scorers, int points, int fishC

@Override
public String playerScoredHuntingTrap(PlayerColor scorer, int points, Map<Animal.Kind, Integer> animals) {
return STR."\{playerName(scorer)} a remporté \{points(points)} en plaçant la fosse à pieux dans un pré " +
return STR."\{hasEarned(scorer, points)} en plaçant la fosse à pieux dans un pré " +
STR."dans lequel elle est entourée de \{joinAnimalsWithQuantities(animals)}.";
}

@Override
public String playerScoredLogboat(PlayerColor scorer, int points, int lakeCount) {
return STR."\{playerName(scorer)} a remporté \{points(points)} en plaçant la pirogue dans un réseau " +
return STR."\{hasEarned(scorer, points)} en plaçant la pirogue dans un réseau " +
STR."hydrographique contenant \{accord("lac", lakeCount)}.";
}

@Override
public String playersScoredMeadow(Set<PlayerColor> scorers, int points, Map<Animal.Kind, Integer> animals) {
return STR."\{joinPlayerNames(scorers)} \{conjugateEarn(scorers)} \{points(points)} en tant qu'" +
return STR."\{hasEarnedPlural(scorers, points)} en tant qu'" +
STR."\{pluralize("occupant·e", scorers)} " +
STR."\{pluralize("majoritaire", scorers)} d'un pré contenant " +
STR."\{joinAnimalsWithQuantities(animals)}.";
}

@Override
public String playersScoredRiverSystem(Set<PlayerColor> scorers, int points, int fishCount) {
return STR."\{joinPlayerNames(scorers)} \{conjugateEarn(scorers)} \{points(points)} en tant qu'" +
return STR."\{hasEarnedPlural(scorers, points)} en tant qu'" +
STR."\{pluralize("occupant·e", scorers)} " +
STR."\{pluralize("majoritaire", scorers)} d'un réseau " +
STR."hydrographique contenant \{accord("poisson", fishCount)}.";
}

@Override
public String playersScoredPitTrap(Set<PlayerColor> scorers, int points, Map<Animal.Kind, Integer> animals) {
return STR."\{joinPlayerNames(scorers)} \{conjugateEarn(scorers)} \{points(points)} " +
return STR."\{hasEarnedPlural(scorers,points)} " +
STR."en tant qu'\{pluralize("occupant·e", scorers)} " +
STR."\{pluralize("majoritaire", scorers)} d'un pré contenant " +
STR."la grande fosse à pieux entourée de \{joinAnimalsWithQuantities(animals)}.";
}

@Override
public String playersScoredRaft(Set<PlayerColor> scorers, int points, int lakeCount) {
return STR."\{joinPlayerNames(scorers)} \{conjugateEarn(scorers)} \{points(points)} en tant " +
return STR."\{hasEarnedPlural(scorers, points)} en tant " +
STR."qu'\{pluralize("occupant·e", scorers)} " +
STR."\{pluralize("majoritaire", scorers)} " +
STR."d'un réseau hydrographique contenant le radeau et \{accord("lac", lakeCount)}.";
Expand Down

0 comments on commit e307444

Please sign in to comment.