sendTchatMessage((String)args);
}
else
{
Game game = (Game)args;
if(game.isStarted())
{
boolean online = (boolean)controller.execute("isOnline", null);
if(game.getPlayers().size() < 4)
{}
else
{
start();
southCards = new ArrayList<>();
northCards = new ArrayList<>();
eastCards = new ArrayList<>();
westCards = new ArrayList<>();
Position[] pos = new Position[3];
pos[0] = Position.WEST;
pos[1] = Position.NORTH;
pos[2] = Position.EAST;
for(Player p : game.getPlayers())
{
for(int i = 0; i < p.getHand().getCards().size(); i++)
{
if(game.getPlayers().indexOf(p) == numPlayer)
{
addCard(Position.SOUTH, p.getHand().getCards().get(i).getImg());
}
else
{
addCard(pos[(game.getPlayers().indexOf(p) - numPlayer + 3) % 4], "res\\cartes\\carte_inconnue.png");
}
}
}
Team us = (numPlayer % 2) == 0 ? game.getT1() : game.getT2();
Team them = (numPlayer % 2) == 1 ? game.getT1() : game.getT2();
setScore(us.getPoints());
setGameScore(us.getGamePoints(), them.getGamePoints());
//Si l'atout n'a pas encore �t� pris
if(game.getCurrentSet().getTrump() == null || game.getCurrentSet().getTrump().equals("null"))
{
showTrump(game.getPacket().getCards().get(game.getPacket().getCards().size() - 1).getImg());
//Si on n'est pas le joueur qui commence
if(!game.getCurrentSet().getTaker().getLogin().equals(game.getPlayers().get(numPlayer).getLogin()))
{
}
//C'est au tour du joueur de d�cider s'il veut prendre l'atout ou non
else
{
takeButton.setDisable(false);
passButton.setDisable(false);
if (online)
{
sendRedTchatMessage("Vous avez 45 secondes pour d�cider de prendre l'atout ou de passer.");
}
//Si on est au deuxi�me tour
if(game.getCurrentSet().getTurn() == 1)
{
Family fam = null;
String trump = game.getPacket().getCards().get(game.getPacket().getCards().size() - 1).getColor();
switch(trump)
{
case "Carreau":
fam = Family.DIAMONDS;
break;
case "Pique":
fam = Family.SPADES;
break;
case "Tr�fle":
fam = Family.CLUBS;
break;
case "Coeur":
fam = Family.HEARTS;
break;
default:
break;
}
otherTrumps(fam);
}
}
}
//L'atout a �t� choisi
else
{
if(game.getCarpet().getCards().size() == 0) resetCenter();
if((game.getPlayers().get(numPlayer).hasBelote() && game.getCurrentSet().getBelotePlayed() == 0) || game.getCurrentSet().getBelotePlayed() == 1)
beloteCheck.setDisable(false);
else
beloteCheck.setDisable(true);
resetCenter();
Position playPos[] = new Position[4];
playPos[numPlayer] = Position.SOUTH;
playPos[(numPlayer+1)%4] = Position.WEST;
playPos[(numPlayer+2)%4] = Position.NORTH;
playPos[(numPlayer+3)%4] = Position.EAST;
String starterLogin = game.getCurrentSet().getStarter().getLogin();
int starter = 0;
for(Player p : game.getPlayers()){
if(p.getLogin().equals(starterLogin))
break;
starter++;
}
for(Card c : game.getCarpet().getCards())
{
playCard(playPos[(starter - game.getCarpet().getCards().size() + 4)%4], new Image(c.getImg()));
starter++;
}
if(game.getPacket().getCards().size() > 0)
{
Pack packet = game.getPacket();
setFold(new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 4).getImg())),
new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 3).getImg())),
new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 2).getImg())),
new ImageView(new Image(packet.getCards().get(packet.getCards().size() - 1).getImg())));
}
setTrump(game.getCurrentSet().getTrump());
}
}
}
else
{
sendRedTchatMessage("Partie termin�e");
Team us = (numPlayer % 2) == 0 ? game.getT1() : game.getT2();
Team them = (numPlayer % 2) == 1 ? game.getT1() : game.getT2();
//Team winner = us.getGamePoints() > them.getGamePoints() ? us : them;
//winner.getGamePoints(); //Les points du vainqueur
//controller.execute("addNbPoints", new Object[] {winner.getP1().getLogin(), winner.getGamePoints()});
//controller.execute("addNbPoints", new Object[] {winner.getP2().getLogin(), winner.getGamePoints()});
setScore(us.getPoints());