diff --git a/buildSrc/src/main/kotlin/eu/jonahbauer/wizard/build/TexturePackerTask.kt b/buildSrc/src/main/kotlin/eu/jonahbauer/wizard/build/TexturePackerTask.kt index 575b4ab..b42e1bb 100644 --- a/buildSrc/src/main/kotlin/eu/jonahbauer/wizard/build/TexturePackerTask.kt +++ b/buildSrc/src/main/kotlin/eu/jonahbauer/wizard/build/TexturePackerTask.kt @@ -52,16 +52,19 @@ abstract class TexturePackerTask : DefaultTask() { package eu.jonahbauer.wizard.client.libgdx; public class $name { public static final String ${'$'}PATH = "$path"; + """.trimIndent()) val content = atlas.readText(Charsets.UTF_8) val matcher = Pattern.compile("(?m)^([^:]*?)\$\\n {2}").matcher(content) + val fields = HashSet() while (matcher.find()) { val texture = matcher.group(1) val field = texture.replace("-", "_").replace("/", "_").uppercase(Locale.ROOT) - builder.append(" public static final String $field = \"$texture\";\n") + fields.add(" public static final String $field = \"$texture\";\n") } + fields.forEach(builder::append) builder.append("}\n") val out = generatedSourceOutput.file("eu/jonahbauer/wizard/client/libgdx/${name}.java").get().asFile diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/WizardGame.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/WizardGame.java index d880c43..3770a8f 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/WizardGame.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/WizardGame.java @@ -8,7 +8,7 @@ import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.I18NBundle; -import eu.jonahbauer.wizard.client.libgdx.screens.MainMenuScreen; +import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen; import java.util.Locale; @@ -40,7 +40,7 @@ public class WizardGame extends Game { Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 0, 0)); cursor.dispose(); - this.setScreen(new MainMenuScreen(this)); + this.setScreen(new GameScreen(this)); } @Override diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardActor.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardActor.java index 837d302..7140cad 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardActor.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardActor.java @@ -7,29 +7,58 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import eu.jonahbauer.wizard.client.libgdx.GameAtlas; import eu.jonahbauer.wizard.common.model.Card; import lombok.Getter; +import lombok.Setter; + +import java.util.Collections; +import java.util.EnumMap; +import java.util.Map; @Getter +@Setter public class CardActor extends Actor { - private final Card card; - private final TextureRegion texture; - float offset; - float baseY; + public static final float ASPECT_RATIO = 14f / 9f; + public static final float PREF_WIDTH = 135; + public static final float PREF_HEIGHT = 210; + + private static final Map ATLAS_PATHS; + + static { + var paths = new EnumMap(Card.class); + for (Card card : Card.values()) { + paths.put(card, switch ((int)(Math.random() * 4)) { + case 0 -> GameAtlas.CARDS_BLUE; + case 1 -> GameAtlas.CARDS_GREEN; + case 2 -> GameAtlas.CARDS_RED; + case 3 -> GameAtlas.CARDS_YELLOW; + default -> throw new AssertionError(); + }); + } + ATLAS_PATHS = Collections.unmodifiableMap(paths); + } + + private final TextureAtlas atlas; + + private Card card; + private TextureRegion background; public CardActor(Card card, TextureAtlas atlas) { + this.atlas = atlas; + setCard(card); + setWidth(PREF_WIDTH); + setHeight(PREF_HEIGHT); + } + + public void setCard(Card card) { this.card = card; - this.texture = atlas.findRegion(switch ((int)(Math.random() * 4)) { - case 0 -> GameAtlas.CARDS_BLUE; - case 1 -> GameAtlas.CARDS_GREEN; - case 2 -> GameAtlas.CARDS_RED; - case 3 -> GameAtlas.CARDS_YELLOW; - default -> throw new AssertionError(); - }); - setWidth(100); - setHeight(100); + this.background = atlas.findRegion(ATLAS_PATHS.get(card)); } @Override public void draw(Batch batch, float parentAlpha) { - batch.draw(texture, getX(), getY() + getHeight() - 100, getWidth(), 100); + var color = getColor(); + batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); + + float height = getWidth() * ASPECT_RATIO; + batch.draw(background, getX(), getY() + getHeight() - height, getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); } } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardStack.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardStack.java new file mode 100644 index 0000000..7951076 --- /dev/null +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardStack.java @@ -0,0 +1,90 @@ +package eu.jonahbauer.wizard.client.libgdx.actors.game; + +import com.badlogic.gdx.scenes.scene2d.*; +import eu.jonahbauer.wizard.client.libgdx.WizardGame; +import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen; +import lombok.Data; + +import java.util.*; + +import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*; + +public class CardStack extends Group { + private final Random random = new Random(); + private final List cards = new ArrayList<>(); + + public CardStack() { + this.addListener(new InputListener() { + @Override + public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { + if (fromActor == null || !isAscendantOf(fromActor)) { + cards.forEach(Entry::expand); + } + } + + @Override + public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { + if (toActor == null || !isAscendantOf(toActor)) { + cards.forEach(Entry::collapse); + } + } + }); + } + + public void add(GameScreen.Seat seat, CardActor card) { + var entry = new Entry( + card, + seat, + (float) random.nextGaussian((WizardGame.WIDTH - card.getWidth()) / 2, 15), + (float) random.nextGaussian((WizardGame.HEIGHT - card.getHeight()) / 2, 15), + (float) random.nextGaussian(0, 60), + (float) random.nextGaussian(0, 20) + ); + addActor(card); + entry.collapse(); + cards.add(entry); + } + + @Override + public void clearChildren(boolean unfocus) { + super.clearChildren(unfocus); + cards.clear(); + } + + @Data + private static class Entry { + private final CardActor actor; + private final GameScreen.Seat seat; + private final float x; + private final float y; + private final float rotation; + private final float rotation2; + private Action action; + + public void expand() { + if (action != null) { + actor.removeAction(action); + } + + action = parallel( + moveTo(seat.getCardX() - actor.getWidth() / 2, seat.getCardY() - actor.getHeight() / 2, 0.25f), + rotateTo(rotation2, 0.25f) + ); + + actor.addAction(action); + } + + public void collapse() { + if (action != null) { + actor.removeAction(action); + } + + action = parallel( + moveTo(x, y, 0.25f), + rotateTo(rotation, 0.25f) + ); + + actor.addAction(action); + } + } +} diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardsGroup.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardsGroup.java index f54a4d6..62727ef 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardsGroup.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/CardsGroup.java @@ -1,88 +1,196 @@ package eu.jonahbauer.wizard.client.libgdx.actors.game; import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.InputEvent; -import com.badlogic.gdx.scenes.scene2d.InputListener; -import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup; +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.*; +import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup; +import com.badlogic.gdx.utils.Pools; import eu.jonahbauer.wizard.common.model.Card; +import lombok.Getter; +import lombok.Setter; -import java.util.List; +import java.util.*; +import java.util.function.Consumer; + +public class CardsGroup extends WidgetGroup { + private static final float TARGET_SPACING = -50f; + + @Getter + private final float prefWidth = 0; + @Getter + private final float prefHeight = CardActor.PREF_HEIGHT; + + private final TextureAtlas atlas; + + private float[] cardX; + private float spacing; + private float cardWidth; -public class CardsGroup extends HorizontalGroup { - private TextureAtlas atlas; - private List actors; - private int hash; private CardActor target; + private boolean dragging; + private final float touchSlop = 5; + private CardActor dragTarget; + private float dragStartX; + + @Setter + private Consumer onClickListener; + public CardsGroup(List cards, TextureAtlas atlas) { this.atlas = atlas; update(cards); + setFillParent(true); + this.addListener(new InputListener() { + + @Override + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + if (pointer != 0) return false; + if (event.getTarget() instanceof CardActor card) { + dragTarget = card; + dragStartX = x; + return true; + } + return false; + } + + @Override + public void touchDragged(InputEvent event, float x, float y, int pointer) { + if (pointer != 0) return; + if (!dragging && Math.abs(x - dragStartX) > touchSlop) { + dragging = true; + } else if (dragging) { + int index = Arrays.binarySearch(cardX, x - (cardWidth + spacing)); + if (index < 0) { + index = -(index + 1); + if (index >= getChildren().size) return; + } + if (getChild(index) != dragTarget) { + float oldX = dragTarget.getX(); + getChildren().removeValue(dragTarget, true); + getChildren().insert(index, dragTarget); + layout(); + dragTarget.setHeight(1.3f * getHeight()); + dragStartX += (dragTarget.getX() - oldX); + } + } + } + + @Override + public void touchUp(InputEvent event, float x, float y, int pointer, int button) { + if (pointer != 0) return; + if (!dragging && dragTarget != null) { + if (onClickListener != null) { + onClickListener.accept(dragTarget); + } + } + dragging = false; + dragTarget = null; + } + @Override public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { + if (pointer != -1) return; if (event.getTarget() instanceof CardActor card) { - CardsGroup.this.target = card; + target = card; } } @Override public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { - if (event.getTarget() == CardsGroup.this.target) { - CardsGroup.this.target = null; + if (pointer != -1) return; + if (event.getTarget() == target) { + target = null; } } }); } - @Override - public float getMinWidth() { - return 0; - } - @Override public void act(float delta) { super.act(delta); - float speed = 10; - float offset = 100; + float offset = 0.3f * getHeight(); + float speed = 10 * offset; - for (Actor child : getChildren()) { + for (var child : getChildren()) { if (child instanceof CardActor card) { - if (card == target) { - card.offset += speed * delta; + float height = card.getHeight(); + if (child == dragTarget || dragTarget == null && child == target) { + height += speed * delta; } else { - card.offset -= speed * delta; + height -= speed * delta; } - card.offset = Math.max(0, Math.min(1, card.offset)); - card.setHeight(100 + offset * card.offset); + height = MathUtils.clamp(height, getHeight(), getHeight() + offset); + card.setHeight(height); } } } @Override public void layout() { - super.layout(); - var space = getWidth(); - for (Actor child : getChildren()) { - space -= child.getWidth(); - if (child instanceof CardActor card) { - card.baseY = card.getY(); - } + var children = getChildren(); + var count = children.size; + + float height = getHeight(); + float width = getWidth(); + cardX = new float[count]; + + cardWidth = height / CardActor.ASPECT_RATIO; + spacing = width - count * cardWidth; + spacing /= count - 1; + spacing = Math.min(spacing, TARGET_SPACING); + + float x = Math.max(0, (width - count * cardWidth - (count - 1) * TARGET_SPACING) / 2); + float y = 0; + + for (int i = 0; i < children.size; i++) { + var child = children.get(i); + child.setBounds(x, y, cardWidth, height); + cardX[i] = x; + x += cardWidth + spacing; } - space(getChildren().size > 1 ? space / (getChildren().size - 1) : 0); - super.layout(); } public void update(List cards) { - var hash = cards.hashCode(); - if (this.hash != hash) { - this.hash = hash; - this.actors = cards.stream().map(card -> new CardActor(card, atlas)).toList(); - this.clearChildren(); - this.actors.forEach(this::addActor); - this.layout(); + clearChildren(); + + cards.stream() + .map(card -> new CardActor(card, atlas)) + .forEach(this::addActor); + layout(); + } + + public CardActor remove(Card card) { + CardActor actor = null; + var children = getChildren(); + for (int i = 0; i < children.size; i++) { + if (children.get(i) instanceof CardActor cardActor && cardActor.getCard() == card) { + actor = cardActor; + break; + } + } + + if (actor == null) { + throw new NoSuchElementException(); + } + + actor.setY(getY() + actor.getHeight() - getHeight()); + var pos = localToStageCoordinates(Pools.get(Vector2.class).obtain().set(actor.getX(), actor.getY())); + actor.setHeight(getHeight()); + actor.setPosition(pos.x, pos.y); + if (target == actor) { + target = null; } + actor.remove(); + layout(); + return actor; + } + + @Override + public float getMinHeight() { + return 0; } } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/ChosenCardActor.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/ChosenCardActor.java deleted file mode 100644 index 108827a..0000000 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/ChosenCardActor.java +++ /dev/null @@ -1,33 +0,0 @@ -package eu.jonahbauer.wizard.client.libgdx.actors.game; - -import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.scenes.scene2d.Action; -import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.actions.Actions; -import eu.jonahbauer.wizard.client.libgdx.WizardGame; -import eu.jonahbauer.wizard.common.model.Card; - -public class ChosenCardActor extends Actor { - private final Card card; - private final TextureRegion texture; - private final Action toCenter; - - public ChosenCardActor(Card card, TextureRegion region) { - this.card = card; - setWidth(100); - setHeight(100); - texture = region; - toCenter = Actions.moveTo(WizardGame.WIDTH * 0.75f * 0.5f - 0.5f * getWidth(), WizardGame.HEIGHT * 0.35f, 0.5f); - this.addAction(toCenter); - } - - @Override - public void draw(Batch batch, float parentAlpha) { - batch.draw(texture, getX(), getY(), getWidth(), getHeight()); - } - - public void action() { - this.addAction(toCenter); - } -} diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/InfoTable.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/InfoTable.java deleted file mode 100644 index 19aabfe..0000000 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/InfoTable.java +++ /dev/null @@ -1,96 +0,0 @@ -package eu.jonahbauer.wizard.client.libgdx.actors.game; - -import com.badlogic.gdx.scenes.scene2d.ui.Cell; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.scenes.scene2d.ui.Table; -import eu.jonahbauer.wizard.common.model.Card; -import lombok.AccessLevel; -import lombok.Setter; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -public class InfoTable extends Table { - - private final UUID[] players; - private final Skin skin; - - @Setter(AccessLevel.MODULE) - private int round = -1; - private int playercount; //optional - private Cell cells[][]; - private static final int TABLELENGTH = 4; - private static final int PLAYERNAMES = 0; - private static final int PREDICTIONS = 1; - private static final int TRICKS = 2; - private static final int SCORES = 3; - private final String headers[] = {"Spieler", "Vorhersage", "Stiche", "Punktzahl"}; - - public InfoTable(Skin skin, UUID[] players) { - super(skin); - this.skin = skin; - this.players = players; - playercount = players.length; - cells = new Cell[TABLELENGTH][playercount]; - createHeader(); - //this.columnDefaults(1).width(5); - } - - public void createHeader() { - for (int i = 0; i < headers.length; i++) { - Label header = new Label(headers[i], skin); - //header.setWidth(5); - //header.setEllipsis(true); - add(header).padRight(5); - } - row(); - } - - public void fill(Map names, Map predictions, Map>> tricks, - Map> scores) { - - for(int i = 0; i < players.length; i++) { - //Name - cells[PLAYERNAMES][i] = add(names.get(players[i])); - ((Label) cells[PLAYERNAMES][i].getActor()).setWidth(10); - ((Label) cells[PLAYERNAMES][i].getActor()).setEllipsis(true); - - //Prediction - cells[PREDICTIONS][i] = add(String.valueOf(predictions.get(players[i]))); - ((Label) cells[PLAYERNAMES][i].getActor()).setEllipsis(true); - - //Tricks - cells[TRICKS][i] = add(String.valueOf(tricks.get(players[i]).size())); - ((Label) cells[PLAYERNAMES][i].getActor()).setEllipsis(true); - - //Scores - //TODO Rundencheck - Rundenupdate - cells[SCORES][i] = add(String.valueOf(scores.get(round).get(players[i]))); - ((Label) cells[PLAYERNAMES][i].getActor()).setEllipsis(true); - - row(); - } - } - - public void updatePrediction(Map predictions) { - for(int i = 0; i < players.length; i++) { - ((Label) cells[PREDICTIONS][i].getActor()).setText(String.valueOf(predictions.get(players[i]))); - } - } - - public void updateTricks(Map>> tricks) { - for(int i = 0; i < players.length; i++) { - ((Label) cells[TRICKS][i].getActor()).setText(String.valueOf(tricks.get(players[i]).size())); - } - } - - public void updateScores(Map> scores) { - for(int i = 0; i < players.length; i++) { - ((Label) cells[SCORES][i].getActor()).setText(String.valueOf(scores.get(round).get(players[i]))); - } - } - - //TODO - update/removePlayer -} diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/PadOfTruth.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/PadOfTruth.java new file mode 100644 index 0000000..d988f73 --- /dev/null +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/PadOfTruth.java @@ -0,0 +1,105 @@ +package eu.jonahbauer.wizard.client.libgdx.actors.game; + +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.InputListener; +import com.badlogic.gdx.scenes.scene2d.Touchable; +import com.badlogic.gdx.scenes.scene2d.actions.ScaleToAction; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.Drawable; +import com.badlogic.gdx.utils.Align; + +public class PadOfTruth extends Table { + private static final float EXTENDED_WIDTH = 636; + private static final float EXTENDED_HEIGHT = 824; + private static final float SMALL_SCALE = 0.2f; + + private final Label[] names = new Label[6]; + private final Label[][] predictions = new Label[20][]; + private final Label[][] scores = new Label[20][]; + + public PadOfTruth(Skin skin, Drawable background) { + super(skin); + setTouchable(Touchable.enabled); + setBackground(background); + + setWidth(EXTENDED_WIDTH); + setHeight(EXTENDED_HEIGHT); + + setTransform(true); + setOrigin(0, 0); + setScale(SMALL_SCALE); + + addListener(new InputListener() { + private ScaleToAction action; + + @Override + public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { + if (fromActor != null && isAscendantOf(fromActor)) return; + System.out.println("ENTER"); + if (action != null) action.finish(); + action = new ScaleToAction(); + action.setDuration(0.25f); + action.setScale(1); + addAction(action); + } + + @Override + public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { + if (toActor != null && isAscendantOf(toActor)) return; + System.out.println("EXIT"); + if (action != null) action.finish(); + action = new ScaleToAction(); + action.setDuration(0.25f); + action.setScale(SMALL_SCALE); + addAction(action); + } + }); + + setRound(false); + pad(20, 45, 25, 25); + align(Align.topLeft); + clip(); + + for (int i = 0; i < 6; i++) { + columnDefaults(2 * i).width(57f).center().pad(2, 4, 2, 4); + columnDefaults(2 * i + 1).width(22f).center().pad(2, 4, 2, 4); + } + + for (int player = 0; player < 6; player++) { + var cell = add("", "handwritten").height(46f).width(87f).colspan(2); + names[player] = cell.getActor(); + names[player].setEllipsis(true); + } + row(); + + for (int round = 0; round < 20; round++) { + int players = MathUtils.clamp(60 / (round + 1), 3, 6); + predictions[round] = new Label[players]; + scores[round] = new Label[players]; + for (int player = 0; player < players; player++) { + scores[round][player] = add("", "handwritten").height(32.5f).center().getActor(); + predictions[round][player] = add("", "handwritten").height(32.5f).center().getActor(); + + scores[round][player].setAlignment(Align.center); + predictions[round][player].setAlignment(Align.center); + } + row(); + } + } + + public void setName(int player, String name) { + names[player].setText(name); + } + + public void setScore(int player, int round, int score) { + scores[round][player].setText(String.valueOf(score)); + } + + public void setPrediction(int player, int round, int prediction) { + predictions[round][player].setText(String.valueOf(prediction)); + } +} diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/PlayedCardActor.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/PlayedCardActor.java deleted file mode 100644 index 2af48a9..0000000 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/PlayedCardActor.java +++ /dev/null @@ -1,54 +0,0 @@ -package eu.jonahbauer.wizard.client.libgdx.actors.game; - -import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.scenes.scene2d.Actor; -import eu.jonahbauer.wizard.client.libgdx.GameAtlas; -import eu.jonahbauer.wizard.client.libgdx.WizardGame; -import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen; -import eu.jonahbauer.wizard.common.model.Card; - -public class PlayedCardActor extends Actor { - private final Card playedCard; - private final TextureRegion texture; - - public PlayedCardActor(Card playedCard, TextureAtlas atlas) { - //TODO Texture zur Karte bestimmen - this.playedCard = playedCard; - this.texture = atlas.findRegion(GameAtlas.CARDS_RED); - - setWidth(100); - setHeight(100); - } - - @Override - public void setPosition(float x, float y) { - super.setPosition(x, y); - } - - public void setPositionOne() { - setPosition(WizardGame.WIDTH * GameScreen.BACKGROUND_WIDTH_PORTION * 0.25f, WizardGame.HEIGHT * 0.5f - 0.5f * getHeight()); - } - - public void setPositionTwo() { - setPosition(WizardGame.WIDTH * GameScreen.BACKGROUND_WIDTH_PORTION * 0.75f, WizardGame.HEIGHT * 0.5f - 0.5f * getHeight()); - } - - public void setPositionThree() { - setPosition(WizardGame.WIDTH * GameScreen.BACKGROUND_WIDTH_PORTION * 0.25f, WizardGame.HEIGHT * 0.7f - 0.5f * getHeight()); - } - - public void setPositionFour() { - setPosition(2 * WizardGame.WIDTH * GameScreen.BACKGROUND_WIDTH_PORTION * 0.25f, WizardGame.HEIGHT * 0.75f - 0.5f * getHeight()); - } - - public void setPositionFive() { - setPosition(3 * WizardGame.WIDTH * GameScreen.BACKGROUND_WIDTH_PORTION * 0.25f, WizardGame.HEIGHT * 0.7f - 0.5f * getHeight()); - } - - @Override - public void draw(Batch batch, float parentAlpha) { - batch.draw(texture, getX(), getY(), getWidth(), getHeight()); - } -} diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/TrumpCardActor.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/TrumpCardActor.java deleted file mode 100644 index 5a8144e..0000000 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actors/game/TrumpCardActor.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.jonahbauer.wizard.client.libgdx.actors.game; - -import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.scenes.scene2d.Actor; -import eu.jonahbauer.wizard.client.libgdx.GameAtlas; -import eu.jonahbauer.wizard.common.model.Card; - -public class TrumpCardActor extends Actor { - private final Card trumpCard; - private final TextureRegion texture; - - public TrumpCardActor(Card trumpCard, TextureAtlas atlas) { - //TODO Texture zur Karte bestimmen - this.trumpCard = trumpCard; - this.texture = atlas.findRegion(GameAtlas.CARDS_RED); - - setWidth(200); - setHeight(200); - } - - @Override - public void draw(Batch batch, float parentAlpha) { - batch.draw(texture, getX(), getY(), getWidth(), getHeight()); - } -} diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java index 04e4095..ee16f1d 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java @@ -61,7 +61,4 @@ public class ConnectScreen extends MenuScreen { buttonBack.addListener(listener); buttonConnect.addListener(listener); } - - @Override - protected void renderInternal(float delta) {} } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java index d2152bc..0dffc5b 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java @@ -77,7 +77,4 @@ public class CreateGameScreen extends MenuScreen { backButton.addListener(listener); continueButton.addListener(listener); } - - @Override - protected void renderInternal(float delta) {} } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java index 339d75d..59c0be6 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java @@ -1,19 +1,17 @@ package eu.jonahbauer.wizard.client.libgdx.screens; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.Screen; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.scenes.scene2d.InputEvent; -import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.Container; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.badlogic.gdx.utils.viewport.ExtendViewport; -import com.badlogic.gdx.utils.viewport.FitViewport; +import com.badlogic.gdx.math.Interpolation; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.ui.*; +import com.badlogic.gdx.scenes.scene2d.ui.Stack; +import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; +import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; +import com.badlogic.gdx.utils.Align; import eu.jonahbauer.wizard.client.libgdx.GameAtlas; +import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas; import eu.jonahbauer.wizard.client.libgdx.WizardGame; import eu.jonahbauer.wizard.client.libgdx.actors.game.*; import eu.jonahbauer.wizard.client.libgdx.util.Pair; @@ -21,271 +19,355 @@ import eu.jonahbauer.wizard.common.messages.observer.*; import eu.jonahbauer.wizard.common.messages.server.GameMessage; import eu.jonahbauer.wizard.common.messages.server.ServerMessage; import eu.jonahbauer.wizard.common.model.Card; +import lombok.Getter; import java.util.*; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; -public class GameScreen implements Screen { +import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*; + +public class GameScreen extends MenuScreen { private final WizardGame game; - private ExtendViewport extendViewport; - private FitViewport viewport; - private Stage stage; - private Skin skin; private TextureAtlas atlas; private TextureRegion background; - public static final float BACKGROUND_WIDTH_PORTION = 0.7f; - - private final UUID[] players; - //wahrscheinlich eine Map für Sitzpositionen einfügen - private final Map seats = new HashMap<>(); + private final List players; private final UUID self; private final UUID session; private final Map names; private final Map> scores = new HashMap<>(); - private int round = - 1; + private int round = -1; private final Map> hands = new HashMap<>(); private final Map predictions = new HashMap<>(); private final Map>> tricks = new HashMap<>(); private Card.Suit trumpSuit; private Card trumpCard; - private Label[] playerNames; - private int trick; + private int trick = -1; private final List> stack = new ArrayList<>(); private Pair activePlayer; - private ChosenCardActor chosenCardActor; - - ClickListener clickListener = new ClickListener() { - //TODO - Fehler bei Click auf Objekt während der Bewegung - Behebung durch Entfernung des Click-Listeners - @Override - public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); - var target = event.getTarget(); - if(target instanceof CardActor cardTarget) { - chosenCardActor = new ChosenCardActor(cardTarget.getCard(), cardTarget.getTexture()); - //TODO falsche Koordinaten - chosenCardActor.setPosition(cardTarget.getX(), cardTarget.getParent().getY()); - stage.addActor(chosenCardActor); - target.remove(); - //Todo Message - Server-Antwort abwarten - moveMethode in chosenCardActor aufrufen - } - } - }; + private CardsGroup handCards; + private CardStack cardStack; + private PadOfTruth padOfTruth; + private CardActor trumpCardActor; + private Map seats = new HashMap<>(); + private Map nameLabels = new HashMap<>(); public GameScreen(WizardGame game) { + this(game, null); + } + + public GameScreen(WizardGame game, Data data) { + super(game, data); this.game = game; - int playerCount = 6; + // this.session = UUID.randomUUID(); - this.players = new UUID[playerCount]; this.names = new HashMap<>(); - HashMap score = new HashMap(); + int playerCount = 6; + var players = new UUID[playerCount]; for (int i = 0; i < playerCount; i++) { players[i] = UUID.randomUUID(); - names.put(players[i], "Player " + (i + 1)); - - predictions.put(players[i], i + 5); - score.put(players[i], i); + names.put(players[i], "Player " + i); } - scores.put(round, score); this.self = players[0]; - - ArrayList> trickList = new ArrayList<>(); - ArrayList trick = new ArrayList(); - trick.add(Card.BLUE_3); - trick.add(Card.YELLOW_1); - trick.add(Card.GREEN_1); - trick.add(Card.RED_5); - trickList.add(trick); - trickList.add(trick); - trickList.add(trick); - - for(int i = 0; i < playerCount; i++) { - tricks.put(players[i], trickList); - var cards = new ArrayList(20); - for(int j = 0; j < 20; j++) { - cards.add(Arrays.stream(Card.values()).toList().get(j)); - } - hands.put(players[i], cards); - } - - //List> stack - stack.add(new Pair<>(players[0], Card.BLUE_11)); - stack.add(new Pair<>(players[1], Card.RED_1)); - stack.add(new Pair<>(players[2], Card.YELLOW_11)); - stack.add(new Pair<>(players[3], Card.BLUE_10)); - stack.add(new Pair<>(players[4], Card.BLUE_9)); - stack.add(new Pair<>(players[5], Card.BLUE_8)); - - determineSeats(players); + this.players = Stream.of(players).sorted().toList(); + // } @Override public void show() { - viewport = new FitViewport(WizardGame.WIDTH, WizardGame.HEIGHT); - extendViewport = new ExtendViewport(WizardGame.WIDTH, WizardGame.HEIGHT); - stage = new Stage(viewport); - skin = new Skin(Gdx.files.internal("uiskin.json")); + super.show(); atlas = new TextureAtlas(Gdx.files.internal(GameAtlas.$PATH)); background = atlas.findRegion(GameAtlas.BACKGROUND); - this.stage.addListener(clickListener); + seat(); + prepareLabels(); - var container = new Container<>(new CardsGroup(hands.get(players[0]), atlas).wrap(false).grow()); - container.setPosition(100, 75); - container.setSize(1200, 200); + handCards = new CardsGroup(Collections.emptyList(), atlas); + handCards.setOnClickListener(card -> playCard(self, card.getCard())); + var container = new Container<>(handCards); + container.setPosition(360, 75); + container.setSize(1200, 210); container.fillX(); - InfoTable infoTable = new InfoTable(skin, players); - infoTable.fill(names, predictions, tricks, scores); - infoTable.setPosition(WizardGame.WIDTH * 0.85f, WizardGame.HEIGHT * 0.8f); - - trumpCard = Card.BLUE_1; - TrumpCardActor trumpCardActor = new TrumpCardActor(trumpCard, atlas); - trumpCardActor.setPosition(WizardGame.WIDTH * 0.85f, WizardGame.HEIGHT * 0.1f); + padOfTruth = new PadOfTruth(data.skin, new TextureRegionDrawable(atlas.findRegion(GameAtlas.PAD_OF_TRUTH))); + padOfTruth.setPosition(1910 - 636f, 10); + padOfTruth.setOrigin(636f, 0); - this.stage.addListener(clickListener); + cardStack = new CardStack(); - createLabels(); - cardPlayed(stack); + setNames(); - Gdx.input.setInputProcessor(stage); - - stage.addActor(container); - stage.addActor(infoTable); - stage.addActor(trumpCardActor); - - stage.setDebugAll(true); + var trump = new TextButton("Trump", data.skin); + trump.align(Align.left); + trump.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + setTrumpCard(Card.values()[(int)(Math.random() * Card.values().length)]); + } + }); + + var playCard = new TextButton("Play Card", data.skin); + playCard.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + var hand = hands.get(self); + if (hand != null && hand.size() > 0) { + playCard(self, hand.get((int) (Math.random() * hand.size()))); + } + } + }); + + var deal = new TextButton("Deal", data.skin); + deal.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + var hand = Stream.of(Card.values()).limit(20).toList(); + setHand(self, hand); + } + }); + + var round = new TextButton("Round", data.skin); + round.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + startRound(); + round.setText("Round " + GameScreen.this.round); + } + }); + + var scores = new TextButton("Scores", data.skin); + scores.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + var scores = players.stream().collect(Collectors.toMap(p -> p, p -> (int) (Math.random() * 5) * 10)); + addScores(scores); + } + }); + + var predictions = new TextButton("Predictions", data.skin); + predictions.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + var predictions = players.stream().collect(Collectors.toMap(p -> p, p -> (int) (Math.random() * 5))); + predictions.forEach((player, prediction) -> addPrediction(player, prediction)); + } + }); + + var playOtherCard = new TextButton("Play Other Card", data.skin); + playOtherCard.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + var card = Card.values()[(int) (Math.random() * Card.values().length)]; + UUID player; + do { + player = players.get((int) (Math.random() * players.size())); + } while (player.equals(self)); + playCard(player, card); + } + }); + + var buttons = new VerticalGroup(); + buttons.top().left().columnLeft().setPosition(0, WizardGame.HEIGHT - buttons.getHeight()); + buttons.addActor(round); + buttons.addActor(deal); + buttons.addActor(trump); + buttons.addActor(predictions); + buttons.addActor(playCard); + buttons.addActor(playOtherCard); + buttons.addActor(scores); + + Gdx.input.setInputProcessor(data.stage); + data.stage.addActor(container); + data.stage.addActor(cardStack); + data.stage.addActor(padOfTruth); + data.stage.addActor(buttons); } @Override - public void render(float delta) { - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - - //viewport.apply(true); - extendViewport.apply(true); - game.batch.setProjectionMatrix(extendViewport.getCamera().combined); - game.batch.begin(); + protected void renderBackground(float delta) { float scale = Math.max( - extendViewport.getWorldWidth() / WizardGame.WIDTH, - extendViewport.getWorldHeight() / WizardGame.HEIGHT + data.extendViewport.getWorldWidth() / WizardGame.WIDTH, + data.extendViewport.getWorldHeight() / WizardGame.HEIGHT + ); + game.batch.draw(data.background, 0,0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT); + game.batch.setColor(1, 1, 1, 0.25f); + game.batch.draw( + data.title, + (data.extendViewport.getWorldWidth() - data.title.getRegionWidth() * 0.75f) / 2f, + (data.extendViewport.getWorldHeight() - data.title.getRegionHeight() * 0.75f) / 2f, + 0.75f * data.title.getRegionWidth(), + 0.75f * data.title.getRegionHeight() ); - game.batch.draw(background, 0,0, scale * WizardGame.WIDTH * BACKGROUND_WIDTH_PORTION, scale * WizardGame.HEIGHT); - game.batch.end(); - - stage.act(delta); - stage.draw(); } @Override - public void resize(int width, int height) { - extendViewport.update(width, height); - viewport.update(width, height); + protected void renderForeground(float delta) {} + + private void seat() { + var count = players.size(); + Seat[] seats = switch (count) { + case 3 -> new Seat[] {Seat.TOP_LEFT, Seat.TOP_RIGHT}; + case 4 -> new Seat[] {Seat.LEFT, Seat.TOP, Seat.RIGHT}; + case 5 -> new Seat[] {Seat.LEFT, Seat.TOP_LEFT, Seat.TOP_RIGHT, Seat.RIGHT}; + case 6 -> new Seat[] {Seat.LEFT, Seat.TOP_LEFT, Seat.TOP, Seat.TOP_RIGHT, Seat.RIGHT}; + default -> throw new AssertionError(); + }; + int index = players.indexOf(self); + for (int i = 1; i < count; i++) { + var player = players.get((index + i) % count); + var seat = seats[i - 1]; + this.seats.put(player, seat); + } } - @Override - public void pause() {} + private void prepareLabels() { + for (UUID player : players) { + if (player.equals(self)) continue; + var label = new Label("", data.skin); + var seat = seats.get(player); + label.setX(seat.getLabelX()); + label.setY(seat.getLabelY()); + label.setAlignment(seat.getLabelAlign()); + this.nameLabels.put(player, label); + data.stage.addActor(label); + } + } - @Override - public void resume() {} + private void setNames() { + for (int i = 0; i < players.size(); i++) { + var player = players.get(i); + var name = names.get(player); + padOfTruth.setName(i, name); + if (!self.equals(player)) { + nameLabels.get(player).setText(name); + } + } + } - @Override - public void hide() {} + private void startRound() { + round++; + hands.clear(); + tricks.clear(); + predictions.clear(); + trumpSuit = null; + trumpCard = null; + handCards.clearChildren(); + cardStack.clearChildren(); + if (trumpCardActor != null) { + trumpCardActor.remove(); + } + } - @Override - public void dispose() { - if (stage != null) stage.dispose(); - if (atlas != null) atlas.dispose(); - if (skin != null) skin.dispose(); + private void setHand(UUID player, List cards) { + var hand = hands.computeIfAbsent(player, p -> new ArrayList<>()); + hand.clear(); + hand.addAll(cards); + + handCards.update(hand); } - private void createLabels() { - //TODO ggf. Labels für Vorhersage und Stichanzahl einbauen - playerNames = new Label[players.length]; - int count = 0; - for(int i = 0; i < players.length; i++) { - playerNames[i] = new Label(names.get(players[i]), skin); - if(players[i] != self) { - switch (count) { - case 0 -> { - playerNames[i].setPosition(10, WizardGame.HEIGHT * 0.5f - 0.5f * playerNames[i].getHeight()); - stage.addActor(playerNames[i]); - } - case 1 -> { - playerNames[i].setPosition(WizardGame.WIDTH * BACKGROUND_WIDTH_PORTION - playerNames[i].getWidth() - 10, WizardGame.HEIGHT * 0.5f - 0.5f * playerNames[i].getHeight()); - stage.addActor(playerNames[i]); - } - case 2 -> { - playerNames[i].setPosition(WizardGame.WIDTH * BACKGROUND_WIDTH_PORTION / (players.length - 2) - playerNames[i].getWidth() * 0.5f, WizardGame.HEIGHT * 0.8f - 0.5f * playerNames[i].getHeight()); - stage.addActor(playerNames[i]); - } - case 3 -> { - playerNames[i].setPosition(2 * WizardGame.WIDTH * BACKGROUND_WIDTH_PORTION / (players.length - 2) - playerNames[i].getWidth() * 0.5f, WizardGame.HEIGHT * 0.85f - 0.5f * playerNames[i].getHeight()); - stage.addActor(playerNames[i]); - } - case 4 -> { - playerNames[i].setPosition(3 * WizardGame.WIDTH * BACKGROUND_WIDTH_PORTION / (players.length - 2) - playerNames[i].getWidth() * 0.5f, WizardGame.HEIGHT * 0.8f - 0.5f * playerNames[i].getHeight()); - stage.addActor(playerNames[i]); - } - default -> throw new IllegalArgumentException(); - } - count++; - } - else { - playerNames[i].setPosition(WizardGame.WIDTH * 0.35f - 0.5f * playerNames[i].getWidth(), WizardGame.HEIGHT * 0.05f); - stage.addActor(playerNames[i]); - } + private void setTrumpCard(Card trumpCard) { + this.trumpCard = trumpCard; + if (trumpCardActor != null) { + trumpCardActor.remove(); } - } - private void cardPlayed(List> stack) { - while(stack.size() > 0) { - Pair pair = stack.get(stack.size() - 1); - if(pair.first() == self) { - //TODO Action - //chosenCardActor.action() - stack.remove(pair); - } - else { - for(UUID player : players) { - if(player == pair.first()) { - drawPlayedCard(seats.get(player), pair.second()); - stack.remove(pair); - } - } - } + if (trumpCard == null) return; + + if (trumpCardActor != null) { + trumpCardActor.setCard(trumpCard); + } else { + trumpCardActor = new CardActor(trumpCard, atlas); } + + var background = new Container<>(); + background.setBackground(new TextureRegionDrawable(data.uiskinAtlas.findRegion(UiskinAtlas.WHITE))); + background.setColor(0.0f, 0.0f, 0.0f, 0.5f); + background.setFillParent(true); + + var screen = new Stack(); + screen.setFillParent(true); + screen.add(background); + + var group = new VerticalGroup().align(Align.center); + screen.add(group); + + var label = new Label("Determining trump", data.skin); + label.setFontScale(1.5f); + group.addActor(label); + group.addActor(trumpCardActor); + + data.stage.addAction(sequence( + run(() -> data.stage.addActor(screen)), + delay(5.0f), + removeActor(label), + addAction(moveTo(10,10, .25f), trumpCardActor), + delay(.25f), + addAction(alpha(0.0f, .1f, Interpolation.pow2Out), background), + delay(.1f), + run(() -> data.stage.addActor(trumpCardActor)), + removeActor(screen) + )); + } + + private void addPrediction(UUID player, int prediction) { + predictions.put(player, prediction); + padOfTruth.setPrediction(players.indexOf(player), round, prediction); } - private void drawPlayedCard(int pos, Card card) { - PlayedCardActor playedCardActor = new PlayedCardActor(card, atlas); - switch (pos) { - case 1 -> playedCardActor.setPositionOne(); - case 2 -> playedCardActor.setPositionTwo(); - case 3 -> playedCardActor.setPositionThree(); - case 4 -> playedCardActor.setPositionFour(); - case 5 -> playedCardActor.setPositionFive(); + private void playCard(UUID player, Card card) { + var handCard = switch (card) { + case CHANGELING_JESTER, CHANGELING_WIZARD -> Card.CHANGELING; + case CLOUD_BLUE, CLOUD_RED, CLOUD_GREEN, CLOUD_YELLOW -> Card.CLOUD; + case JUGGLER_BLUE, JUGGLER_RED, JUGGLER_GREEN, JUGGLER_YELLOW -> Card.JUGGLER; + default -> card; + }; + + if (hands.containsKey(player)) { + hands.get(player).remove(handCard); + } + stack.add(Pair.of(player, card)); + + CardActor actor; + Seat seat; + if (player.equals(self)) { + actor = handCards.remove(handCard); + seat = Seat.BOTTOM; + } else { + actor = new CardActor(card, atlas); + seat = seats.get(player); + actor.setPosition(seat.getX() - actor.getWidth() / 2, seat.getY() - actor.getHeight() / 2); + actor.setRotation(seat.getAngle()); } - stage.addActor(playedCardActor); + actor.setOrigin(actor.getWidth() / 2, actor.getHeight() / 2); + cardStack.add(seat, actor); } - private void determineSeats(UUID[] players) { - for(int i = 0; i < players.length; i++) { - if(self == players[i]) { - seats.put(self, 0); - } - else { - seats.put(players[i], i); - } + private void addScores(Map scores) { + this.scores.put(round, scores); + + for (int i = 0; i < players.size(); i++) { + UUID player = players.get(i); + padOfTruth.setScore(i, round, scores.get(player)); } } + @Override + public void dispose() { + super.dispose(); + if (atlas != null) atlas.dispose(); + } + public void onMessage(ServerMessage serverMessage) { if (serverMessage instanceof GameMessage gameMessage) { var observerMessage = gameMessage.getObserverMessage(); @@ -336,4 +418,37 @@ public class GameScreen implements Screen { } } } + + @Getter + public enum Seat { + BOTTOM(WizardGame.WIDTH * 0.5f, 0, 0, 0, Align.bottom, WizardGame.WIDTH * 0.5f, 300), + LEFT(0, WizardGame.HEIGHT * 0.5f, 50, WizardGame.HEIGHT * 0.5f + 110f, Align.bottomLeft, 117.5f, WizardGame.HEIGHT * 0.5f), + RIGHT(WizardGame.WIDTH, WizardGame.HEIGHT * 0.5f, WizardGame.WIDTH - 50, WizardGame.HEIGHT * 0.5f + 110f, Align.bottomRight, WizardGame.WIDTH - 117.5f, WizardGame.HEIGHT * 0.5f), + TOP_LEFT(WizardGame.WIDTH * 0.25f, WizardGame.HEIGHT, WizardGame.WIDTH * 0.25f, WizardGame.HEIGHT - 50, Align.top, WizardGame.WIDTH * 0.25f, WizardGame.HEIGHT - 200), + TOP(WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT, WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT - 50, Align.top, WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT - 200), + TOP_RIGHT(WizardGame.WIDTH * 0.75f, WizardGame.HEIGHT, WizardGame.WIDTH * 0.75f, WizardGame.HEIGHT - 50, Align.top, WizardGame.WIDTH * 0.75f, WizardGame.HEIGHT - 200); + + private final float x; + private final float y; + private final float labelX; + private final float labelY; + private final int labelAlign; + private final float angle; + private final float cardX; + private final float cardY; + + Seat(float x, float y, float labelX, float labelY, int labelAlign, float cardX, float cardY) { + this.x = x; + this.y = y; + this.labelX = labelX; + this.labelY = labelY; + this.labelAlign = labelAlign; + this.cardX = cardX; + this.cardY = cardY; + + var deltaX = WizardGame.WIDTH * 0.5f - x; + var deltaY = WizardGame.HEIGHT * 0.5f - y; + this.angle = (float) Math.toDegrees(Math.atan2(deltaY, deltaX) + Math.PI / 2); + } + } } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java index fbe905e..7520a31 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java @@ -106,9 +106,6 @@ public class LobbyScreen extends MenuScreen { ); } - @Override - protected void renderInternal(float delta) {} - public void addSessions(SessionData...sessions) { for (SessionData session : sessions) { this.sessions.getItems().add(session); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java index 9e62551..31df2ec 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java @@ -51,7 +51,8 @@ public class MainMenuScreen extends MenuScreen { } @Override - protected void renderInternal(float delta) { + protected void renderForeground(float delta) { + super.renderForeground(delta); int width = 160, height = 224; int left = 384, right = 384, top = 384, bottom = 192; this.game.batch.draw(data.symbols[0], left, bottom, width, height); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java index 0f0fb89..7a25215 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java @@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.utils.viewport.ExtendViewport; @@ -98,25 +97,9 @@ public abstract class MenuScreen implements Screen { } else { data.reset(); } + if (WizardGame.DEBUG) { data.stage.setDebugAll(true); - data.stage.addListener(event -> { - if (!(event instanceof InputEvent input) || input.getType() == InputEvent.Type.mouseMoved) return false; - - var actor = event.getTarget(); - if (actor != null) { - System.out.printf( - "%s(name=%s, x=%f, y=%f, width=%f, height=%f)%n", - actor.getClass().getSimpleName(), - actor.getName(), - actor.getX(), - actor.getY(), - actor.getWidth(), - actor.getHeight() - ); - } - return false; - }); } } @@ -127,6 +110,20 @@ public abstract class MenuScreen implements Screen { data.extendViewport.apply(true); game.batch.setProjectionMatrix(data.extendViewport.getCamera().combined); game.batch.begin(); + renderBackground(delta); + game.batch.end(); + + data.fitViewport.apply(); + game.batch.setProjectionMatrix(data.fitViewport.getCamera().combined); + game.batch.begin(); + renderForeground(delta); + game.batch.end(); + + data.stage.act(delta); + data.stage.draw(); + } + + protected void renderBackground(float delta) { float scale = Math.max( data.extendViewport.getWorldWidth() / WizardGame.WIDTH, data.extendViewport.getWorldHeight() / WizardGame.HEIGHT @@ -136,21 +133,12 @@ public abstract class MenuScreen implements Screen { game.batch.draw(data.corners[1], 0, 0); game.batch.draw(data.corners[2], data.extendViewport.getWorldWidth() - data.corners[2].getRegionWidth(), 0); game.batch.draw(data.corners[3], data.extendViewport.getWorldWidth() - data.corners[3].getRegionWidth(), data.extendViewport.getWorldHeight() - data.corners[3].getRegionHeight()); - game.batch.end(); + } - data.fitViewport.apply(); - game.batch.setProjectionMatrix(data.fitViewport.getCamera().combined); - game.batch.begin(); + protected void renderForeground(float delta) { game.batch.draw(data.title, 555, WizardGame.HEIGHT - 192 - 96, 810, 192); - renderInternal(delta); - game.batch.end(); - - data.stage.act(delta); - data.stage.draw(); } - protected abstract void renderInternal(float delta); - @Override public final void resize(int width, int height) { data.extendViewport.update(width, height); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java index 1bdb5be..155f49d 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java @@ -93,9 +93,6 @@ public class WaitingScreen extends MenuScreen { buttonReady.setText(game.messages.get(ready ? "menu.waiting.not_ready" : "menu.waiting.ready")); } - @Override - protected void renderInternal(float delta) {} - private Table createInfoTable() { float infoTableWidth = 0.3f * WizardGame.WIDTH - 20; diff --git a/wizard-client/wizard-client-libgdx/core/src/main/resources/font/handwritten.fnt b/wizard-client/wizard-client-libgdx/core/src/main/resources/font/handwritten.fnt new file mode 100644 index 0000000..14c30ba --- /dev/null +++ b/wizard-client/wizard-client-libgdx/core/src/main/resources/font/handwritten.fnt @@ -0,0 +1,201 @@ +info face="Romantick" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2 +common lineHeight=40 base=26 scaleW=256 scaleH=256 pages=1 packed=0 +page id=0 file="handwritten.png" +chars count=195 +char id=0 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=0 page=0 chnl=0 +char id=13 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=0 page=0 chnl=0 +char id=33 x=251 y=0 width=4 height=23 xoffset=-1 yoffset=6 xadvance=3 page=0 chnl=0 +char id=34 x=214 y=160 width=7 height=8 xoffset=0 yoffset=6 xadvance=7 page=0 chnl=0 +char id=35 x=97 y=140 width=10 height=18 xoffset=-1 yoffset=11 xadvance=10 page=0 chnl=0 +char id=36 x=30 y=117 width=7 height=22 xoffset=-1 yoffset=8 xadvance=7 page=0 chnl=0 +char id=37 x=37 y=117 width=9 height=22 xoffset=0 yoffset=8 xadvance=9 page=0 chnl=0 +char id=38 x=196 y=117 width=11 height=20 xoffset=-1 yoffset=9 xadvance=9 page=0 chnl=0 +char id=39 x=234 y=160 width=6 height=7 xoffset=-1 yoffset=7 xadvance=4 page=0 chnl=0 +char id=40 x=193 y=91 width=6 height=23 xoffset=0 yoffset=6 xadvance=6 page=0 chnl=0 +char id=41 x=199 y=91 width=6 height=23 xoffset=0 yoffset=6 xadvance=6 page=0 chnl=0 +char id=42 x=151 y=160 width=7 height=11 xoffset=0 yoffset=8 xadvance=7 page=0 chnl=0 +char id=43 x=186 y=160 width=9 height=10 xoffset=0 yoffset=13 xadvance=9 page=0 chnl=0 +char id=44 x=240 y=160 width=7 height=7 xoffset=-1 yoffset=23 xadvance=5 page=0 chnl=0 +char id=45 x=69 y=176 width=9 height=4 xoffset=-1 yoffset=20 xadvance=8 page=0 chnl=0 +char id=46 x=51 y=176 width=5 height=5 xoffset=-1 yoffset=23 xadvance=4 page=0 chnl=0 +char id=47 x=72 y=91 width=12 height=24 xoffset=-2 yoffset=5 xadvance=8 page=0 chnl=0 +char id=48 x=207 y=117 width=9 height=20 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 +char id=49 x=107 y=117 width=4 height=21 xoffset=0 yoffset=7 xadvance=4 page=0 chnl=0 +char id=50 x=111 y=117 width=9 height=21 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 +char id=51 x=205 y=91 width=8 height=23 xoffset=0 yoffset=6 xadvance=7 page=0 chnl=0 +char id=52 x=46 y=117 width=10 height=22 xoffset=-1 yoffset=7 xadvance=8 page=0 chnl=0 +char id=53 x=56 y=117 width=9 height=22 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 +char id=54 x=65 y=117 width=9 height=22 xoffset=0 yoffset=6 xadvance=8 page=0 chnl=0 +char id=55 x=213 y=91 width=8 height=23 xoffset=-1 yoffset=7 xadvance=7 page=0 chnl=0 +char id=56 x=120 y=117 width=9 height=21 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 +char id=57 x=74 y=117 width=7 height=22 xoffset=0 yoffset=6 xadvance=7 page=0 chnl=0 +char id=58 x=195 y=160 width=5 height=10 xoffset=-1 yoffset=18 xadvance=4 page=0 chnl=0 +char id=59 x=113 y=160 width=6 height=12 xoffset=-1 yoffset=18 xadvance=4 page=0 chnl=0 +char id=60 x=86 y=160 width=10 height=13 xoffset=-1 yoffset=10 xadvance=8 page=0 chnl=0 +char id=61 x=0 y=176 width=10 height=7 xoffset=-1 yoffset=15 xadvance=9 page=0 chnl=0 +char id=62 x=96 y=160 width=10 height=13 xoffset=-1 yoffset=9 xadvance=8 page=0 chnl=0 +char id=63 x=129 y=117 width=8 height=21 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 +char id=64 x=194 y=140 width=10 height=16 xoffset=0 yoffset=12 xadvance=10 page=0 chnl=0 +char id=65 x=121 y=64 width=16 height=26 xoffset=-2 yoffset=6 xadvance=12 page=0 chnl=0 +char id=66 x=137 y=64 width=14 height=26 xoffset=-1 yoffset=5 xadvance=13 page=0 chnl=0 +char id=67 x=177 y=34 width=12 height=28 xoffset=0 yoffset=6 xadvance=11 page=0 chnl=0 +char id=68 x=151 y=64 width=14 height=26 xoffset=-1 yoffset=6 xadvance=13 page=0 chnl=0 +char id=69 x=225 y=34 width=10 height=27 xoffset=-1 yoffset=5 xadvance=9 page=0 chnl=0 +char id=70 x=165 y=64 width=20 height=26 xoffset=-1 yoffset=6 xadvance=11 page=0 chnl=0 +char id=71 x=235 y=34 width=16 height=27 xoffset=0 yoffset=5 xadvance=10 page=0 chnl=0 +char id=72 x=127 y=0 width=19 height=31 xoffset=-1 yoffset=4 xadvance=16 page=0 chnl=0 +char id=73 x=0 y=64 width=12 height=27 xoffset=-1 yoffset=7 xadvance=9 page=0 chnl=0 +char id=74 x=12 y=64 width=12 height=27 xoffset=-1 yoffset=7 xadvance=10 page=0 chnl=0 +char id=75 x=189 y=34 width=13 height=28 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 +char id=76 x=185 y=64 width=15 height=26 xoffset=0 yoffset=6 xadvance=6 page=0 chnl=0 +char id=77 x=24 y=64 width=12 height=27 xoffset=-1 yoffset=6 xadvance=11 page=0 chnl=0 +char id=78 x=84 y=91 width=17 height=24 xoffset=0 yoffset=7 xadvance=13 page=0 chnl=0 +char id=79 x=36 y=64 width=11 height=27 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 +char id=80 x=200 y=64 width=12 height=26 xoffset=-1 yoffset=6 xadvance=11 page=0 chnl=0 +char id=81 x=146 y=0 width=13 height=31 xoffset=0 yoffset=6 xadvance=12 page=0 chnl=0 +char id=82 x=47 y=64 width=14 height=27 xoffset=-1 yoffset=5 xadvance=13 page=0 chnl=0 +char id=83 x=212 y=64 width=9 height=26 xoffset=0 yoffset=5 xadvance=8 page=0 chnl=0 +char id=84 x=221 y=64 width=33 height=26 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 +char id=85 x=202 y=34 width=10 height=28 xoffset=-1 yoffset=5 xadvance=9 page=0 chnl=0 +char id=86 x=61 y=64 width=12 height=27 xoffset=-1 yoffset=5 xadvance=9 page=0 chnl=0 +char id=87 x=73 y=64 width=13 height=27 xoffset=0 yoffset=5 xadvance=13 page=0 chnl=0 +char id=88 x=212 y=34 width=13 height=28 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0 +char id=89 x=0 y=34 width=8 height=30 xoffset=0 yoffset=5 xadvance=9 page=0 chnl=0 +char id=90 x=25 y=91 width=13 height=25 xoffset=-1 yoffset=6 xadvance=9 page=0 chnl=0 +char id=91 x=221 y=91 width=8 height=23 xoffset=-1 yoffset=6 xadvance=6 page=0 chnl=0 +char id=92 x=101 y=91 width=12 height=24 xoffset=-2 yoffset=5 xadvance=8 page=0 chnl=0 +char id=93 x=81 y=117 width=6 height=22 xoffset=0 yoffset=6 xadvance=6 page=0 chnl=0 +char id=94 x=119 y=160 width=8 height=12 xoffset=-1 yoffset=5 xadvance=7 page=0 chnl=0 +char id=95 x=78 y=176 width=13 height=4 xoffset=-1 yoffset=26 xadvance=12 page=0 chnl=0 +char id=96 x=91 y=176 width=7 height=4 xoffset=-1 yoffset=10 xadvance=5 page=0 chnl=0 +char id=97 x=56 y=160 width=7 height=14 xoffset=0 yoffset=14 xadvance=6 page=0 chnl=0 +char id=98 x=86 y=64 width=8 height=27 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 +char id=99 x=168 y=140 width=8 height=17 xoffset=0 yoffset=12 xadvance=7 page=0 chnl=0 +char id=100 x=113 y=91 width=8 height=24 xoffset=0 yoffset=6 xadvance=8 page=0 chnl=0 +char id=101 x=204 y=140 width=8 height=16 xoffset=-1 yoffset=14 xadvance=7 page=0 chnl=0 +char id=102 x=159 y=0 width=12 height=31 xoffset=-1 yoffset=4 xadvance=11 page=0 chnl=0 +char id=103 x=229 y=91 width=17 height=23 xoffset=-6 yoffset=14 xadvance=7 page=0 chnl=0 +char id=104 x=246 y=91 width=8 height=23 xoffset=-1 yoffset=6 xadvance=7 page=0 chnl=0 +char id=105 x=32 y=160 width=5 height=15 xoffset=-1 yoffset=11 xadvance=4 page=0 chnl=0 +char id=106 x=171 y=34 width=6 height=29 xoffset=-2 yoffset=7 xadvance=4 page=0 chnl=0 +char id=107 x=38 y=91 width=9 height=25 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=0 +char id=108 x=94 y=64 width=7 height=27 xoffset=-1 yoffset=5 xadvance=5 page=0 chnl=0 +char id=109 x=216 y=117 width=12 height=20 xoffset=0 yoffset=11 xadvance=13 page=0 chnl=0 +char id=110 x=212 y=140 width=10 height=16 xoffset=-1 yoffset=14 xadvance=8 page=0 chnl=0 +char id=111 x=106 y=160 width=7 height=13 xoffset=0 yoffset=16 xadvance=6 page=0 chnl=0 +char id=112 x=87 y=117 width=7 height=22 xoffset=0 yoffset=14 xadvance=8 page=0 chnl=0 +char id=113 x=121 y=91 width=8 height=24 xoffset=0 yoffset=13 xadvance=7 page=0 chnl=0 +char id=114 x=222 y=140 width=8 height=16 xoffset=0 yoffset=13 xadvance=7 page=0 chnl=0 +char id=115 x=107 y=140 width=8 height=18 xoffset=-1 yoffset=12 xadvance=6 page=0 chnl=0 +char id=116 x=0 y=117 width=9 height=23 xoffset=-2 yoffset=7 xadvance=7 page=0 chnl=0 +char id=117 x=115 y=140 width=9 height=18 xoffset=-1 yoffset=13 xadvance=7 page=0 chnl=0 +char id=118 x=124 y=140 width=8 height=18 xoffset=-1 yoffset=12 xadvance=6 page=0 chnl=0 +char id=119 x=230 y=140 width=10 height=16 xoffset=0 yoffset=12 xadvance=9 page=0 chnl=0 +char id=120 x=158 y=160 width=10 height=11 xoffset=-1 yoffset=17 xadvance=7 page=0 chnl=0 +char id=121 x=101 y=64 width=11 height=27 xoffset=-1 yoffset=13 xadvance=9 page=0 chnl=0 +char id=122 x=63 y=160 width=8 height=14 xoffset=0 yoffset=15 xadvance=8 page=0 chnl=0 +char id=123 x=129 y=91 width=7 height=24 xoffset=0 yoffset=5 xadvance=7 page=0 chnl=0 +char id=124 x=251 y=34 width=3 height=24 xoffset=0 yoffset=5 xadvance=3 page=0 chnl=0 +char id=125 x=136 y=91 width=7 height=24 xoffset=-1 yoffset=5 xadvance=6 page=0 chnl=0 +char id=126 x=200 y=160 width=10 height=10 xoffset=0 yoffset=13 xadvance=9 page=0 chnl=0 +char id=160 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=4 page=0 chnl=0 +char id=161 x=9 y=117 width=4 height=23 xoffset=0 yoffset=14 xadvance=3 page=0 chnl=0 +char id=162 x=71 y=160 width=8 height=14 xoffset=0 yoffset=12 xadvance=8 page=0 chnl=0 +char id=163 x=26 y=140 width=9 height=19 xoffset=0 yoffset=8 xadvance=9 page=0 chnl=0 +char id=165 x=132 y=140 width=8 height=18 xoffset=0 yoffset=9 xadvance=8 page=0 chnl=0 +char id=166 x=94 y=117 width=4 height=22 xoffset=0 yoffset=7 xadvance=4 page=0 chnl=0 +char id=168 x=98 y=176 width=7 height=4 xoffset=0 yoffset=10 xadvance=6 page=0 chnl=0 +char id=169 x=240 y=140 width=12 height=16 xoffset=0 yoffset=10 xadvance=12 page=0 chnl=0 +char id=171 x=127 y=160 width=12 height=12 xoffset=-1 yoffset=15 xadvance=10 page=0 chnl=0 +char id=174 x=37 y=160 width=12 height=15 xoffset=0 yoffset=6 xadvance=12 page=0 chnl=0 +char id=176 x=221 y=160 width=7 height=8 xoffset=0 yoffset=8 xadvance=6 page=0 chnl=0 +char id=180 x=105 y=176 width=7 height=4 xoffset=-1 yoffset=10 xadvance=6 page=0 chnl=0 +char id=184 x=228 y=160 width=6 height=8 xoffset=-1 yoffset=23 xadvance=5 page=0 chnl=0 +char id=187 x=139 y=160 width=12 height=12 xoffset=-1 yoffset=15 xadvance=10 page=0 chnl=0 +char id=191 x=137 y=117 width=8 height=21 xoffset=0 yoffset=15 xadvance=8 page=0 chnl=0 +char id=192 x=8 y=34 width=16 height=30 xoffset=-2 yoffset=2 xadvance=13 page=0 chnl=0 +char id=193 x=24 y=34 width=16 height=30 xoffset=-2 yoffset=2 xadvance=13 page=0 chnl=0 +char id=194 x=38 y=0 width=16 height=32 xoffset=-2 yoffset=0 xadvance=13 page=0 chnl=0 +char id=195 x=171 y=0 width=16 height=31 xoffset=-2 yoffset=1 xadvance=13 page=0 chnl=0 +char id=196 x=40 y=34 width=16 height=30 xoffset=-2 yoffset=2 xadvance=13 page=0 chnl=0 +char id=197 x=54 y=0 width=16 height=32 xoffset=-2 yoffset=0 xadvance=13 page=0 chnl=0 +char id=198 x=13 y=117 width=17 height=23 xoffset=0 yoffset=6 xadvance=15 page=0 chnl=0 +char id=199 x=187 y=0 width=13 height=31 xoffset=0 yoffset=6 xadvance=11 page=0 chnl=0 +char id=200 x=56 y=34 width=10 height=30 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 +char id=201 x=66 y=34 width=10 height=30 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 +char id=202 x=70 y=0 width=10 height=32 xoffset=0 yoffset=0 xadvance=9 page=0 chnl=0 +char id=203 x=200 y=0 width=10 height=31 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0 +char id=204 x=80 y=0 width=12 height=32 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 +char id=205 x=92 y=0 width=12 height=32 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 +char id=206 x=0 y=0 width=12 height=34 xoffset=-1 yoffset=0 xadvance=9 page=0 chnl=0 +char id=207 x=104 y=0 width=12 height=32 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 +char id=208 x=47 y=91 width=15 height=25 xoffset=-2 yoffset=6 xadvance=13 page=0 chnl=0 +char id=209 x=76 y=34 width=17 height=30 xoffset=0 yoffset=1 xadvance=13 page=0 chnl=0 +char id=210 x=93 y=34 width=11 height=30 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 +char id=211 x=104 y=34 width=11 height=30 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 +char id=212 x=116 y=0 width=11 height=32 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=0 +char id=213 x=210 y=0 width=11 height=31 xoffset=0 yoffset=1 xadvance=11 page=0 chnl=0 +char id=214 x=115 y=34 width=11 height=30 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 +char id=216 x=143 y=91 width=11 height=24 xoffset=-1 yoffset=6 xadvance=9 page=0 chnl=0 +char id=217 x=221 y=0 width=10 height=31 xoffset=-1 yoffset=2 xadvance=10 page=0 chnl=0 +char id=218 x=231 y=0 width=10 height=31 xoffset=-1 yoffset=2 xadvance=10 page=0 chnl=0 +char id=219 x=12 y=0 width=10 height=33 xoffset=-1 yoffset=0 xadvance=10 page=0 chnl=0 +char id=220 x=241 y=0 width=10 height=31 xoffset=-1 yoffset=2 xadvance=10 page=0 chnl=0 +char id=221 x=22 y=0 width=8 height=33 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 +char id=222 x=154 y=91 width=13 height=24 xoffset=-1 yoffset=5 xadvance=12 page=0 chnl=0 +char id=223 x=35 y=140 width=7 height=19 xoffset=0 yoffset=12 xadvance=7 page=0 chnl=0 +char id=224 x=140 y=140 width=7 height=18 xoffset=0 yoffset=10 xadvance=7 page=0 chnl=0 +char id=225 x=147 y=140 width=7 height=18 xoffset=0 yoffset=10 xadvance=7 page=0 chnl=0 +char id=226 x=42 y=140 width=7 height=19 xoffset=0 yoffset=9 xadvance=7 page=0 chnl=0 +char id=227 x=154 y=140 width=7 height=18 xoffset=0 yoffset=10 xadvance=7 page=0 chnl=0 +char id=228 x=161 y=140 width=7 height=18 xoffset=0 yoffset=10 xadvance=7 page=0 chnl=0 +char id=229 x=49 y=140 width=7 height=19 xoffset=0 yoffset=9 xadvance=7 page=0 chnl=0 +char id=230 x=0 y=160 width=11 height=16 xoffset=0 yoffset=13 xadvance=10 page=0 chnl=0 +char id=231 x=145 y=117 width=8 height=21 xoffset=0 yoffset=12 xadvance=7 page=0 chnl=0 +char id=232 x=228 y=117 width=8 height=20 xoffset=-1 yoffset=10 xadvance=7 page=0 chnl=0 +char id=233 x=236 y=117 width=8 height=20 xoffset=-1 yoffset=10 xadvance=7 page=0 chnl=0 +char id=234 x=153 y=117 width=8 height=21 xoffset=-1 yoffset=9 xadvance=7 page=0 chnl=0 +char id=235 x=244 y=117 width=8 height=20 xoffset=-1 yoffset=10 xadvance=7 page=0 chnl=0 +char id=236 x=11 y=160 width=7 height=16 xoffset=-2 yoffset=10 xadvance=4 page=0 chnl=0 +char id=237 x=18 y=160 width=7 height=16 xoffset=-2 yoffset=10 xadvance=4 page=0 chnl=0 +char id=238 x=176 y=140 width=7 height=17 xoffset=-2 yoffset=9 xadvance=4 page=0 chnl=0 +char id=239 x=25 y=160 width=7 height=16 xoffset=-1 yoffset=10 xadvance=4 page=0 chnl=0 +char id=240 x=49 y=160 width=7 height=15 xoffset=0 yoffset=14 xadvance=7 page=0 chnl=0 +char id=241 x=0 y=140 width=10 height=20 xoffset=-1 yoffset=10 xadvance=8 page=0 chnl=0 +char id=242 x=56 y=140 width=8 height=19 xoffset=-1 yoffset=10 xadvance=6 page=0 chnl=0 +char id=243 x=64 y=140 width=8 height=19 xoffset=-1 yoffset=10 xadvance=6 page=0 chnl=0 +char id=244 x=10 y=140 width=8 height=20 xoffset=-1 yoffset=9 xadvance=6 page=0 chnl=0 +char id=245 x=72 y=140 width=7 height=19 xoffset=0 yoffset=10 xadvance=6 page=0 chnl=0 +char id=246 x=79 y=140 width=7 height=19 xoffset=0 yoffset=10 xadvance=6 page=0 chnl=0 +char id=248 x=79 y=160 width=7 height=14 xoffset=0 yoffset=15 xadvance=7 page=0 chnl=0 +char id=249 x=161 y=117 width=9 height=21 xoffset=-1 yoffset=10 xadvance=7 page=0 chnl=0 +char id=250 x=170 y=117 width=9 height=21 xoffset=-1 yoffset=10 xadvance=7 page=0 chnl=0 +char id=251 x=98 y=117 width=9 height=22 xoffset=-1 yoffset=9 xadvance=7 page=0 chnl=0 +char id=252 x=179 y=117 width=9 height=21 xoffset=-1 yoffset=10 xadvance=7 page=0 chnl=0 +char id=253 x=126 y=34 width=11 height=30 xoffset=-1 yoffset=10 xadvance=9 page=0 chnl=0 +char id=254 x=112 y=64 width=9 height=27 xoffset=-1 yoffset=5 xadvance=7 page=0 chnl=0 +char id=255 x=137 y=34 width=11 height=30 xoffset=-1 yoffset=10 xadvance=9 page=0 chnl=0 +char id=305 x=210 y=160 width=4 height=9 xoffset=0 yoffset=17 xadvance=4 page=0 chnl=0 +char id=321 x=0 y=91 width=17 height=26 xoffset=-2 yoffset=6 xadvance=6 page=0 chnl=0 +char id=322 x=17 y=91 width=8 height=26 xoffset=-2 yoffset=5 xadvance=5 page=0 chnl=0 +char id=338 x=167 y=91 width=15 height=24 xoffset=0 yoffset=5 xadvance=15 page=0 chnl=0 +char id=339 x=183 y=140 width=11 height=17 xoffset=0 yoffset=14 xadvance=10 page=0 chnl=0 +char id=352 x=148 y=34 width=9 height=30 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0 +char id=353 x=188 y=117 width=8 height=21 xoffset=-1 yoffset=9 xadvance=6 page=0 chnl=0 +char id=376 x=30 y=0 width=8 height=33 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 +char id=381 x=157 y=34 width=14 height=30 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0 +char id=382 x=18 y=140 width=8 height=20 xoffset=0 yoffset=9 xadvance=8 page=0 chnl=0 +char id=8216 x=247 y=160 width=7 height=7 xoffset=-1 yoffset=5 xadvance=5 page=0 chnl=0 +char id=8217 x=10 y=176 width=7 height=7 xoffset=-1 yoffset=5 xadvance=5 page=0 chnl=0 +char id=8218 x=17 y=176 width=7 height=7 xoffset=-1 yoffset=23 xadvance=5 page=0 chnl=0 +char id=8220 x=24 y=176 width=9 height=7 xoffset=-1 yoffset=5 xadvance=8 page=0 chnl=0 +char id=8221 x=33 y=176 width=9 height=7 xoffset=-1 yoffset=5 xadvance=8 page=0 chnl=0 +char id=8222 x=42 y=176 width=9 height=7 xoffset=-1 yoffset=23 xadvance=8 page=0 chnl=0 +char id=8224 x=182 y=91 width=11 height=24 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=0 +char id=8225 x=62 y=91 width=10 height=25 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=0 +char id=8230 x=56 y=176 width=13 height=5 xoffset=-1 yoffset=23 xadvance=12 page=0 chnl=0 +char id=8249 x=168 y=160 width=9 height=11 xoffset=-1 yoffset=16 xadvance=7 page=0 chnl=0 +char id=8250 x=177 y=160 width=9 height=11 xoffset=-1 yoffset=15 xadvance=7 page=0 chnl=0 +char id=8364 x=86 y=140 width=11 height=19 xoffset=0 yoffset=9 xadvance=11 page=0 chnl=0 +kernings count=1 +kerning first=75 second=65 amount=-2 diff --git a/wizard-client/wizard-client-libgdx/core/src/main/resources/font/handwritten.png b/wizard-client/wizard-client-libgdx/core/src/main/resources/font/handwritten.png new file mode 100644 index 0000000..092012c Binary files /dev/null and b/wizard-client/wizard-client-libgdx/core/src/main/resources/font/handwritten.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/resources/uiskin.json b/wizard-client/wizard-client-libgdx/core/src/main/resources/uiskin.json index 6ea2045..e3936ae 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/resources/uiskin.json +++ b/wizard-client/wizard-client-libgdx/core/src/main/resources/uiskin.json @@ -5,6 +5,9 @@ }, "enchanted": { "file": "font/enchanted.fnt" + }, + "handwritten": { + "file": "font/handwritten.fnt" } }, "Color": { @@ -124,6 +127,10 @@ "background": "textfield", "font": "default-font", "fontColor": "white" + }, + "handwritten": { + "font": "handwritten", + "fontColor": "black" } }, "TextFieldStyle": { diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/blue_1.9.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/blue_1.9.png new file mode 100644 index 0000000..31d7dc1 Binary files /dev/null and b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/blue_1.9.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/blue_1.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/blue_1.png deleted file mode 100644 index ddd1737..0000000 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/blue_1.png and /dev/null differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/green_1.9.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/green_1.9.png new file mode 100644 index 0000000..c0e5058 Binary files /dev/null and b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/green_1.9.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/green_1.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/green_1.png deleted file mode 100644 index d6b7785..0000000 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/green_1.png and /dev/null differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/red_1.9.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/red_1.9.png new file mode 100644 index 0000000..bd14bce Binary files /dev/null and b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/red_1.9.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/red_1.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/red_1.png deleted file mode 100644 index bb57144..0000000 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/red_1.png and /dev/null differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/yellow_1.9.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/yellow_1.9.png new file mode 100644 index 0000000..d972936 Binary files /dev/null and b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/yellow_1.9.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/yellow_1.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/yellow_1.png deleted file mode 100644 index 9264faa..0000000 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/cards/yellow_1.png and /dev/null differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/pack.json b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/pack.json new file mode 100644 index 0000000..510c0e4 --- /dev/null +++ b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/pack.json @@ -0,0 +1,6 @@ +{ + "maxWidth": 2048, + "maxHeight": 2048, + "filterMin": "MipMap", + "filterMag": "Linear" +} \ No newline at end of file diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/game/pad_of_truth.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/pad_of_truth.png new file mode 100644 index 0000000..d7653fe Binary files /dev/null and b/wizard-client/wizard-client-libgdx/core/src/main/textures/game/pad_of_truth.png differ diff --git a/wizard-server/src/main/java/eu/jonahbauer/wizard/server/Server.java b/wizard-server/src/main/java/eu/jonahbauer/wizard/server/Server.java index ab549ee..29a323f 100644 --- a/wizard-server/src/main/java/eu/jonahbauer/wizard/server/Server.java +++ b/wizard-server/src/main/java/eu/jonahbauer/wizard/server/Server.java @@ -2,9 +2,16 @@ package eu.jonahbauer.wizard.server; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication -public class Server { +public class Server extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(Server.class); + } public static void main(String[] args) { SpringApplication.run(Server.class, args);