Commit 59195a5c authored by Felix RABADAN's avatar Felix RABADAN
Browse files

Fin choix deck

parent e59906f8
......@@ -40,14 +40,16 @@ public class Game {
Admin admin = Admin.getInstance();
admin.putOnMarket(new Pair<Card, Integer>(card1, 1000));
admin.putOnMarket(new Pair<Card, Integer>(card1, 505));
market.displayBuyableCards();
felix.addCard(card1);
market.displayBuyableCards();
felix.sell();
// felix.sell();
felix.displayDeck();
market.displayBuyableCards();
System.out.println("#### choose cards");
felix.chooseDeck();
// test parser
// try {
// Parser.parseTeam("CSV\\2021_46_Nantes.csv");
......
......@@ -45,15 +45,33 @@ public class User extends Member {
}
}
public Card chooseCard() {
int choice;
do {
choice = scanner.nextInt();
} while (choice >= deck.size());
return deck.get(choice);
}
public Card chooseCard(Player.Position position) {
int choice;
Player.Position chosePosition;
do {
choice = scanner.nextInt();
chosePosition = deck.get(choice).getPlayer().getPosition();
} while (choice >= deck.size()|| chosePosition != position);
return deck.get(choice);
}
public void chooseDeck() {
// TODO peut etre changer display deck avec condition pour qui affiche que
// goalkeeper ect
displayDeck();
deck.clear();
System.out.println("Which goalkeeper do you want to add to your deck");
for (Card card : deck) {
if (card.getPlayer().getPosition() == Position.GOAL_KEEPER) {
}
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);
displayDeck();
team[i] = chooseCard(Position.COURT_FIELD_PLAYER);
}
}
......@@ -62,8 +80,7 @@ public class User extends Member {
public void sell() {
System.out.println("Which card would you like to sell ?");
displayDeck();
int choice = scanner.nextInt();
Card chosenCard = deck.get(choice);
Card chosenCard = chooseCard();
System.out.println("At which price ?");
int price = scanner.nextInt();
putOnMarket(new Pair<Card, Integer>(chosenCard, price));
......
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