|
|
|
@ -10,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
|
|
|
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
|
|
|
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
|
|
|
|
import com.badlogic.gdx.utils.Align;
|
|
|
|
|
import com.badlogic.gdx.utils.I18NBundle;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.GameAtlas;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.actors.game.CardActor;
|
|
|
|
@ -26,6 +27,7 @@ import eu.jonahbauer.wizard.common.messages.player.PlayCardMessage;
|
|
|
|
|
import eu.jonahbauer.wizard.common.messages.player.PlayerMessage;
|
|
|
|
|
import eu.jonahbauer.wizard.common.model.Card;
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
import org.jetbrains.annotations.Nls;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
@ -273,11 +275,19 @@ public class GameScreen extends MenuScreen {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addPrediction(int round, UUID player, int prediction) {
|
|
|
|
|
boolean changed = false;
|
|
|
|
|
if (activePlayer != null && activePlayer.first().equals(player) && (activePlayer.second() == CHANGE_PREDICTION || activePlayer.second() == MAKE_PREDICTION)) {
|
|
|
|
|
changed = activePlayer.second() == CHANGE_PREDICTION;
|
|
|
|
|
setActivePlayer(null, null, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addMessage(state.getPlayers().get(player) + " predicted " + prediction + ".");
|
|
|
|
|
if (state.getSelf().equals(player)) {
|
|
|
|
|
addMessage(game.messages.format("game.action." + (changed ? "change" : "make") + "_prediction.self", prediction));
|
|
|
|
|
} else {
|
|
|
|
|
var name = state.getPlayers().get(player);
|
|
|
|
|
addMessage(game.messages.format("game.action." + (changed ? "change" : "make") + "_prediction.other", name, prediction));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
execute(() -> padOfTruth.setPrediction(players.indexOf(player), round, prediction));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -286,7 +296,12 @@ public class GameScreen extends MenuScreen {
|
|
|
|
|
setActivePlayer(null, null, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addMessage(state.getPlayers().get(player) + " played a card.");
|
|
|
|
|
if (state.getSelf().equals(player)) {
|
|
|
|
|
addMessage(game.messages.get("game.action.play_card.self"));
|
|
|
|
|
} else {
|
|
|
|
|
var name = state.getPlayers().get(player);
|
|
|
|
|
addMessage(game.messages.format("game.action.play_card.other", name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Seat seat = seats.get(player);
|
|
|
|
|
|
|
|
|
@ -318,6 +333,9 @@ public class GameScreen extends MenuScreen {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setActivePlayer(UUID player, UserInputMessage.Action action, long timeout) {
|
|
|
|
|
if (action == SYNC) throw new IllegalArgumentException();
|
|
|
|
|
|
|
|
|
|
// reset label color
|
|
|
|
|
if (activePlayer != null && nameLabels.containsKey(activePlayer.getKey())) {
|
|
|
|
|
var label = nameLabels.get(activePlayer.getKey());
|
|
|
|
|
execute(() -> label.setStyle(labelStyleDefault));
|
|
|
|
@ -330,38 +348,47 @@ public class GameScreen extends MenuScreen {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activePlayer = Pair.of(player, action);
|
|
|
|
|
// set label color
|
|
|
|
|
if (nameLabels.containsKey(player)) {
|
|
|
|
|
var label = nameLabels.get(player);
|
|
|
|
|
execute(() -> label.setStyle(labelStyleActive));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (state.getSelf().equals(player)) {
|
|
|
|
|
// show interface
|
|
|
|
|
setPersistentMessage(null);
|
|
|
|
|
switch (action) {
|
|
|
|
|
case PICK_TRUMP -> execute(new PickTrumpOverlay(this, timeout, false));
|
|
|
|
|
case MAKE_PREDICTION -> execute(new MakePredictionOverlay(this, timeout, state.getRound()));
|
|
|
|
|
case CHANGE_PREDICTION -> execute(new ChangePredictionOverlay(this, timeout, state.getRound(), state.getPredictions().get(state.getSelf())));
|
|
|
|
|
case PLAY_CARD -> setPersistentMessage("It is your turn to play a card.");
|
|
|
|
|
case PLAY_CARD -> setPersistentMessage(game.messages.get("game.message.play_card.self"));
|
|
|
|
|
}
|
|
|
|
|
// TODO do something
|
|
|
|
|
} else {
|
|
|
|
|
var name = state.getPlayers().get(player);
|
|
|
|
|
setPersistentMessage("It is " + name + "'s turn to " + switch (action) {
|
|
|
|
|
case CHANGE_PREDICTION -> "change their prediction";
|
|
|
|
|
case JUGGLE_CARD -> "juggle a card";
|
|
|
|
|
case PLAY_CARD -> "play a card";
|
|
|
|
|
case PICK_TRUMP -> "pick the trump suit";
|
|
|
|
|
case MAKE_PREDICTION -> "make a prediction";
|
|
|
|
|
// show message
|
|
|
|
|
var key = switch (action) {
|
|
|
|
|
case CHANGE_PREDICTION -> "game.message.change_prediction.";
|
|
|
|
|
case JUGGLE_CARD -> "game.message.juggle_card.";
|
|
|
|
|
case MAKE_PREDICTION -> "game.message.make_prediction.";
|
|
|
|
|
case PICK_TRUMP -> "game.message.pick_trump.";
|
|
|
|
|
case PLAY_CARD -> "game.message.play_card.";
|
|
|
|
|
default -> throw new AssertionError();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (player == null) {
|
|
|
|
|
setPersistentMessage(game.messages.get(key + "all"));
|
|
|
|
|
} else {
|
|
|
|
|
var name = state.getPlayers().get(player);
|
|
|
|
|
setPersistentMessage(game.messages.format(key + "other", name));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addMessage(String text) {
|
|
|
|
|
public void addMessage(@Nls String text) {
|
|
|
|
|
addMessage(text, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addMessage(String text, boolean immediate) {
|
|
|
|
|
public void addMessage(@Nls String text, boolean immediate) {
|
|
|
|
|
var label = new Label(text, game.data.skin);
|
|
|
|
|
label.addAction(sequence(
|
|
|
|
|
delay(1.5f),
|
|
|
|
@ -384,7 +411,7 @@ public class GameScreen extends MenuScreen {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPersistentMessage(String text) {
|
|
|
|
|
public void setPersistentMessage(@Nls String text) {
|
|
|
|
|
execute(() -> {
|
|
|
|
|
if (text != null) {
|
|
|
|
|
if (persistentMessage == null) {
|
|
|
|
@ -418,7 +445,7 @@ public class GameScreen extends MenuScreen {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void timeout() {
|
|
|
|
|
addMessage("Timed out.");
|
|
|
|
|
addMessage(game.messages.get("game.message.timeout"));
|
|
|
|
|
ready(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -436,6 +463,10 @@ public class GameScreen extends MenuScreen {
|
|
|
|
|
return game.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public I18NBundle getMessages() {
|
|
|
|
|
return game.messages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
|
public enum Seat {
|
|
|
|
|
BOTTOM(WizardGame.WIDTH * 0.5f, 0, 0, 0, Align.bottom, WizardGame.WIDTH * 0.5f, 300),
|
|
|
|
|