Commit 198442ab authored by Felix RABADAN's avatar Felix RABADAN
Browse files

Merge branch 'main' of gitlab.univ-nantes.fr:E188013M/2021-kervestin-rabadan-java into main

parents 8240d842 ab375d1a
......@@ -24,8 +24,8 @@ public class Admin extends Member {
}
public void putOnMarket() { // the administrator can only creat new random cards with random prices
Card new_card = CardController.getInstance().createRandomCard();
Market.getInstance().getBuyableCards().add(new Triple<Card, Integer, User>(new_card,
Card newCard = CardController.getInstance().createRandomCard();
Market.getInstance().getBuyableCards().add(new Triple<Card, Integer, User>(newCard,
new Random().nextInt(1000) + 1, null));
}
......
......@@ -17,7 +17,7 @@ public class CardController {
return instance;
}
public Card controlNbMaxCards(String new_key, int number, Player player, Rarity rarity) {
public Card controlNbMaxCards(String newKey, int number, Player player, Rarity rarity) {
int maxBound = 0;
switch (rarity) {
case COMMON:
......@@ -33,15 +33,15 @@ public class CardController {
break;
}
if (0 < number && number < maxBound) {
Card new_card = new Card(number, rarity, player);
Card newCard = new Card(number, rarity, player);
if (player.getNbCommonCards() < maxBound) {
player.getCards().put(new_key, new_card);
player.getCards().put(newKey, newCard);
player.setNbCommonCards();
} else {
System.err.println("The player " + player.getName() + " has too many " + rarity + " cards");
return null;
}
return new_card;
return newCard;
} else {
System.err.println("Error : card's number incorrect");
return null;
......@@ -50,9 +50,9 @@ public class CardController {
}
public Card createCard(int number, Card.Rarity rarity, Player player) {
String new_key = "" + number + rarity;
if (!player.getCards().containsKey(new_key)) {
return controlNbMaxCards(new_key, number, player, rarity);
String newKey = "" + number + rarity;
if (!player.getCards().containsKey(newKey)) {
return controlNbMaxCards(newKey, number, player, rarity);
} else {
System.err.println("This card already exists");
return null;
......
......@@ -30,9 +30,9 @@ public final class UserController {
public User addUser(String name) {
if (!users.containsKey(name)) {
User new_user = new User(name);
users.put(name, new_user);
return new_user;
User newUser = new User(name);
users.put(name, newUser);
return newUser;
} else {
System.err.println("This user already exists");
return users.get(name);
......@@ -70,15 +70,17 @@ public final class UserController {
for (User user : userRank) {
user.updateTeamScore();
Boolean valid = true;
for (Card card : user.getTeam()) {//on parcours la team du user
for (Card card : user.getTeam()) {// on parcours la team du user
if (card == null) {
valid = false;
break;
}
}
if (valid) {userRankValid.add(user);}//si user n'a pas de card null dans team on le rajoute au user valide
if (valid) {
userRankValid.add(user);
} // si user n'a pas de card null dans team on le rajoute au user valide
}
//tri du rank en fonction du teamscore
// tri du rank en fonction du teamscore
Collections.sort(userRank, (a, b) -> Math.round(b.getTeamScore() - (a.getTeamScore())));
System.out.println("### Classement ###");
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment