added trick count label

main
Jonah Bauer 3 years ago
parent 91618aeb60
commit c41caeef59

@ -83,6 +83,7 @@ public class GameScreen extends WizardScreen {
private final Map<UUID, Seat> seats = new HashMap<>();
private final Map<UUID, Label> nameLabels = new HashMap<>();
private final Map<UUID, Label> trickLabels = new HashMap<>();
private final AtomicBoolean pendingSync = new AtomicBoolean();
@ -131,7 +132,7 @@ public class GameScreen extends WizardScreen {
stage.addActor(overlayRoot);
stage.addActor(menu = createMenu());
labelStyleDefault = skin.get(Label.LabelStyle.class);
labelStyleDefault = skin.get("textfield", Label.LabelStyle.class);
labelStyleActive = new Label.LabelStyle(labelStyleDefault);
labelStyleActive.fontColor = Color.RED;
@ -238,15 +239,22 @@ public class GameScreen extends WizardScreen {
padOfTruth.setName(i++, name);
if (isSelf(uuid)) continue;
var label = new Label("", skin);
var seat = seats.get(uuid);
label.setX(seat.getLabelX());
label.setY(seat.getLabelY());
label.setAlignment(seat.getLabelAlign());
label.setText(name);
nameLabels.put(uuid, label);
contentRoot.addActor(label);
var group = new HorizontalGroup();
group.setPosition(seat.getLabelX(), seat.getLabelY());
group.align(seat.getLabelAlign());
group.space(-3);
var nameLabel = new Label(name, skin);
group.addActor(nameLabel);
var trickLabel = new Label("0", skin, "textfield");
trickLabel.setAlignment(Align.center);
group.addActor(new Container<>(trickLabel).fill().width(50));
nameLabels.put(uuid, nameLabel);
trickLabels.put(uuid, trickLabel);
contentRoot.addActor(group);
}
}
@ -403,6 +411,7 @@ public class GameScreen extends WizardScreen {
handCards.clearChildren();
cardStack.clearChildren();
trickLabels.values().forEach(label -> label.setText("0"));
});
execute(new StartRoundOverlay(this, round));
}
@ -412,7 +421,7 @@ public class GameScreen extends WizardScreen {
execute(() -> cardStack.clearChildren());
}
public void finishTrick(@NotNull UUID player) {
public void finishTrick(@NotNull UUID player, int totalPlayerTricks) {
var seat = seats.getOrDefault(player, Seat.FALLBACK);
var animation = parallel();
@ -437,7 +446,11 @@ public class GameScreen extends WizardScreen {
AnimationTimings.STACK_FINISH_MOVE
))
),
targeting(card, alpha(0, AnimationTimings.STACK_FINISH_FADE))
targeting(card, alpha(0, AnimationTimings.STACK_FINISH_FADE)),
run(() -> {
var trickLabel = trickLabels.get(player);
if (trickLabel != null) trickLabel.setText(Integer.toString(totalPlayerTricks));
})
));
});
}),
@ -710,6 +723,7 @@ public class GameScreen extends WizardScreen {
}
padOfTruth.clearValues();
nameLabels.values().forEach(label -> label.setStyle(labelStyleDefault));
trickLabels.values().forEach(label -> label.setText("0"));
}
//</editor-fold>
@ -947,7 +961,7 @@ public class GameScreen extends WizardScreen {
@Getter
public enum Seat {
FALLBACK(WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT * 0.5f, 0, 0, 0, WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT * 0.5f),
BOTTOM(WizardGame.WIDTH * 0.5f, 0, 0, 0, Align.bottom, WizardGame.WIDTH * 0.5f, 300),
BOTTOM(WizardGame.WIDTH * 0.5f, 0, WizardGame.WIDTH * 0.5f, 37.5f, Align.center, WizardGame.WIDTH * 0.5f, 300),
LEFT(-324, WizardGame.HEIGHT * 0.5f, 50, WizardGame.HEIGHT * 0.5f + 110f, Align.bottomLeft, 117.5f, WizardGame.HEIGHT * 0.5f),
TOP_LEFT(WizardGame.WIDTH * 0.25f - 144, WizardGame.HEIGHT + 289, WizardGame.WIDTH * 0.25f, WizardGame.HEIGHT - 50, Align.top, WizardGame.WIDTH * 0.25f, WizardGame.HEIGHT - 200),
TOP(WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT + 324, WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT - 50, Align.top, WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT - 200),

@ -227,9 +227,10 @@ public final class Game extends BaseState {
log.info("This trick {} goes to {}.", cards, nameOf(player));
this.stack.clear();
this.tricks.computeIfAbsent(player, p -> new ArrayList<>())
.add(cards);
if (gameScreen != null) gameScreen.finishTrick(player);
var playerTricks = this.tricks.computeIfAbsent(player, p -> new ArrayList<>());
playerTricks.add(cards);
if (gameScreen != null) gameScreen.finishTrick(player, playerTricks.size());
}
private void onCardMessage(@NotNull UUID player, @NotNull Card card) {

Loading…
Cancel
Save