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

mise en vente des cartes côté système et utilisateur

parent 3cbbdccd
......@@ -2,11 +2,8 @@ package game;
import game.controllers.*;
<<<<<<< HEAD
=======
import java.io.FileNotFoundException;
>>>>>>> 516ce458b2b6d48772710f66eccae34c13a74a5e
import game.Player.Position;
public class Game {
......@@ -22,7 +19,7 @@ public class Game {
CardController cardController = CardController.getInstance();
Player p = new Player("Paul Pogba", Position.COURT_FIELD_PLAYER, (float)5.0);
Player p = new Player("Paul Pogba", Position.COURT_FIELD_PLAYER, (float) 5.0);
Card card1 = cardController.createCard(1, Card.Rarity.COMMON, p);
cardController.createCard(1, Card.Rarity.COMMON, p);
cardController.removeCard(card1);
......@@ -47,12 +44,18 @@ public class Game {
market.displayBuyableCards();
p.displayCards();
//test parser
try {
Parser.parseTeam("CSV\\2021_46_Nantes.csv");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
felix.addCard(card1);
market.displayBuyableCards();
userController.sell();
felix.displayDeck();
market.displayBuyableCards();
// test parser
// try {
// Parser.parseTeam("CSV\\2021_46_Nantes.csv");
// } catch (FileNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
}
......@@ -18,8 +18,11 @@ public class Market {
}
public void displayBuyableCards() {
int i = 0;
System.out.println("The market :");
for (Pair<Card, Integer> pair : buyableCards) {
System.out.println(pair.toString());
System.out.println(i + " - " + pair.toString());
i++;
}
}
......
......@@ -16,9 +16,15 @@ public class User {
}
public void displayDeck() {
int i = 0;
System.out.println("My deck :");
for (Card card : deck) {
System.out.println("- " + card.toString());
if (!deck.isEmpty()) {
for (Card card : deck) {
System.out.println(i + " - " + card.toString());
i++;
}
} else {
System.out.println("empty");
}
}
......@@ -33,4 +39,11 @@ public class User {
public ArrayList<Card> getDeck() {
return this.deck;
}
public void addCard(Card card) {
if (card != null) {
deck.add(card);
System.out.println("Your card has been added in your deck");
}
}
}
\ No newline at end of file
......@@ -50,6 +50,15 @@ public final class UserController {
}
}
public void disconnect(User user) {
if (connectedUser != null) {
this.connectedUser = null;
System.out.println(user.getName() + " is disconnected");
} else {
System.out.println("Disconnexion error : nobody is connected");
}
}
private Scanner scanner = new Scanner(System.in);
public void sell() {
......@@ -60,6 +69,7 @@ public final class UserController {
System.out.println("At which price ?");
int price = scanner.nextInt();
CardController.getInstance().putOnMarket(new Pair<Card, Integer>(chosenCard, price));
System.out.println("Your card is on the market now");
connectedUser.getDeck().remove(chosenCard);
}
}
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