Skip to content

Commit

Permalink
Fixed another concurrency bug with animation
Browse files Browse the repository at this point in the history
  • Loading branch information
jberclaz committed Apr 25, 2020
1 parent e12506c commit 088aac7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
21 changes: 4 additions & 17 deletions src/main/java/com/leflat/jass/client/ModernGamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ public void collectCards(PlayerPosition position) {
animationFrameNumber++;
repaint(repaintArea);
if (animationFrameNumber >= totalNbrSteps) {
animationTimer.stop();
collectPlie();
gameMode = GameMode.GAME;
collectPlie();
animationTimer.stop();
}
});
gameMode = GameMode.ANIMATION;
Expand Down Expand Up @@ -319,21 +319,8 @@ private void pressButtonAnnouncement(ActionEvent evt) {
}

private void repaintPlayerArea(PlayerPosition position) {
var area = getRenderingDimension();
switch (position) {
case MYSELF:
repaint(toInt(getPlayerArea(area)));
break;
case ACROSS:
repaint(toInt(getAcrossArea(area)));
break;
case LEFT:
repaint(toInt(getLeftArea(area)));
break;
case RIGHT:
repaint(toInt(getRightArea(area)));
break;
}
var playerArea = getPlayerArea(position);
repaint(toInt(playerArea));
}

private Dimension getCardDimension(Rectangle2D.Float renderingArea) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/leflat/jass/server/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ Plie playOneHand(int firstToPlay) throws PlayerLeftExpection, BrokenRuleExceptio
Plie playPlie(int startingPlayer) throws PlayerLeftExpection, BrokenRuleException {
var plie = new Plie();

for (int i = 0; i < 4; i++) { // demande de jouer
for (int i = 0; i < 4; i++) { // demande de jouer
var player = players.get((startingPlayer + i) % 4);
var card = player.play();

for (int j = 1; j < 4; j++) { // envoie la carte jouée aux autres
for (int j = 1; j < 4; j++) { // envoie la carte jouée aux autres
players.get((startingPlayer + i + j) % 4).setPlayedCard(player, card);
}

Expand Down

0 comments on commit 088aac7

Please sign in to comment.