Commit 76e6339b authored by Felix RABADAN's avatar Felix RABADAN
Browse files

fix choseTeam

parent a31ecb55
......@@ -26,7 +26,7 @@ public class Card {
}
public String toString() {
return this.player.getName() + " / " + this.rarity + " / " + this.number;
return this.player.getName() + " / " + this.rarity + " / " + this.number + " / " + this.player.getPosition();
}
public Object getId() {
......
......@@ -8,7 +8,7 @@ import game.controllers.ClubController;
import game.controllers.PlayerController;
public class Parser {
public static void parseTeam(String pathname) throws FileNotFoundException {
public static void parse(String pathname) throws FileNotFoundException {
Scanner fileScanner = new Scanner(new File(pathname));
ClubController clubController = ClubController.getInstance();
PlayerController playerController = PlayerController.getInstance();
......@@ -29,6 +29,7 @@ public class Parser {
}else{
playposition= Player.Position.COURT_FIELD_PLAYER;
}
//TODO verify
Player player = playerController.addPlayer(name,playposition,score);
club.addPlayer(player);
// while (lineScanner.hasNext()) {
......@@ -39,5 +40,4 @@ public class Parser {
}
fileScanner.close();
}
}
package game;
import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;
import game.Card.Rarity;
......@@ -53,7 +52,7 @@ public class User extends Member {
}
}
public Card chooseCard() {
private Card chooseCard() {
int choice;
do {
choice = scanner.nextInt();
......@@ -61,25 +60,40 @@ public class User extends Member {
return deck.get(choice);
}
public Card chooseCard(Player.Position position) {
private Card chooseCardToDeck(Player.Position position) {// verifie aussi quil ny ai pas 2x le meme joueur pour la
// creation de deck
int choice;
Player.Position chosePosition;
boolean samePlayer;
do {
choice = scanner.nextInt();
chosePosition = deck.get(choice).getPlayer().getPosition();
} while (choice >= deck.size() || chosePosition != position);
samePlayer = false;
for (Card card : team) {// check si le joueur nest pas deja dans la team
if (card != null && card.getPlayer() == deck.get(choice).getPlayer()) {
samePlayer = true;
break;
}
}
// System.out.println(choice >= deck.size() );
// System.out.println(chosePosition != position );
// System.out.println(samePlayer);
} while (choice >= deck.size() || chosePosition != position || samePlayer);
return deck.get(choice);
}
public void chooseDeck() {
deck.clear();
System.out.println("Which goalkeeper do you want to add to your deck");
displayDeck();
team[0] = chooseCard(Position.GOAL_KEEPER);
for (int i = 1; i < team.length; i++) {
System.out.printf("Choose your nb%d court field player\n", i);
if (deck.size() < 4) {
System.out.println("You don't have enough cards to create a team");
} else {
System.out.println("Which goalkeeper do you want to add to your deck");
displayDeck();
team[i] = chooseCard(Position.COURT_FIELD_PLAYER);
team[0] = chooseCardToDeck(Position.GOAL_KEEPER);
for (int i = 1; i < team.length; i++) {
System.out.printf("Choose your nb%d court field player\n", i);
displayDeck();
team[i] = chooseCardToDeck(Position.COURT_FIELD_PLAYER);
}
}
}
......
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