Compare commits
No commits in common. 'dev' and 'main' have entirely different histories.
@ -0,0 +1,24 @@
|
|||||||
|
package eu.jonahbauer.wizard.client.cli.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public record Pair<F,S>(F first, S second) implements Map.Entry<F, S> {
|
||||||
|
public static <F,S> Pair<F,S> of(F first, S second) {
|
||||||
|
return new Pair<>(first, second);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public F getKey() {
|
||||||
|
return first();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public S getValue() {
|
||||||
|
return second();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public S setValue(S value) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
@ -1,53 +0,0 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.actors;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.List;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
|
||||||
import com.badlogic.gdx.utils.Align;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
public abstract class IconList<T> extends List<T> {
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private float iconWidth = -1;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private float iconPadding = 8;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public IconList(Skin skin) {
|
|
||||||
super(skin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public IconList(Skin skin, String styleName) {
|
|
||||||
super(skin, styleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public IconList(ListStyle style) {
|
|
||||||
super(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Drawable getIcon(T item);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public void setAlignment(int alignment) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GlyphLayout drawItem(Batch batch, BitmapFont font, int index, T item, float x, float y, float width) {
|
|
||||||
var text = toString(item);
|
|
||||||
var icon = getIcon(item);
|
|
||||||
var height = font.getCapHeight();
|
|
||||||
var iconWidth = this.iconWidth < 0 ? height : this.iconWidth;
|
|
||||||
|
|
||||||
icon.draw(batch, x, y - height, iconWidth, height);
|
|
||||||
return font.draw(batch, text, x + iconWidth + iconPadding, y, 0, text.length(), width - iconWidth - iconPadding, Align.left, false, "...");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.listeners;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
|
||||||
import eu.jonahbauer.wizard.client.libgdx.util.SoundManager;
|
|
||||||
|
|
||||||
public class ButtonClickListener extends ChangeListener {
|
|
||||||
private final SoundManager sounds;
|
|
||||||
|
|
||||||
public ButtonClickListener(SoundManager sounds) {
|
|
||||||
this.sounds = sounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
if (actor instanceof Button) {
|
|
||||||
sounds.sfxClick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.util;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.audio.Sound;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
public class SoundManager {
|
|
||||||
public static final float CARD_SHUFFLE_DURATION = 4.2f;
|
|
||||||
|
|
||||||
private final WizardAssetManager assets;
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
private float sfxVolume = 1;
|
|
||||||
|
|
||||||
private final Sound click;
|
|
||||||
private final Sound cardPlayed;
|
|
||||||
private final Sound cardShuffle;
|
|
||||||
|
|
||||||
public SoundManager(WizardAssetManager assets) {
|
|
||||||
this.assets = assets;
|
|
||||||
assets.load(WizardAssetManager.SFX_CLICK, Sound.class);
|
|
||||||
assets.load(WizardAssetManager.SFX_CARD_PLAYED, Sound.class);
|
|
||||||
assets.load(WizardAssetManager.SFX_CARD_SHUFFLE, Sound.class);
|
|
||||||
assets.finishLoading();
|
|
||||||
|
|
||||||
this.click = assets.get(WizardAssetManager.SFX_CLICK);
|
|
||||||
this.cardPlayed = assets.get(WizardAssetManager.SFX_CARD_PLAYED);
|
|
||||||
this.cardShuffle = assets.get(WizardAssetManager.SFX_CARD_SHUFFLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sfxClick() {
|
|
||||||
this.click.play(sfxVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sfxShuffle() {
|
|
||||||
this.cardShuffle.play(sfxVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sfxPlayCard() {
|
|
||||||
this.cardPlayed.play(sfxVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
|
||||||
assets.unload(WizardAssetManager.SFX_CLICK);
|
|
||||||
assets.unload(WizardAssetManager.SFX_CARD_PLAYED);
|
|
||||||
assets.unload(WizardAssetManager.SFX_CARD_SHUFFLE);
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
@ -1,23 +0,0 @@
|
|||||||
module eu.jonahbauer.wizard.common {
|
|
||||||
exports eu.jonahbauer.wizard.common.machine;
|
|
||||||
exports eu.jonahbauer.wizard.common.messages;
|
|
||||||
exports eu.jonahbauer.wizard.common.messages.client;
|
|
||||||
exports eu.jonahbauer.wizard.common.messages.data;
|
|
||||||
exports eu.jonahbauer.wizard.common.messages.observer;
|
|
||||||
exports eu.jonahbauer.wizard.common.messages.player;
|
|
||||||
exports eu.jonahbauer.wizard.common.messages.server;
|
|
||||||
exports eu.jonahbauer.wizard.common.model;
|
|
||||||
exports eu.jonahbauer.wizard.common.util;
|
|
||||||
|
|
||||||
opens eu.jonahbauer.wizard.common.messages.client to com.fasterxml.jackson.databind;
|
|
||||||
opens eu.jonahbauer.wizard.common.messages.data to com.fasterxml.jackson.databind;
|
|
||||||
opens eu.jonahbauer.wizard.common.messages.observer to com.fasterxml.jackson.databind;
|
|
||||||
opens eu.jonahbauer.wizard.common.messages.player to com.fasterxml.jackson.databind;
|
|
||||||
opens eu.jonahbauer.wizard.common.messages.server to com.fasterxml.jackson.databind;
|
|
||||||
|
|
||||||
requires com.fasterxml.jackson.databind;
|
|
||||||
requires com.fasterxml.jackson.module.paramnames;
|
|
||||||
|
|
||||||
requires static lombok;
|
|
||||||
requires static org.jetbrains.annotations;
|
|
||||||
}
|
|
@ -0,0 +1,72 @@
|
|||||||
|
package eu.jonahbauer.wizard.core;
|
||||||
|
|
||||||
|
import eu.jonahbauer.wizard.common.messages.player.PickTrumpMessage;
|
||||||
|
import eu.jonahbauer.wizard.common.messages.player.PlayCardMessage;
|
||||||
|
import eu.jonahbauer.wizard.common.messages.player.PredictMessage;
|
||||||
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
|
import eu.jonahbauer.wizard.core.messages.Observer;
|
||||||
|
import eu.jonahbauer.wizard.core.model.GameConfiguration;
|
||||||
|
import eu.jonahbauer.wizard.core.model.Configurations;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class CLI {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
GameConfiguration config = Configurations.DEFAULT;
|
||||||
|
Observer observer = (player, msg) -> System.out.println(msg);
|
||||||
|
Game game = new Game(config, observer);
|
||||||
|
var players = List.of(
|
||||||
|
UUID.randomUUID(),
|
||||||
|
UUID.randomUUID(),
|
||||||
|
UUID.randomUUID(),
|
||||||
|
UUID.randomUUID()
|
||||||
|
);
|
||||||
|
|
||||||
|
game.start(players);
|
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
Pattern pattern = Pattern.compile("(\\d) ([a-z]+) (.*)");
|
||||||
|
while (scanner.hasNextLine()) {
|
||||||
|
try {
|
||||||
|
Matcher matcher = pattern.matcher(scanner.nextLine());
|
||||||
|
if (!matcher.find()) {
|
||||||
|
System.err.println("Format is \"(\\d) ([a-z]+) (.*)\"");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String player = matcher.group(1);
|
||||||
|
String command = matcher.group(2);
|
||||||
|
String param = matcher.group(3);
|
||||||
|
|
||||||
|
int id = Integer.parseInt(player);
|
||||||
|
|
||||||
|
if (id > players.size()) {
|
||||||
|
System.err.println("ID must be between 0 and " + (players.size() - 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (command) {
|
||||||
|
case "predict" -> {
|
||||||
|
int prediction = Integer.parseInt(param);
|
||||||
|
game.onMessage(players.get(id), new PredictMessage(prediction));
|
||||||
|
}
|
||||||
|
case "play" -> {
|
||||||
|
Card card = Card.valueOf(param);
|
||||||
|
game.onMessage(players.get(id), new PlayCardMessage(card));
|
||||||
|
}
|
||||||
|
case "trump" -> {
|
||||||
|
Card.Suit suit = Card.Suit.valueOf(param);
|
||||||
|
game.onMessage(players.get(id), new PickTrumpMessage(suit));
|
||||||
|
}
|
||||||
|
default -> System.err.println("Unknown command: " + command);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package eu.jonahbauer.wizard.core.states;
|
package eu.jonahbauer.wizard.core.machine.states;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import eu.jonahbauer.wizard.common.util.Pair;
|
import eu.jonahbauer.wizard.core.util.Pair;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
@ -1,4 +1,4 @@
|
|||||||
package eu.jonahbauer.wizard.core.states;
|
package eu.jonahbauer.wizard.core.machine.states;
|
||||||
|
|
||||||
public class InvalidDataException extends RuntimeException {
|
public class InvalidDataException extends RuntimeException {
|
||||||
public InvalidDataException(String message) {
|
public InvalidDataException(String message) {
|
@ -0,0 +1,4 @@
|
|||||||
|
package eu.jonahbauer.wizard.core.machine.states;
|
||||||
|
|
||||||
|
public interface TransientState {
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.game;
|
package eu.jonahbauer.wizard.core.machine.states.game;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
@ -1,7 +1,7 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.game;
|
package eu.jonahbauer.wizard.core.machine.states.game;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
@ -1,8 +1,8 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.game;
|
package eu.jonahbauer.wizard.core.machine.states.game;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.game;
|
package eu.jonahbauer.wizard.core.machine.states.game;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.ScoreMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.ScoreMessage;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.*;
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
|
||||||
|
|
||||||
public final class Finishing extends GameState {
|
public final class Finishing extends GameState {
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
package eu.jonahbauer.wizard.core.machine.states.game;
|
||||||
|
|
||||||
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
|
import eu.jonahbauer.wizard.core.machine.states.round.StartingRound;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.PLAYERS;
|
||||||
|
|
||||||
|
public final class Starting extends GameState {
|
||||||
|
|
||||||
|
public Starting(GameData data) {
|
||||||
|
super(data.require(PLAYERS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<GameState> onEnter(Game game) {
|
||||||
|
return transition(new StartingRound(getData()));
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,15 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.round;
|
package eu.jonahbauer.wizard.core.machine.states.round;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.HandMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.HandMessage;
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.core.model.deck.Deck;
|
import eu.jonahbauer.wizard.core.model.deck.Deck;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.*;
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
|
||||||
|
|
||||||
public final class Dealing extends RoundState {
|
public final class Dealing extends RoundState {
|
||||||
|
|
@ -1,15 +1,15 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.round;
|
package eu.jonahbauer.wizard.core.machine.states.round;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.TrumpMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.TrumpMessage;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.core.model.card.GameCards;
|
import eu.jonahbauer.wizard.core.model.card.GameCards;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.*;
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
|
||||||
|
|
||||||
public final class DeterminingTrump extends RoundState {
|
public final class DeterminingTrump extends RoundState {
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.round;
|
package eu.jonahbauer.wizard.core.machine.states.round;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.*;
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
|
||||||
|
|
||||||
public abstract class RoundState extends GameState {
|
public abstract class RoundState extends GameState {
|
||||||
public static GameData requirements(GameData data) {
|
public static GameData requirements(GameData data) {
|
@ -1,8 +1,8 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.round;
|
package eu.jonahbauer.wizard.core.machine.states.round;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
@ -1,19 +1,19 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.trick;
|
package eu.jonahbauer.wizard.core.machine.states.trick;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.core.states.InvalidDataException;
|
import eu.jonahbauer.wizard.core.machine.states.InvalidDataException;
|
||||||
import eu.jonahbauer.wizard.core.states.round.ChangingPrediction;
|
import eu.jonahbauer.wizard.core.machine.states.round.ChangingPrediction;
|
||||||
import eu.jonahbauer.wizard.core.states.round.FinishingRound;
|
import eu.jonahbauer.wizard.core.machine.states.round.FinishingRound;
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.TrickMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.TrickMessage;
|
||||||
import eu.jonahbauer.wizard.core.model.card.*;
|
import eu.jonahbauer.wizard.core.model.card.*;
|
||||||
import eu.jonahbauer.wizard.common.util.Pair;
|
import eu.jonahbauer.wizard.core.util.Pair;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.*;
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
|
||||||
|
|
||||||
public final class FinishingTrick extends TrickState {
|
public final class FinishingTrick extends TrickState {
|
||||||
|
|
@ -1,22 +1,22 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.trick;
|
package eu.jonahbauer.wizard.core.machine.states.trick;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.TimeoutMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.TimeoutMessage;
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.core.states.InvalidDataException;
|
import eu.jonahbauer.wizard.core.machine.states.InvalidDataException;
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.CardMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.CardMessage;
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage;
|
||||||
import eu.jonahbauer.wizard.common.messages.player.PlayCardMessage;
|
import eu.jonahbauer.wizard.common.messages.player.PlayCardMessage;
|
||||||
import eu.jonahbauer.wizard.common.messages.player.PlayerMessage;
|
import eu.jonahbauer.wizard.common.messages.player.PlayerMessage;
|
||||||
import eu.jonahbauer.wizard.core.model.card.GameCards;
|
import eu.jonahbauer.wizard.core.model.card.GameCards;
|
||||||
import eu.jonahbauer.wizard.common.util.Pair;
|
import eu.jonahbauer.wizard.core.util.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.*;
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
|
||||||
import static eu.jonahbauer.wizard.common.messages.observer.UserInputMessage.Action.PLAY_CARD;
|
import static eu.jonahbauer.wizard.common.messages.observer.UserInputMessage.Action.PLAY_CARD;
|
||||||
|
|
||||||
public final class PlayingCard extends TrickState {
|
public final class PlayingCard extends TrickState {
|
@ -1,8 +1,8 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.trick;
|
package eu.jonahbauer.wizard.core.machine.states.trick;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
import eu.jonahbauer.wizard.core.machine.Game;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.trick;
|
package eu.jonahbauer.wizard.core.machine.states.trick;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.states.round.RoundState;
|
import eu.jonahbauer.wizard.core.machine.states.round.RoundState;
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.*;
|
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
|
||||||
|
|
||||||
public abstract class TrickState extends RoundState {
|
public abstract class TrickState extends RoundState {
|
||||||
public static GameData requirements(GameData data) {
|
public static GameData requirements(GameData data) {
|
@ -1,4 +1,4 @@
|
|||||||
package eu.jonahbauer.wizard.core;
|
package eu.jonahbauer.wizard.core.messages;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.ObserverMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.ObserverMessage;
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
package eu.jonahbauer.wizard.core.states;
|
|
||||||
|
|
||||||
public interface TransientState {
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package eu.jonahbauer.wizard.core.states.game;
|
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.Game;
|
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
|
||||||
import eu.jonahbauer.wizard.core.states.round.StartingRound;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static eu.jonahbauer.wizard.core.states.GameData.PLAYERS;
|
|
||||||
|
|
||||||
public final class Starting extends GameState {
|
|
||||||
|
|
||||||
public Starting(GameData data) {
|
|
||||||
super(data.require(PLAYERS));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<GameState> onEnter(Game game) {
|
|
||||||
return transition(new StartingRound(getData()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package eu.jonahbauer.wizard.common.util;
|
package eu.jonahbauer.wizard.core.util;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package eu.jonahbauer.wizard.common.util;
|
package eu.jonahbauer.wizard.core.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class StringUtil {
|
public class Util {
|
||||||
public static String toSnakeCase(String str) {
|
public static String toSnakeCase(String str) {
|
||||||
return str.replaceAll("([a-z])([A-Z]+)", "$1_$2").toLowerCase(Locale.ROOT);
|
return str.replaceAll("([a-z])([A-Z]+)", "$1_$2").toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
@ -1,8 +0,0 @@
|
|||||||
module eu.jonahbauer.wizard.core {
|
|
||||||
exports eu.jonahbauer.wizard.core;
|
|
||||||
|
|
||||||
requires eu.jonahbauer.wizard.common;
|
|
||||||
|
|
||||||
requires static lombok;
|
|
||||||
requires static org.jetbrains.annotations;
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
package eu.jonahbauer.wizard.core;
|
package eu.jonahbauer.wizard.core.machine;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.core.states.game.Finished;
|
import eu.jonahbauer.wizard.core.machine.states.game.Finished;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
@ -1,11 +1,11 @@
|
|||||||
package eu.jonahbauer.wizard.core;
|
package eu.jonahbauer.wizard.core.machine;
|
||||||
|
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.ObserverMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.ObserverMessage;
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage;
|
||||||
import eu.jonahbauer.wizard.common.messages.player.*;
|
import eu.jonahbauer.wizard.common.messages.player.*;
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import eu.jonahbauer.wizard.core.states.GameData;
|
import eu.jonahbauer.wizard.core.machine.states.GameData;
|
||||||
import eu.jonahbauer.wizard.core.states.GameState;
|
import eu.jonahbauer.wizard.core.messages.Observer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -1,5 +1,6 @@
|
|||||||
package eu.jonahbauer.wizard.core.states;
|
package eu.jonahbauer.wizard.core.machine.states;
|
||||||
|
|
||||||
|
import eu.jonahbauer.wizard.core.machine.GameState;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
@ -1,11 +0,0 @@
|
|||||||
package eu.jonahbauer.wizard.server.management;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public interface LobbyMBean {
|
|
||||||
|
|
||||||
int getPlayerCount();
|
|
||||||
|
|
||||||
int getTotalPlayerCount();
|
|
||||||
|
|
||||||
int getSessionCount();
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package eu.jonahbauer.wizard.server.management;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public interface SessionMBean {
|
|
||||||
|
|
||||||
UUID getUuid();
|
|
||||||
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
int getPlayerCount();
|
|
||||||
|
|
||||||
boolean isRunning();
|
|
||||||
|
|
||||||
boolean isDebug();
|
|
||||||
|
|
||||||
void close();
|
|
||||||
}
|
|
Loading…
Reference in New Issue