Commit ab375d1a authored by Malo KERVESTIN's avatar Malo KERVESTIN
Browse files

fix merge

parents 1d4652a4 187d44b9
......@@ -10,6 +10,7 @@ import game.controllers.UserController;
public class Admin extends Member {
private static Admin instance = null;
private int weeknb = 0;
private Admin() {
super("admin");
......@@ -36,15 +37,14 @@ public class Admin extends Member {
Parser.parse(pathname);
} catch (FileNotFoundException e) {
e.printStackTrace();
} // update the score and players
ArrayList<User> rank = UserController.getInstance().rank();// update the rank of every users
// best user get their cards
rank.get(0).addCard(CardController.getInstance().createRandomCard(Rarity.RARE));
;
rank.get(1).addCard(CardController.getInstance().createRandomCard(Rarity.LESS_COMMON));
;
rank.get(2).addCard(CardController.getInstance().createRandomCard(Rarity.COMMON));
;
}//update the score and players
weeknb++;
System.out.printf("The %d week is starting...\n\n", weeknb);
ArrayList<User> rank = UserController.getInstance().rank();//update the rank of every users
//best user get their cards
rank.get(0).addCard(CardController.getInstance().createRandomCard(Rarity.RARE));;
rank.get(1).addCard(CardController.getInstance().createRandomCard(Rarity.LESS_COMMON));;
rank.get(2).addCard(CardController.getInstance().createRandomCard(Rarity.COMMON));;
}
}
......@@ -17,6 +17,7 @@ public class Game {
User felix = userController.addUser("felix");
User malo = userController.addUser("malo");
User prof = userController.addUser("prof");
User sensei = userController.addUser("sensei");
Admin admin = Admin.getInstance();
// add all the players
......@@ -48,8 +49,6 @@ public class Game {
prof.chooseTeam();
admin.newWeek("CSV\\2021_42\\2021_42_Nantes.csv");// first week
felix.displayDeck();// on voit bien la nouvelle carte rare en plus
// TODO compteur de semaine
// TODO verif joueur on tous fait leurs equipe
felix.displayDeck();//on voit bien la nouvelle carte rare en plus
}
}
......@@ -10,7 +10,7 @@ public class User extends Member {
private int balance;
private ArrayList<Card> deck;
private Card[] team;
private Float teamScore;
private Float teamScore =(float) 0;
private Scanner scanner = new Scanner(System.in);
......@@ -192,7 +192,9 @@ public class User extends Member {
public void updateTeamScore() {
float sum = 0;
for (Card c : team) {
if (c != null) {
sum += c.getPlayer().getScore() * c.getRarity().factor;
}
}
teamScore = sum / (float) team.length;
}
......@@ -200,4 +202,8 @@ public class User extends Member {
public float getTeamScore() {
return teamScore;
}
public Card[] getTeam() {
return team;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import game.Card;
import game.Member;
import game.User;
......@@ -61,9 +62,21 @@ public final class UserController {
public ArrayList<User> rank() {
ArrayList<User> userRank = new ArrayList<User>(users.values());
ArrayList<User> userRankValid = new ArrayList<User>();
for (User user : userRank) {
user.updateTeamScore();
Boolean valid = true;
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
}
// tri du rank en fonction du teamscore
Collections.sort(userRank, (a, b) -> Math.round(b.getTeamScore() - (a.getTeamScore())));
System.out.println("### Classement ###");
......
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