Commit 8240d842 authored by Felix RABADAN's avatar Felix RABADAN
Browse files

interface

parent 187d44b9
......@@ -13,4 +13,4 @@ FC Nantes Alban Lafont 0 0 0 13/27 (48%) 0 (0) 0 (0) 0 (0) 90' G 6.3
FC Nantes Dennis Appiah 0 0 0 3/6 (50%) 3 (0) 3 (0) 0 (0) 21' D 6.3
FC Nantes Sébastien Corchia 0 1 0 6/6 (100%) 4 (1) 4 (1) 0 (0) 39' D 5.7
FC Nantes Kalifa Coulibaly 0 0 0 0/0 0 (0) 0 (0) 0 (0) 1' F -
FC Nantes Samuel Moutoussamy 0 0 0 1/1 (100%) 0 (0) 0 (0) 0 (0) 1' M -
\ No newline at end of file
FC Nantes Samuel Moutoussamy 0 0 0 1/1 (100%) 0 (0) 0 (0) 0 (0) 1' M -
......@@ -13,5 +13,4 @@ France Kingsley Coman 0 0 0 17/22 (77%) 2 (2) 2 (2) 0 (0) 33' F 6.8
France Moussa Diaby 0 0 0 16/17 (94%) 3 (1) 3 (1) 0 (0) 56' F 6.7
France Adrien Rabiot 0 0 1 40/46 (87%) 4 (2) 3 (1) 1 (1) 86' M 6.5
France Mattéo Guendouzi 0 0 0 14/18 (78%) 4 (2) 3 (1) 1 (1) 23' M 6.5
France Jordan Veretout 0 0 0 0/1 (0%) 0 (0) 0 (0) 0 (0) 8' M 6.4
France Jordan Veretout 0 0 0 0/1 (0%) 0 (0) 0 (0) 0 (0) 8' M 6.4
\ No newline at end of file
FC Nantes Quentin Merlin 0 0 0 20/21 (95%) 1 (0) 0 (0) 1 (0) 32' F 7.2
FC Nantes Kalifa Coulibaly 0 0 1 5/8 (63%) 13 (8) 4 (2) 9 (6) 58' F 7.0
FC Nantes Pedro Chirivella 0 0 3 70/77 (91%) 10 (6) 9 (5) 1 (1) 90' M 7.0
FC Nantes Andrei Girotto 0 0 4 27/30 (90%) 12 (6) 9 (4) 3 (2) 90' D 6.9
FC Nantes Marcus Coco 0 0 0 14/17 (82%) 9 (4) 8 (4) 1 (0) 77' M 6.9
FC Nantes Alban Lafont 0 0 0 15/20 (75%) 1 (1) 0 (0) 1 (1) 90' G 6.8
FC Nantes Ludovic Blas 0 0 0 39/43 (91%) 6 (2) 6 (2) 0 (0) 90' M 6.8
FC Nantes Samuel Moutoussamy 0 0 0 40/43 (93%) 1 (0) 1 (0) 0 (0) 77' M 6.6
FC Nantes Willem Geubbels 0 0 0 4/5 (80%) 2 (2) 1 (1) 1 (1) 13' F 6.6
FC Nantes Fábio 0 0 2 16/21 (76%) 12 (6) 12 (6) 0 (0) 58' D 6.4
FC Nantes Sébastien Corchia 0 0 1 5/6 (83%) 4 (2) 4 (2) 0 (0) 42' D 6.4
FC Nantes Wylan Cyprien 0 0 2 10/11 (91%) 3 (2) 3 (2) 0 (0) 13' M 6.4
FC Nantes Jean-Charles Castelletto 0 0 2 14/15 (93%) 5 (2) 5 (2) 0 (0) 90' D 6.3
FC Nantes Osman Bukari 0 0 1 13/13 (100%) 7 (2) 7 (2) 0 (0) 32' M 6.1
FC Nantes Randal Kolo Muani 1 0 3 21/26 (81%) 17 (7) 15 (5) 2 (2) 90' M 6.1
FC Nantes Dennis Appiah 0 0 0 20/21 (95%) 3 (0) 3 (0) 0 (0) 48' D 5.8
\ No newline at end of file
......@@ -10,5 +10,4 @@ FC Nantes Samuel Moutoussamy 0 0 3 24/31 (77%) 8 (3) 7 (3) 1 (0) 90' M 6.6
FC Nantes Fábio 0 0 9 18/30 (60%) 17 (11) 15 (10) 2 (1) 78' D 6.4
FC Nantes Marcus Coco 0 0 0 0/0 5 (1) 4 (1) 1 (0) 8' F 6.4
FC Nantes Pedro Chirivella 0 0 0 28/37 (76%) 6 (0) 6 (0) 0 (0) 90' M 6.3
FC Nantes Randal Kolo Muani 0 0 1 7/9 (78%) 29 (10) 15 (5) 14 (5) 90' F 6.2
FC Nantes Randal Kolo Muani 0 0 1 7/9 (78%) 29 (10) 15 (5) 14 (5) 90' F 6.2
\ No newline at end of file
......@@ -9,5 +9,4 @@ FC Nantes Randal Kolo Muani 0 0 0 7/12 (58%) 12 (5) 10 (4) 2 (1) 90' F 6.6
FC Nantes Wylan Cyprien 0 0 0 40/45 (89%) 6 (2) 5 (2) 1 (0) 90' M 6.6
FC Nantes Willem Geubbels 0 0 0 1/3 (33%) 1 (0) 0 (0) 1 (0) 13' F 6.5
FC Nantes Jean-Charles Castelletto 0 0 0 27/29 (93%) 3 (0) 3 (0) 0 (0) 90' D 6.4
FC Nantes Nicolas Pallois 0 0 2 14/17 (82%) 4 (2) 4 (2) 0 (0) 32' D 5.5
FC Nantes Nicolas Pallois 0 0 2 14/17 (82%) 4 (2) 4 (2) 0 (0) 32' D 5.5
\ No newline at end of file
......@@ -29,22 +29,24 @@ public class Admin extends Member {
new Random().nextInt(1000) + 1, null));
}
public void newWeek(String pathname) {
public void newFile(String teamName, int weekNb) throws FileNotFoundException {
Parser.parse("CSV\\2021_" + weekNb + "\\2021_" + weekNb + "_" + teamName + ".csv");
}
public void newWeek() {
/**
* Launch a next week, and make every actions necessary
*/
try {
Parser.parse(pathname);
} catch (FileNotFoundException e) {
e.printStackTrace();
}//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));;
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));
;
}
}
......@@ -3,11 +3,161 @@ package game;
import game.controllers.*;
import java.io.FileNotFoundException;
import java.util.Scanner;
import game.Player.Position;
public class Game {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("1 - Normal game\n2 - Test game");
int i = sc.nextInt();
if (i == 1) {
normalGame();
} else {
testGame();
}
}
private static void normalGame() {
Scanner sc = new Scanner(System.in);
Boolean end = false;
while (!end) {
UserController userController = UserController.getInstance();
System.out.println("1 - create new user\n2 - connect to user\n3 - connect to admin\n4 - remove user\n5 - game over");
int i = sc.nextInt();
switch (i) {
case 1:
System.out.println("Name of the new user :");
String name = sc.next();
userController.connect(userController.addUser(name));
break;
case 2:
System.out.println("Name of the user");
String username = sc.next();
userController.connect(username);
connected();
break;
case 3:
admin();
sc.next();
break;
case 4:
System.out.println("Name of the user you want to remove :");
String userToRemove = sc.next();
userController.removeUser(userToRemove);
break;
case 5:
end = true;
default:
break;
}
}
sc.close();
}
private static void connected() {
Scanner sc = new Scanner(System.in);
User u = UserController.getInstance().getConnectedMember();
Boolean connected = true;
while (connected) {
System.out.println(
"1 - displayDeck\n2 - display balance\n3 - compose team\n4 - go to market\n5 - disconnect");
int i = sc.nextInt();
switch (i) {
case 1:
u.displayDeck();
break;
case 2:
u.displayBalance();
break;
case 3:
u.chooseTeam();
break;
case 4:
market();
break;
case 5:
UserController.getInstance().disconnect();
connected = false;
break;
default:
break;
}
}
sc.close();
}
private static void market() {
Scanner sc = new Scanner(System.in);
User u = UserController.getInstance().getConnectedMember();
Boolean onMarket = true;
while (onMarket) {
System.out.println("1 - buy\n2 - sell\n3 - exchange\n4 - leave market");
int i = sc.nextInt();
switch (i) {
case 1:
u.buy();
break;
case 2:
u.sell();
break;
case 3:
u.exchange();
break;
case 4:
onMarket = false;
break;
default:
break;
}
}
sc.close();
}
private static void admin() {
Admin admin = Admin.getInstance();
Scanner sc = new Scanner(System.in);
Boolean connected = true;
while (connected) {
System.out.println("1 - new file\n2 - new card(s)\n3 - new week\n4 - disconnect");
int i = sc.nextInt();
switch (i) {
case 1:
while (true) {
try {
System.out.println("Week number ?");
int weekNb = sc.nextInt();
System.out.println("Team name ?");
String teamName = sc.next();
admin.newFile(teamName, weekNb);
break;
} catch (FileNotFoundException e) {
System.out.println("Invalid, try again.");
}
}
break;
case 2:
System.out.println("How many new cards do you want to put on market ?");
int nbCards = sc.nextInt();
for (int j = 0; j < nbCards; j++) {
admin.putOnMarket();
}
break;
case 3:
admin.newWeek();
break;
case 4:
connected = false;
break;
default:
break;
}
}
sc.close();
}
private static void testGame() {
// DEBUT TEST
System.out.println("NEW GAME !!!!!!!");
......@@ -48,7 +198,7 @@ public class Game {
malo.chooseTeam();
prof.chooseTeam();
admin.newWeek("CSV\\2021_42\\2021_42_Nantes.csv");// first week
felix.displayDeck();//on voit bien la nouvelle carte rare en plus
admin.newWeek();// first week
felix.displayDeck();// on voit bien la nouvelle carte rare en plus
}
}
......@@ -11,7 +11,7 @@ import game.User;
public final class UserController {
private static UserController instance = null;
private HashMap<String, User> users;
private Member connectedMember;
private User connectedUser;
private UserController() {
users = new HashMap<String, User>();
......@@ -46,18 +46,22 @@ public final class UserController {
}
}
public void connect(Member user) {
if (connectedMember == null) {
this.connectedMember = user;
public void connect(User user) {
if (connectedUser == null) {
this.connectedUser = user;
System.out.println(user.getName() + " is connected");
} else {
System.out.println("Connexion error : another user is already connected");
}
}
public void connect(String name) {
connect(users.get(name));
}
public void disconnect() {
System.out.println(connectedMember.getName() + " is disconnected");
connectedMember = null;
System.out.println(connectedUser.getName() + " is disconnected");
connectedUser = null;
}
public ArrayList<User> rank() {
......@@ -85,4 +89,8 @@ public final class UserController {
}
return userRank;
}
public User getConnectedMember() {
return connectedUser;
}
}
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