51 Commits

Author SHA1 Message Date
Benjamin Feyer
ee70699150 added some logic to the tests 2024-12-03 06:35:45 +01:00
Benjamin Feyer
9ef897f873 minor changes 2024-12-02 23:26:45 +01:00
Benjamin Feyer
ba9a60a58a added one more test and added some logic to the moveTest to test unwanted statechanges 2024-12-02 23:10:21 +01:00
Benjamin Feyer
2434ede556 added one testmethod 2024-12-02 22:43:11 +01:00
Benjamin Feyer
50ac201277 added two new pieceTests 2024-12-02 22:10:11 +01:00
Benjamin Feyer
bd55a1f08d Merge branch 'development' into 'dev/test'
merge dev into test

See merge request progproj/gruppen-ht24/Gruppe-01!33
2024-12-02 16:37:00 +00:00
Timo Brennförder
db95a44915 initial commit for SettingsTests 2024-12-02 17:18:32 +01:00
Benjamin Feyer
cfd16973f5 refactored the package names 2024-12-02 16:59:50 +01:00
Benjamin Feyer
af38224483 added one testmethod for pieceTest 2024-12-02 16:47:34 +01:00
Benjamin Feyer
9b9b5e6781 added a message in piecetest for ShufflePile 2024-12-02 16:03:42 +01:00
Benjamin Feyer
0f2766918b added a testmethod for the piece for no powerCards 2024-12-02 15:57:53 +01:00
Benjamin Feyer
314019a632 added one more test-class 2024-12-02 04:40:49 +01:00
Benjamin Feyer
798b6ebe1d added some testmethods for the piecetest 2024-12-02 04:19:52 +01:00
Benjamin Feyer
2cb8e512e6 added some testmethods for piecetest 2024-12-02 03:38:38 +01:00
Benjamin Feyer
5e61727bec added two testmethods in piecetest 2024-12-02 02:27:21 +01:00
Benjamin Feyer
470607af5c Merge branch 'development' into 'dev/test'
Updated 'Game' class.

See merge request progproj/gruppen-ht24/Gruppe-01!32
2024-12-02 00:55:01 +00:00
Benjamin Feyer
435919306a Merge branch 'development' into 'dev/test'
Updated 'Die' class.

See merge request progproj/gruppen-ht24/Gruppe-01!31
2024-12-02 00:49:22 +00:00
Benjamin Feyer
f63e94cf24 added one testmethod in pieceTest 2024-12-02 01:47:47 +01:00
Benjamin Feyer
0aeb02a5f2 Merge branch 'development' into 'dev/test'
merge dev into test

See merge request progproj/gruppen-ht24/Gruppe-01!30
2024-12-02 00:29:39 +00:00
Benjamin Feyer
5240150ec2 added some parts of test-method piecetest 2024-12-02 01:28:42 +01:00
Benjamin Feyer
7bf41bc358 Merge branch 'development' into 'dev/test'
merge dev int test

See merge request progproj/gruppen-ht24/Gruppe-01!29
2024-12-01 22:33:42 +00:00
Benjamin Feyer
48923cddd6 Merge branch 'development' into 'dev/test'
merge dev into test

See merge request progproj/gruppen-ht24/Gruppe-01!28
2024-12-01 22:11:24 +00:00
Benjamin Feyer
a1934e30cb minor changes 2024-12-01 23:08:56 +01:00
Benjamin Feyer
9718ad111f Merge branch 'development' into 'dev/test'
merge Development into test

See merge request progproj/gruppen-ht24/Gruppe-01!27
2024-12-01 20:56:49 +00:00
Benjamin Feyer
6370ec15c2 added minor changes 2024-12-01 21:53:38 +01:00
Benjamin Feyer
1c826bcec0 added comments 2024-12-01 21:12:19 +01:00
Benjamin Feyer
bd9d8c688d Merge branch 'development' into 'dev/test'
merge development into test

See merge request progproj/gruppen-ht24/Gruppe-01!26
2024-12-01 20:02:47 +00:00
Benjamin Feyer
a1bd8007de added some comments in Piecetest 2024-12-01 14:59:56 +01:00
Benjamin Feyer
55ef5438d2 added som javadoc in the PieceTest-class 2024-12-01 14:31:06 +01:00
Benjamin Feyer
d7b0ac92b8 added in PieceTest the declaration and initialization of two players 2024-12-01 14:23:26 +01:00
Benjamin Feyer
0d043e4bb4 added some more messages to test the server 2024-12-01 14:10:05 +01:00
Benjamin Feyer
27de0ccece Merge branch 'development' into 'dev/test'
merge dev into test

See merge request progproj/gruppen-ht24/Gruppe-01!24
2024-12-01 11:14:19 +00:00
Benjamin Feyer
8d49528a92 added the nextmethods 2024-12-01 12:13:29 +01:00
Benjamin Feyer
8b1868e03b Merge branch 'development' into 'dev/test'
merge development int test branch

See merge request progproj/gruppen-ht24/Gruppe-01!23
2024-12-01 11:10:24 +00:00
Benjamin Feyer
56f32c5c0b edited some comments in the methods and wrote in som methods, to test unwanted statechanges 2024-12-01 12:09:13 +01:00
Benjamin Feyer
c41848b061 adjusted some Todos and deleted some mention of statemachines 2024-12-01 00:41:37 +01:00
Benjamin Feyer
0fd190419d Merge branch 'development' into 'dev/test'
merge development into test

See merge request progproj/gruppen-ht24/Gruppe-01!22
2024-11-30 23:34:40 +00:00
Benjamin Feyer
838beee345 added some more tests andd edited some mor 2024-11-29 16:49:11 +01:00
Benjamin Feyer
c6462a50ca added two more tests for the substates of turn to their end-states and added some simulated inputs in the lobby and dialogs 2024-11-29 16:00:10 +01:00
Benjamin Feyer
d0361b2759 commented the 'received(interruptMessage)' out, to ensure, there are no unwanted state-changes 2024-11-29 00:33:33 +01:00
Benjamin Feyer
eff011f69f implemented more tests for the clientStartgame 2024-11-29 00:13:06 +01:00
Benjamin Feyer
fad853b34a implemented more tests for the clientstatetests 2024-11-28 23:24:31 +01:00
Benjamin Feyer
4a89c4fa65 processed some Todo in the Client State, to test unwanted statechanged 2024-11-28 22:46:50 +01:00
Benjamin Feyer
6d58ceee3d corrected the classes of the states in the statetests 2024-11-28 19:45:18 +01:00
Benjamin Feyer
ecf1cc6e9a push after merge 2024-11-28 18:53:32 +01:00
Benjamin Feyer
dd836aa6b9 Merge remote-tracking branch 'origin/development' into dev/test
# Conflicts:
#	Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java
2024-11-28 18:44:47 +01:00
Benjamin Feyer
b3504925a5 corrected some testmethods in the serverStateTest,
changed all assertTrue( .... isinstanceof ....) to assertEquals(...,....)
2024-11-28 18:40:07 +01:00
Benjamin Feyer
8a5ebfd9d2 added some clientStateTests 2024-11-28 18:01:22 +01:00
Benjamin Feyer
a3a155a7e3 corrected some testmethods due to renaming of classes and changed state-architecture 2024-11-28 16:52:00 +01:00
Benjamin Feyer
5ef07e35d1 Merge branch 'development' into 'dev/test'
merge edited model into test

See merge request progproj/gruppen-ht24/Gruppe-01!18
2024-11-26 22:32:02 +00:00
Benjamin Feyer
ef3193cd68 Merge branch 'development' into 'dev/test'
merge after refactoring

See merge request progproj/gruppen-ht24/Gruppe-01!16
2024-11-25 15:52:35 +00:00
205 changed files with 7222 additions and 13238 deletions

View File

@@ -16,4 +16,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>

View File

@@ -0,0 +1,4 @@
package pp.battleship.game.client;
public class AnimationState {
}

View File

@@ -30,16 +30,15 @@ public enum Asset {
tank,
world(1.2f),
shieldRing("Models/shieldRing/shieldRing.j3o", null),
treeSmall(1.2f),
treeBig(1.2f),
treeSmall,
treeBig,
turboCard,
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.png"),
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.j3o"),
swapCard,
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.j3o"),
shieldCard,
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
dice,
missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.j3o"),
dice
;
private final String modelPath;

View File

@@ -27,7 +27,6 @@
import pp.mdga.notification.SelectableCardsNotification;
import java.util.List;
import java.util.UUID;
public class InputSynchronizer {
@@ -40,11 +39,6 @@ public class InputSynchronizer {
private CardControl hoverCard;
private PieceControl hoverPiece;
private boolean clickAllowed = true;
private boolean isRotateLeft = false;
private boolean isRotateRight = false;
/**
* Constructor initializes the InputSynchronizer with the application context.
* Sets up input mappings and listeners for user interactions.
@@ -60,18 +54,6 @@ public class InputSynchronizer {
setupInput();
}
public void update(float tpf) {
if(isRotateLeft && isRotateRight) {
return;
}
if(isRotateLeft) {
rotationAngle += 180 * tpf;
}
if(isRotateRight) {
rotationAngle -= 180 * tpf;
}
}
/**
* Configures input mappings for various actions and binds them to listeners.
*/
@@ -79,22 +61,22 @@ private void setupInput() {
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_Q));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_E));
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
inputManager.addMapping("MouseVertical", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new MouseAxisTrigger(MouseInput.AXIS_Y, true)); //Mouse Up Down movement
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Left", "Right", "Test");
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Test");
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
}
UUID p = null;
private boolean test = false;
/**
* Handles action-based input events such as key presses and mouse clicks.
*/
@@ -111,10 +93,6 @@ public void onAction(String name, boolean isPressed, float tpf) {
rightMousePressed = isPressed;
}
if(name.equals("Click") && isPressed) {
if(!clickAllowed) {
return;
}
if (app.getView() instanceof GameView gameView) {
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
@@ -143,40 +121,13 @@ else if(boardSelect != null) {
}
if (name.equals("Left")) {
isRotateLeft = !isRotateLeft;
}
if (name.equals("Right")) {
isRotateRight = !isRotateRight;
}
if(name.equals("Test2") &&isPressed){
if(name.equals("Test") &&isPressed){
if(app.getView() instanceof GameView gameView){
if(p == null) {
p = UUID.randomUUID();
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
gameView.getBoardHandler().movePieceStartAnim(p,0);
//gameView.getBoardHandler().movePieceAnim(p,0, 8);
} else {
gameView.getBoardHandler().throwMissileAnim(p);
//gameView.getBoardHandler().movePieceStartAnim(p,0);
}
// gameView.getGuiHandler().rollRankingResult(Color.AIRFORCE, 1);
// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
// gameView.getGuiHandler().showDice();
// UUID p1 = UUID.randomUUID();
// gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p1,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
// gameView.getBoardHandler().movePieceStartAnim(p1,0);
//gameView.getGuiHandler().drawCard(Color.ARMY);
//gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
//gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD);
gameView.getGuiHandler().showDice();
}
}
}
@@ -351,12 +302,4 @@ public void setRotation(float rotationAngle){
public int getScroll() {
return scrollValue;
}
public void setClickAllowed(boolean allowed) {
clickAllowed = allowed;
}
public boolean isClickAllowed() {
return clickAllowed;
}
}

View File

@@ -1,19 +1,13 @@
package pp.mdga.client;
import com.jme3.app.SimpleApplication;
import com.simsilica.lemur.GuiGlobals;
import com.sun.tools.javac.Main;
import pp.mdga.client.acoustic.AcousticHandler;
import com.jme3.system.AppSettings;
import com.simsilica.lemur.GuiGlobals;
import pp.mdga.client.acoustic.AcousticHandler;
import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.view.*;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.prefs.Preferences;
@@ -45,19 +39,19 @@ public class MdgaApp extends SimpleApplication {
private MdgaState state = null;
/** Scale for rendering images. */
private final float imageScale = prefs.getInt("scale", 1);
private float imageScale = prefs.getInt("scale", 1);
/** The main menu view. */
private MainView mainView;
private MdgaView mainView;
/** The lobby view. */
private LobbyView lobbyView;
private MdgaView lobbyView;
/** The game view. */
private GameView gameView;
private MdgaView gameView;
/** The ceremony view. */
private CeremonyView ceremonyView;
private MdgaView ceremonyView;
/** The client game logic. */
private final ClientGameLogic clientGameLogic;
@@ -66,7 +60,7 @@ public class MdgaApp extends SimpleApplication {
private ServerConnection networkConnection;
public MdgaApp() {
private MdgaApp() {
networkConnection = new NetworkSupport(this);
this.clientGameLogic = new ClientGameLogic(networkConnection);
}
@@ -80,30 +74,15 @@ public MdgaApp() {
public static void main(String[] args) {
AppSettings settings = new AppSettings(true);
settings.setSamples(128);
if(prefs.getBoolean("fullscreen", false)) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = (int) screenSize.getWidth();
int screenHeight = (int) screenSize.getHeight();
settings.setResolution(screenWidth, screenHeight);
settings.setFullscreen(true);
} else {
settings.setWidth(prefs.getInt("width", 1280));
settings.setHeight(prefs.getInt("height", 720));
}
settings.setWidth(prefs.getInt("width", 1280));
settings.setHeight(prefs.getInt("height", 720));
settings.setCenterWindow(true);
settings.setVSync(false);
settings.setTitle("MDGA");
settings.setVSync(true);
MdgaApp app = new MdgaApp();
app.setSettings(settings);
app.setShowSettings(false);
app.setPauseOnLostFocus(false);
app.setDisplayStatView(false);
app.start();
}
@@ -141,7 +120,6 @@ public void simpleUpdate(float tpf) {
view.update(tpf);
acousticHandler.update();
notificationSynchronizer.update();
inputSynchronizer.update(tpf);
}
/**
@@ -267,60 +245,30 @@ public ServerConnection getNetworkSupport(){
return networkConnection;
}
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
if(isFullscreen) {
int baseWidth = 1280;
int baseHeight = 720;
float baseAspectRatio = (float) baseWidth / baseHeight;
float newAspectRatio = (float) width / height;
public void updateResolution(int width, int height, float imageFactor) {
prefs.putInt("width", width);
prefs.putInt("height", height);
prefs.putFloat("scale", imageFactor);
float scaleFactor = Math.max((float) width / baseWidth, (float) height / baseHeight);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = (int) screenSize.getWidth();
int screenHeight = (int) screenSize.getHeight();
settings.setResolution(screenWidth, screenHeight);
settings.setFullscreen(true);
prefs.putFloat("scale", scaleFactor);
prefs.putBoolean("fullscreen", true);
} else {
prefs.putInt("width", width);
prefs.putInt("height", height);
prefs.putFloat("scale", imageFactor);
prefs.putBoolean("fullscreen", false);
}
}
public static void restartApp() {
try {
String javaBin = System.getProperty("java.home") + "/bin/java";
String classPath = System.getProperty("java.class.path");
String className = System.getProperty("sun.java.command");
ProcessBuilder builder = new ProcessBuilder(
javaBin, "-cp", classPath, className
);
builder.start();
System.exit(0);
restartApp();
} catch (Exception e) {
throw new RuntimeException("restart failed");
//nothing
}
}
public void afterGameCleanup() {
MainView main = (MainView) mainView;
public static void restartApp() throws IOException {
String javaBin = System.getProperty("java.home") + "/bin/java";
String classPath = System.getProperty("java.class.path");
String className = System.getProperty("sun.java.command");
main.getJoinDialog().disconnect();
main.getHostDialog().shutdownServer();
ProcessBuilder builder = new ProcessBuilder(
javaBin, "-cp", classPath, className
);
ceremonyView.afterGameCleanup();
}
builder.start();
public GameView getGameView(){
return gameView;
System.exit(0);
}
}

View File

@@ -74,11 +74,10 @@ public void selectCard(BonusCard card) {
this.card = card;
GameView gameView = (GameView) app.getView();
if(card == null) {
if(card != null) {
gameView.needConfirm();
} else {
gameView.needNoPower();
gameView.noConfirm();
}
}
@@ -94,17 +93,14 @@ public void confirm() {
} else if (a != null) {
selectPiece(a);
gameView.getBoardHandler().clearSelectable();
} else if (card != null){
selectCard(card);
gameView.getGuiHandler().clearSelectableCards();
} else {
if(null == card) {
selectCard(null);
} else {
selectCard(card);
gameView.getGuiHandler().clearSelectableCards();
}
throw new RuntimeException("nothing to confirm");
}
gameView.noConfirm();
gameView.noNoPower();
}
public void selectTsk(Color color) {
@@ -149,8 +145,4 @@ public void enter(MdgaState state) {
public void setSwap(boolean swap){
this.swap = swap;
}
public void force() {
}
}

View File

@@ -1,6 +1,5 @@
package pp.mdga.client;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.gui.GuiHandler;
import pp.mdga.client.view.CeremonyView;
@@ -20,44 +19,39 @@ public class NotificationSynchronizer {
this.app = app;
}
public void addTestNotification(Notification n) {
notifications.add(n);
handleGame(n);
}
public void update() {
Notification n = app.getGameLogic().getNotification();
while (n != null) {
if(n instanceof InfoNotification infoNotification) {
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
return;
}
if(n != null) {
switch (app.getState()) {
case MAIN:
handleMain(n);
break;
case LOBBY:
handleLobby(n);
break;
case GAME:
handleGame(n);
break;
case CEREMONY:
handleCeremony(n);
break;
case NONE:
throw new RuntimeException("no notification expected: " + n.getClass().getName());
}
if(n != null) {
switch (app.getState()) {
case MAIN:
handleMain(n);
break;
case LOBBY:
handleLobby(n);
break;
case GAME:
handleGame(n);
break;
case CEREMONY:
handleCeremony(n);
break;
case NONE:
throw new RuntimeException("no notification expected: " + n.toString());
}
n = app.getGameLogic().getNotification();
}
}
private void handleMain(Notification notification) {
if (notification instanceof LobbyDialogNotification) {
app.enter(MdgaState.LOBBY);
} else if (notification instanceof StartDialogNotification) {
//nothing
} else {
throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName());
throw new RuntimeException("notification not expected: ");
}
}
@@ -67,17 +61,16 @@ private void handleLobby(Notification notification) {
if (notification instanceof TskSelectNotification n) {
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
} else if (notification instanceof StartDialogNotification) {
app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else if (notification instanceof TskUnselectNotification n) {
lobbyView.setTaken(n.getColor(), false, false, null);
} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady());
} else if (notification instanceof GameNotification n) {
app.getGameView().setOwnColor(n.getOwnColor());
app.enter(MdgaState.GAME);
((GameView) app.getView()).setOwnColor(n.getOwnColor());
} else {
throw new RuntimeException("notification not expected in lobby: " + notification.getClass().getName());
throw new RuntimeException("notification not expected: " + notification.toString());
}
}
@@ -88,12 +81,10 @@ private void handleGame(Notification notification) {
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
if (notification instanceof AcquireCardNotification n) {
guiHandler.addCardOwn(n.getBonusCard());
app.getAcousticHandler().playSound(MdgaSound.BONUS);
guiHandler.addCard(n.getBonusCard());
} else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor());
boardHandler.showDice(n.getColor());
app.getAcousticHandler().playSound(MdgaSound.UI90);
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
app.enter(MdgaState.CEREMONY);
CeremonyView ceremonyView = (CeremonyView) app.getView();
@@ -128,8 +119,8 @@ private void handleGame(Notification notification) {
} else if (notification instanceof HomeMoveNotification home) {
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
guiHandler.hideText();
} else if (notification instanceof InterruptNotification notification1) {
gameView.enterInterrupt(notification1.getColor());
} else if (notification instanceof InterruptNotification) {
app.enter(MdgaState.LOBBY);
} else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) {
//StartMove
@@ -141,17 +132,21 @@ private void handleGame(Notification notification) {
}
guiHandler.hideText();
} else if (notification instanceof ThrowPieceNotification n) {
boardHandler.throwBombAnim(n.getPieceId());
boardHandler.throwPieceAnim(n.getPieceId());
} else if (notification instanceof NoShieldNotification n) {
boardHandler.unshieldPiece(n.getPieceId());
} else if (notification instanceof PlayCardNotification n) {
if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
switch(n.getCard()){
case SWAP -> guiHandler.swap();
case TURBO -> guiHandler.turbo();
case SHIELD -> guiHandler.shield();
default -> throw new RuntimeException("invalid card");
}
} else if (notification instanceof PlayerInGameNotification n) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) {
gameView.leaveInterrupt();
//TODO
} else if (notification instanceof RollDiceNotification n) {
gameView.getGuiHandler().hideText();
if(n.getColor() == gameView.getOwnColor()){
@@ -164,13 +159,11 @@ private void handleGame(Notification notification) {
}
} else if (notification instanceof SelectableCardsNotification n) {
guiHandler.setSelectableCards(n.getCards());
gameView.needNoPower();
} else if (notification instanceof ShieldActiveNotification n) {
boardHandler.shieldPiece(n.getPieceId());
} else if (notification instanceof ShieldSuppressedNotification n) {
boardHandler.suppressShield(n.getPieceId());
} else if (notification instanceof StartDialogNotification) {
app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else if (notification instanceof SwapPieceNotification n) {
// boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
@@ -191,16 +184,15 @@ private void handleGame(Notification notification) {
} else if (notification instanceof FinishNotification n){
guiHandler.finish(n.getColorFinished());
} else {
throw new RuntimeException("notification not expected in game: " + notification.getClass().getName());
throw new RuntimeException("notification not expected: " + notification.toString());
}
}
private void handleCeremony(Notification notification) {
if (notification instanceof StartDialogNotification) {
app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else {
throw new RuntimeException("notification not expected in ceremony: " + notification.getClass().getName());
throw new RuntimeException("notification not expected: " + notification.toString());
}
}
}

View File

@@ -109,29 +109,6 @@ public void playSound(MdgaSound sound) {
case LEAVE:
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_SOUND2, 0.6f, 0.0f));
break;
case JET:
assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
break;
case EXPLOSION:
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 0f));
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 0f));
break;
case LOSE:
assets.add(new SoundAssetDelayVolume(SoundAsset.LOSE, 1.0f, 0.0f));
break;
case BONUS:
assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
break;
case UI90:
assets.add(new SoundAssetDelayVolume(SoundAsset.UI90, 1.0f, 0.0f));
break;
case MISSILE:
assets.add(new SoundAssetDelayVolume(SoundAsset.MISSILE, 1.0f, 0.0f));
break;
case MATRIX:
assets.add(new SoundAssetDelayVolume(SoundAsset.MATRIX, 1.0f, 0.0f));
break;
default:
break;
}

View File

@@ -31,11 +31,4 @@ public enum MdgaSound {
OTHER_CONNECTED,
NOT_READY,
LEAVE,
JET,
EXPLOSION,
LOSE,
BONUS,
UI90,
MISSILE,
MATRIX,
}

View File

@@ -28,15 +28,6 @@ enum SoundAsset {
POWERUP("powerup.wav"),
ROBOT_READY("robotReady.wav"),
UNIT_READY("unitReady.wav"),
JET("jet-overhead.wav"),
EXPLOSION_1("exp.ogg"),
EXPLOSION_2("exp2.ogg"),
THUNDER("thunder.ogg"),
UI90("ui90.ogg"),
BONUS("bonus.ogg"),
LOSE("lose.ogg"),
MISSILE("missile.ogg"),
MATRIX("matrix.wav"),
CONNECTED("connected.wav");
private final String path;

View File

@@ -1,125 +0,0 @@
package pp.mdga.client.animation;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh.Type;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
public class Explosion {
private final Node rootNode;
private final MdgaApp app;
private final Vector3f location;
private ParticleEmitter fire;
private ParticleEmitter smoke;
private boolean triggered = false;
private final Material mat;
/**
* Konstruktor für die Explosion.
*
* @param app Die Hauptanwendung.
* @param rootNode Der Root-Knoten, an den die Explosion angefügt wird.
* @param location Der Ort der Explosion in World-Koordinaten.
*/
public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
this.app = app;
this.rootNode = rootNode;
this.location = location;
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
}
/**
* Initialisiert den Partikel-Emitter für die Explosion.
*/
private void initializeEmitter() {
fire = new ParticleEmitter("Effect", Type.Triangle,50);
fire.setMaterial(mat);
fire.setStartColor(ColorRGBA.Yellow);
fire.setEndColor(ColorRGBA.Red);
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
fire.getParticleInfluencer().setVelocityVariation(0.4f);
fire.setStartSize(0.1f);
fire.setEndSize(0.8f);
fire.setGravity(0, 0, -0.1f);
fire.setLowLife(0.5f);
fire.setHighLife(2.2f);
fire.setParticlesPerSec(0);
fire.setLocalTranslation(location);
smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
smoke.setMaterial(mat);
smoke.setImagesX(2);
smoke.setImagesY(2);
smoke.setStartColor(ColorRGBA.DarkGray);
smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.7f));
smoke.getParticleInfluencer().setVelocityVariation(0.5f);
smoke.setStartSize(0.2f);
smoke.setEndSize(0.5f);
smoke.setGravity(0, 0, -0.3f);
smoke.setLowLife(1.2f);
smoke.setHighLife(5.5f);
smoke.setParticlesPerSec(0);
smoke.setLocalTranslation(location);
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
}
/**
* Löst die Explosion aus.
*/
public void trigger() {
if (!triggered) {
triggered = true;
initializeEmitter();
}
rootNode.attachChild(fire);
fire.emitAllParticles();
fire.addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
if (elapsedTime > 10f) {
rootNode.detachChild(fire);
fire.removeControl(this);
}
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
});
rootNode.attachChild(smoke);
smoke.emitAllParticles();
smoke.addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
if (elapsedTime > 10f) {
rootNode.detachChild(smoke);
smoke.removeControl(this);
}
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
});
}
}

View File

@@ -1,173 +0,0 @@
package pp.mdga.client.animation;
import com.jme3.material.Material;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.view.GameView;
import java.util.UUID;
public class JetAnimation {
private final MdgaApp app; // Referenz auf die Hauptanwendung
private final Node rootNode; // Root-Knoten, an dem die Animation hängt
private Spatial jetModel; // Das Model des "jet"
private final Vector3f spawnPoint; // Spawnpunkt des Jets
private final Vector3f nodePoint; // Punkt des überflogenen Knotens
private final Vector3f despawnPoint; // Punkt, an dem der Jet despawnt
private final float curveHeight; // Maximale Höhe der Kurve
private final float animationDuration; // Dauer der Animation
private Explosion explosion;
private final UUID id;
/**
* Konstruktor für die ThrowAnimation-Klasse.
*
* @param app Die Hauptanwendung
* @param rootNode Der Root-Knoten, an dem der Jet angefügt wird
* @param uuid Die UUID des pieces
* @param targetPoint Der Punkt, an dem der Jet spawnt
* @param curveHeight Die maximale Höhe der Flugkurve
* @param animationDuration Die Gesamtdauer der Animation in Sekunden
*/
public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration) {
Vector3f spawnPoint = targetPoint.add(170, 50, 50);
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
Vector3f despawnPoint = targetPoint.add(-100, -100, 40);
this.app = app;
this.rootNode = rootNode;
this.spawnPoint = spawnPoint;
this.nodePoint = controlPoint;
this.despawnPoint = despawnPoint;
this.curveHeight = curveHeight;
this.animationDuration = animationDuration;
id = uuid;
explosion = new Explosion(app, rootNode, targetPoint);
}
/**
* Startet die Animation.
*/
public void start() {
app.getAcousticHandler().playSound(MdgaSound.JET);
spawnJet();
animateJet();
}
/**
* Spawnt den Jet an der spezifizierten Position.
*/
private void spawnJet() {
jetModel = app.getAssetManager().loadModel(Asset.jet.getModelPath());
jetModel.setLocalTranslation(spawnPoint);
jetModel.scale(Asset.jet.getSize());
jetModel.rotate(FastMath.HALF_PI, 0, 0);
jetModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.jet.getDiffPath()));
jetModel.setMaterial(mat);
rootNode.attachChild(jetModel);
}
/**
* Animiert den Jet entlang einer Kurve und lässt ihn anschließend verschwinden.
*/
private void animateJet() {
Vector3f controlPoint1 = spawnPoint.add(0, curveHeight, 0);
Vector3f controlPoint2 = nodePoint.add(0, curveHeight, 0);
BezierCurve3f curve = new BezierCurve3f(spawnPoint, controlPoint1, controlPoint2, despawnPoint);
app.getRootNode().addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
float progress = elapsedTime / animationDuration;
if(elapsedTime > 4.2f) {
explosion.trigger();
}
if (progress > 1) {
rootNode.detachChild(jetModel);
this.spatial.removeControl(this);
} else {
Vector3f currentPos = curve.interpolate(progress);
Vector3f direction = curve.interpolateDerivative(progress).normalizeLocal();
jetModel.setLocalTranslation(currentPos);
jetModel.lookAt(currentPos.add(direction), Vector3f.UNIT_Z);
jetModel.rotate(-FastMath.HALF_PI, 0, (float) Math.toRadians(-25));
}
if (elapsedTime > 6.0f) {
GameView gameView = (GameView) app.getView();
BoardHandler boardHandler = gameView.getBoardHandler();
boardHandler.throwPieceAnim(id);
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// Wird hier nicht benötigt
}
});
}
/**
* Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
*/
private static class BezierCurve3f {
private final Vector3f p0, p1, p2, p3;
public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
this.p0 = p0;
this.p1 = p1;
this.p2 = p2;
this.p3 = p3;
}
public Vector3f interpolate(float t) {
float u = 1 - t;
float tt = t * t;
float uu = u * u;
float uuu = uu * u;
float ttt = tt * t;
Vector3f point = p0.mult(uuu);
point = point.add(p1.mult(3 * uu * t));
point = point.add(p2.mult(3 * u * tt));
point = point.add(p3.mult(ttt));
return point;
}
public Vector3f interpolateDerivative(float t) {
float u = 1 - t;
float tt = t * t;
Vector3f derivative = p0.mult(-3 * u * u);
derivative = derivative.add(p1.mult(3 * u * u - 6 * u * t));
derivative = derivative.add(p2.mult(6 * u * t - 3 * tt));
derivative = derivative.add(p3.mult(3 * tt));
return derivative;
}
}
}

View File

@@ -1,138 +0,0 @@
package pp.mdga.client.animation;
import com.jme3.material.Material;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import java.util.UUID;
public class MissileAnimation {
private final Node rootNode; // Root-Knoten, an den die Animation gehängt wird
private final MdgaApp app; // Referenz auf die Hauptanwendung
private final Vector3f start; // Startpunkt der Rakete
private final Vector3f target; // Zielpunkt der Rakete
private final float flightTime; // Gesamtdauer des Flugs
private Explosion explosion;
private Spatial missileModel; // 3D-Modell der Rakete
private UUID id;
/**
* Konstruktor für die MissileAnimation.
*
* @param app Die Hauptanwendung.
* @param rootNode Der Root-Knoten, an den die Animation gehängt wird.
* @param target Der Zielpunkt der Rakete.
* @param flightTime Die Zeit, die die Rakete für den gesamten Flug benötigt.
*/
public MissileAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f target, float flightTime) {
this.app = app;
this.rootNode = rootNode;
this.flightTime = flightTime;
explosion = new Explosion(app, rootNode, target);
id = uuid;
this.target = target.add(new Vector3f(1.5f, -1, 0));
start = BoardHandler.gridToWorld(12, 0);
start.add(new Vector3f(0, 0, 0));
}
/**
* Startet die Raketenanimation.
*/
public void start() {
loadMissile();
app.getAcousticHandler().playSound(MdgaSound.MISSILE);
animateMissile();
}
/**
* Lädt das Raketenmodell und setzt es auf den Startpunkt.
*/
private void loadMissile() {
missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath()); // Lade das Missile-Modell
missileModel.scale(Asset.missile.getSize());
missileModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.missile.getDiffPath()));
missileModel.setMaterial(mat);
missileModel.setLocalTranslation(start); // Setze Startposition
rootNode.attachChild(missileModel); // Füge das Modell zur Szene hinzu
}
/**
* Animiert die Rakete entlang einer Parabel.
*/
private void animateMissile() {
missileModel.addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
float progress = elapsedTime / flightTime;
if (progress >= 0.95f) {
explosion.trigger();
}
if (progress >= 1) {
explosion.trigger();
// Flug abgeschlossen
rootNode.detachChild(missileModel); // Entferne Rakete nach dem Ziel
this.spatial.removeControl(this); // Entferne die Steuerung
return;
}
// Berechne die aktuelle Position entlang der Parabel
Vector3f currentPosition = computeParabolicPath(start, target, progress);
missileModel.setLocalTranslation(currentPosition);
// Passe die Ausrichtung an (Nase der Rakete zeigt in Flugrichtung)
Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
.subtract(currentPosition)
.normalizeLocal();
missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y); // Z ist oben, Y ist "Up"
missileModel.rotate(0, FastMath.HALF_PI, 0);
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// Keine Render-Logik benötigt
}
});
}
/**
* Berechnet eine Parabelbewegung von `start` zu `target`.
*
* @param start Der Startpunkt der Rakete.
* @param target Der Zielpunkt der Rakete.
* @param t Der Fortschritt des Flugs (0 bis 1).
* @return Die Position der Rakete entlang der Parabel.
*/
private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {
Vector3f midPoint = start.add(target).multLocal(0.5f); // Berechne die Mitte zwischen Start und Ziel
midPoint.addLocal(0, 0, 20); // Erhöhe den Scheitelpunkt der Parabel entlang der Z-Achse
// Quadratische Interpolation (Parabel)
Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
return FastMath.interpolateLinear(t, startToMid, midToTarget);
}
}

View File

@@ -9,12 +9,10 @@
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.animation.MissileAnimation;
import pp.mdga.client.animation.MoveControl;
import pp.mdga.client.animation.JetAnimation;
import pp.mdga.client.gui.DiceControl;
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import java.util.*;
@@ -202,7 +200,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
* @param y The y-coordinate on the grid
* @return The corresponding world position
*/
public static Vector3f gridToWorld(int x, int y) {
private static Vector3f gridToWorld(int x, int y) {
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
}
@@ -445,7 +443,6 @@ private void throwPiece(UUID uuid){
// Synchronisation oder Animation
pieceControl.rotateInit();
app.getAcousticHandler().playSound(MdgaSound.LOSE);
app.getModelSynchronize().animationEnd();
}
@@ -723,32 +720,10 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
*/
public void throwPieceAnim(UUID uuid){
pieces.get(uuid).getSpatial().addControl(new MoveControl(
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), ()->throwPiece(uuid))
);
}
/**
* Animates the throwing of a piece to the next available waiting node and plays jet animation.
*
* @param uuid the UUID of the piece to animate
*/
public void throwBombAnim(UUID uuid){
Vector3f targetPoint = pieces.get(uuid).getLocation();
JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6);
anim.start();
}
/**
* Animates the throwing of a piece to the next available waiting node and plays ship animation.
*
* @param uuid the UUID of the piece to animate
*/
public void throwMissileAnim(UUID uuid){
Vector3f targetPoint = pieces.get(uuid).getLocation();
MissileAnimation anim = new MissileAnimation(app, rootNode, uuid, targetPoint, 2);
anim.start();
pieces.get(uuid).getLocation(),
getNextWaitingNode(pieceColor.get(uuid)).getLocation(),
()->throwPiece(uuid)
));
}
/**

View File

@@ -7,8 +7,6 @@
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.FXAAFilter;
import com.jme3.post.ssao.SSAOFilter;
import com.jme3.scene.Spatial;
import com.jme3.shadow.DirectionalLightShadowFilter;
import com.jme3.shadow.EdgeFilteringMode;
@@ -39,8 +37,6 @@ public class CameraHandler {
private Color ownColor;
private boolean init;
private boolean initRot;
private SSAOFilter ssaoFilter;
private FXAAFilter fxaaFilter;
/**
* Constructor for the CameraHandler. Initializes the camera settings and lighting.
@@ -69,9 +65,6 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
dlsf.setEnabled(true);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
dlsf.setShadowIntensity(0.7f);
ssaoFilter = new SSAOFilter(6, 10f, 0.33f, 0.61f);
// ssaoFilter = new SSAOFilter();
fxaaFilter = new FXAAFilter();
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);
@@ -89,8 +82,6 @@ public void init(Color ownColor) {
app.getRootNode().addLight(ambient);
app.getRootNode().attachChild(sky);
fpp.addFilter(dlsf);
fpp.addFilter(ssaoFilter);
fpp.addFilter(fxaaFilter);
init = true;
initRot = true;
this.ownColor = ownColor;

View File

@@ -107,8 +107,8 @@ private static Asset getLoadedAsset(String assetName) {
case "radar" -> Asset.radar;
case "ship" -> Asset.ship;
case "tank" -> Asset.tank;
case "treeSmall" -> Asset.treeSmall;
case "treeBig" -> Asset.treeBig;
case "tree_small" -> Asset.treeSmall;
case "tree_big" -> Asset.treeBig;
default -> throw new IllegalStateException("Unexpected value: " + assetName);
};
}

View File

@@ -1,63 +1,4 @@
package pp.mdga.client.dialog;
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView;
import pp.mdga.game.Color;
public class InterruptDialog extends Dialog {
private ButtonRight forceButton;
private LabelButton label;
private String text = "";
public InterruptDialog(MdgaApp app, Node node) {
super(app, node);
forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
label = new LabelButton(app, node, "Warte auf " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
float offset = 2.8f;
label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
}
@Override
protected void onShow() {
if(app.getGameLogic().isHost()) {
forceButton.show();
}
label.show();
}
@Override
protected void onHide() {
forceButton.hide();
label.hide();
}
public void setColor(Color color) {
switch (color) {
case AIRFORCE:
text = "Luftwaffe";
break;
case ARMY:
text = "Heer";
break;
case NAVY:
text = "Marine";
break;
case CYBER:
text = "CIR";
break;
}
}
public class InterruptDialog {
}

View File

@@ -92,16 +92,4 @@ public void resetPort() {
public void connectToServer() {
connectServer();
}
public void disconnect() {
NetworkSupport network = getNetwork();
if (network != null) {
try {
network.disconnect();
} catch (Exception e) {
System.err.println("Error while disconnecting: " + e.getMessage());
}
}
}
}

View File

@@ -14,8 +14,6 @@ public abstract class NetworkDialog extends Dialog {
private String hostname;
private int portNumber;
private Future<Object> connectionFuture;
private MdgaServer serverInstance;
private Thread serverThread;
public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
super(app, node);
@@ -30,6 +28,7 @@ public void setPortNumber(int portNumber) {
this.portNumber = portNumber;
}
protected Object initNetwork() {
try {
this.network.initNetwork(this.hostname, this.portNumber);
@@ -40,49 +39,25 @@ protected Object initNetwork() {
}
protected void connectServer() {
try {
connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
} catch (NumberFormatException var2) {
throw new NumberFormatException("Port must be a number");
}
}
protected void startServer() {
serverThread = new Thread(() -> {
(new Thread(() -> {
try {
serverInstance = new MdgaServer(portNumber);
serverInstance.run();
MdgaServer mdgaServer = new MdgaServer(portNumber);
mdgaServer.run();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
serverThread.start();
}
public void shutdownServer() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.err.println("Thread was interrupted: " + e.getMessage());
}
if (serverInstance != null) {
serverInstance.shutdown();
serverInstance = null;
}
if (serverThread != null && serverThread.isAlive()) {
serverThread.interrupt();
try {
serverThread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
serverThread = null;
}
})).start();
}
public void update(float delta) {
@@ -90,14 +65,14 @@ public void update(float delta) {
try {
this.connectionFuture.get();
} catch (ExecutionException ignored) {
// TODO: implement
// todo: implement
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
public NetworkSupport getNetwork() {
public NetworkSupport getNetwork(){
return network;
}
}

View File

@@ -177,109 +177,6 @@ public String getName() {
"CarryPro",
"ProBaiter",
"GameWarden",
"KartoffelKönig",
"SaufenderWolf",
"WurstGriller",
"Flitzekacke",
"BratwurstBub",
"Hoppeldoppels",
"BananenMensch",
"KlopapierGuru",
"SchnitzelKing",
"NerdNomade",
"Dönertänzer",
"GlitzerGurke",
"SchinkenShrek",
"KäseKalle",
"SchokoSchnecke",
"KeksKämpfer",
"QuarkPiraten",
"Müslimonster",
"KnuddelNase",
"FantaFighter",
"SchnapsSaurier",
"Wackelpudding",
"ZitronenZock",
"FettWurst",
"PlüschPanda",
"Zuckerschnur",
"FluffiKopf",
"DonutDöner",
"VollpfostenX",
"Schraubenschlüssel",
"Witzepumper",
"ToastTraum",
"FroschFighter",
"KrümelTiger",
"RegenWolke",
"PuddingPower",
"KoffeinKrieger",
"SpeckSchlumpf",
"SuperSuppe",
"BierBärchen",
"FischBär",
"Flauschi",
"Schokomonster",
"ChaosKäse",
"FlitzLappen",
"WurstWombat",
"KrümelMensch",
"PuddingBär",
"ZickZack",
"Schwabel",
"Fluffi",
"RülpsFrosch",
"PommesPapa",
"QuarkBär",
"KnusperKönig",
"ToastBrot",
"Ploppster",
"Schleimschwein",
"Äpfelchen",
"Knallbonbon",
"KaffeeKopf",
"WackelWurst",
"RennKeks",
"BröselBub",
"ZockerBrot",
"BierWurm",
"StinkFlummi",
"SchlumpfKing",
"PurzelBär",
"FlinkFluff",
"PloppPudel",
"Schnorchel",
"FliegenKopf",
"PixelPommes",
"SchwipsWürst",
"WutzBär",
"KnuddelKeks",
"FantaFlumm",
"ZockerKäse",
"LachHäufchen",
"GurkenGuru",
"PonySchnitzel",
"NudelNinja",
"VulkanKeks",
"WasserToast",
"MenschSalat",
"KampfKohlenhydrate",
"SockenZirkus",
"SchwimmBärchen",
"TanzenderDachgepäckträger",
"PizzamarktMensch",
"ZahnarztZocker",
"RollerCoasterTester",
"WaschmaschinenPilot",
"WitzigeZwiebel",
"Pillenschlucker",
"ZwiebelReiter",
"HüpfenderKaktus",
"KochenderAsteroid",
"ChaosKarotte",
"WolkenFurz",
"SchnitzelPartikel",
"WackelBiene",
};
Random random = new Random();

View File

@@ -3,20 +3,13 @@
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView;
import java.util.prefs.Preferences;
public class VideoSettingsDialog extends Dialog {
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
private ButtonRight fullscreenButton;
private MenuButton backButton;
private ButtonRight restartButton;
private ButtonLeft hdButton9;
private ButtonLeft fullHdButton9;
@@ -36,24 +29,20 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
restartButton = new ButtonRight(app, node, MdgaApp::restartApp, "Neustart", 1);
fullscreenButton = new ButtonRight(app, node, () -> updateResolution(0, 0, 0, true), "Vollbild", 1);
hdButton9 = new ButtonLeft(app, node, () -> updateResolution(1280, 720, 1.0f, false), "hd 16:9", 10);
fullHdButton9 = new ButtonLeft(app, node, () -> updateResolution(1920, 1080, 2.25f, false), "full hd 16:9", 10);
wqhdButton9 = new ButtonLeft(app, node, () -> updateResolution(2560, 1440, 4.0f, false), "wqhd 16:9", 10);
// MenuButton für verschiedene Auflösungen erstellen
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f), "hd 16:9", 10);
fullHdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1920, 1080, 2.25f), "full hd 16:9", 10);
wqhdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(2560, 1440, 4.0f), "wqhd 16:9", 10);
hdButton10 = new ButtonRight(app, node, () -> updateResolution(1280, 800, 1.0f, false), "hd 16:10", 10);
fullHdButton10 = new ButtonRight(app, node, () -> updateResolution(1920, 1200, 2.25f, false), "full hd 16:10", 10);
wqhdButton10 = new ButtonRight(app, node, () -> updateResolution(2560, 1600, 4.0f, false), "wqhd 16:10", 10);
hdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1280, 800, 1.0f), "hd 16:10", 10);
fullHdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1920, 1200, 2.25f), "full hd 16:10", 10);
wqhdButton10 = new ButtonRight(app, node, () -> app.updateResolution(2560, 1600, 4.0f), "wqhd 16:10", 10);
float offset = 2.8f;
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
hdButton10.setPos(new Vector2f(hdButton10.getPos().x, MenuButton.VERTICAL - offset));
fullscreenButton.setPos(new Vector2f(fullscreenButton.getPos().x, MenuButton.VERTICAL - offset));
offset += 1.5f;
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
@@ -79,7 +68,6 @@ protected void onShow() {
fullHdButton10.show();
wqhdButton10.show();
fullscreenButton.show();
backButton.show();
}
@@ -95,9 +83,7 @@ protected void onHide() {
fullHdButton10.hide();
wqhdButton10.hide();
fullscreenButton.hide();
backButton.hide();
restartButton.hide();
}
public void update() {
@@ -105,12 +91,4 @@ public void update() {
return;
}
}
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
if(width != prefs.getInt("width", 1280) || height != prefs.getInt("height", 720) || isFullscreen != prefs.getBoolean("fullscreen", false)) {
restartButton.show();
}
app.updateResolution(width, height, imageFactor, isFullscreen);
}
}

View File

@@ -60,7 +60,7 @@ private Node createNum(){
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Black);
circle.setMaterial(mat);
// root.attachChild(circle);
root.attachChild(circle);
BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt");
num = new BitmapText(guiFont);
num.setSize(0.3f);

View File

@@ -94,8 +94,7 @@ public void update(float tpf) {
}
public void addSpatial(Spatial card) {
if(root == null) cardBuffer.add(card);
else root.attachChild(card);
cardBuffer.add(card);
}
public void deleteSpatial(Spatial spatial) {

View File

@@ -85,19 +85,6 @@ public void addCard(BonusCard card) {
bonusCardControlMap.get(card).setNumCard(newNum);
}
public void removeCard(BonusCard card){
if(bonusCardControlMap.containsKey(card)){
bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1);
if(bonusCardIntegerMap.get(card) <= 0){
cardLayer.deleteSpatial(bonusCardControlMap.get(card).getRoot());
bonusCardIntegerMap.remove(card);
bonusCardControlMap.remove(card);
}
}
}
public void clearSelectableCards() {
for (CardControl control : selectableCards) {
control.setSelectable(false);
@@ -131,8 +118,6 @@ public void selectCard(CardControl cardControl) {
cardControl.select();
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
}
app.getModelSynchronize().selectCard(cardSelect);
}
public Camera getCardLayerCamera() {

View File

@@ -74,31 +74,8 @@ public void hideDice() {
cardLayerHandler.hideDice();
}
//add own handCard
public void addCardOwn(BonusCard card) {
public void addCard(BonusCard card) {
cardLayerHandler.addCard(card);
playerNameHandler.addCard(ownColor);
actionTextHandler.drawCardOwn(ownColor);
}
public void playCardOwn(BonusCard card){
getEffectByCard(card);
cardLayerHandler.removeCard(card);
playerNameHandler.removeCard(ownColor);
}
public void playCardEnemy(Color color, BonusCard card) {
getEffectByCard(card);
playerNameHandler.removeCard(color);
}
private void getEffectByCard(BonusCard bonus){
switch(bonus){
case SWAP -> swap();
case TURBO -> turbo();
case SHIELD -> shield();
default -> throw new RuntimeException("invalid card");
}
}
public void clearSelectableCards() {
@@ -148,11 +125,9 @@ public void hideText(){
actionTextHandler.hide();
}
//addCard Enemy (DrawCardNotification)
public void drawCard(Color color) {
//Color != ownColor
actionTextHandler.drawCard(playerNameHandler.getName(color), color);
playerNameHandler.addCard(color);
if (ownColor == color) actionTextHandler.drawCardOwn(color);
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
}
public void finish(Color color){
@@ -166,6 +141,4 @@ public void rollRankingResult(Color color, int eye){
}
}

View File

@@ -4,27 +4,23 @@
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
import com.jme3.ui.Picture;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
public class PlayerNameHandler {
private final BitmapFont playerFont;
private final Node playerNameNode;
private final List<Color> playerOrder;
private final Map<Color, String> colorNameMap;
private final Map<Color, Integer> colorCardMap;
private final AppSettings appSettings;
private final AssetManager assetManager;
private Color ownColor;
@@ -47,7 +43,6 @@ public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings ap
playerNameNode = new Node("player name node");
playerOrder = new ArrayList<>();
colorNameMap = new HashMap<>();
colorCardMap = new HashMap<>();
this.appSettings = appSettings;
this.assetManager = assetManager;
}
@@ -69,38 +64,13 @@ private void drawPlayers(){
if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
Node nameParent = new Node("nameParent");
nameParent.attachChild(createName(colorNameMap.get(color), i == 0, color == ownColor));
nameParent.attachChild(createColor(color));
BitmapText name = createName(colorNameMap.get(color), i == 0, color == ownColor);
nameParent.attachChild(name);
if(colorCardMap.getOrDefault(color, 0) > 0){
Picture pic = createHandCard(name.getLineWidth());
nameParent.attachChild(pic);
nameParent.attachChild(createCardNum(colorCardMap.get(color), pic.getWidth(), pic.getLocalTranslation().getX()));
}
nameParent.setLocalTranslation(50,appSettings.getWindowHeight()-PADDING_TOP- MARGIN_NAMES *i,0);
playerNameNode.attachChild(nameParent);
}
}
private Spatial createCardNum(int num, float lastWidth, float lastX ) {
BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45
hudText.setSize(TEXT_SIZE);
hudText.setColor(NORMAL_COLOR);
hudText.setText(String.valueOf(num));
hudText.setLocalTranslation(lastX + lastWidth + 20,hudText.getHeight()/2, 0);
return hudText;
}
private Picture createHandCard(float width) {
Picture pic = new Picture("HUD Picture");
pic.setImage(assetManager, "./Images/handcard.png", true);
pic.setWidth(IMAGE_SIZE);
pic.setHeight(IMAGE_SIZE);
pic.setPosition(-pic.getWidth()/2 + width + PADDING_LEFT * 2 ,-pic.getHeight()/2);
return pic;
}
private String imagePath(Color color){
String root = "./Images/name_pictures/";
return switch(color){
@@ -123,7 +93,7 @@ private Spatial createColor(Color color) {
private BitmapText createName(String name, boolean first, boolean own){
private Spatial createName(String name, boolean first, boolean own){
BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45
hudText.setSize(TEXT_SIZE);
@@ -154,18 +124,5 @@ public String getName(Color color){
return colorNameMap.get(color);
}
public void addCard(Color color){
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) + 1);
drawPlayers();
}
public void removeCard(Color color){
if(colorCardMap.containsKey(color)){
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) - 1);
if(colorCardMap.get(color) <= 0) colorCardMap.remove(color);
}
drawPlayers();
}
}

View File

@@ -3,9 +3,7 @@
import com.jme3.network.*;
import com.jme3.network.serializing.Serializer;
import com.jme3.network.serializing.serializers.EnumSerializer;
import pp.mdga.Resources;
import pp.mdga.game.*;
import pp.mdga.game.card.*;
import pp.mdga.message.client.*;
import pp.mdga.message.server.*;
import pp.mdga.server.ServerGameLogic;
@@ -125,7 +123,7 @@ private void initializeSerializables() {
Serializer.registerClass(NoTurnMessage.class);
Serializer.registerClass(PauseGameMessage.class);
Serializer.registerClass(PlayCardMessage.class);
Serializer.registerClass(PossibleCardsMessage.class);
Serializer.registerClass(PossibleCardMessage.class);
Serializer.registerClass(PossiblePieceMessage.class);
Serializer.registerClass(RankingResponseMessage.class);
Serializer.registerClass(RankingRollAgainMessage.class);
@@ -137,7 +135,6 @@ private void initializeSerializables() {
Serializer.registerClass(UpdateReadyMessage.class);
Serializer.registerClass(UpdateTSKMessage.class);
Serializer.registerClass(WaitPieceMessage.class);
Serializer.registerClass(IncorrectRequestMessage.class);
Serializer.registerClass(Player.class);
Serializer.registerClass(Statistic.class);
Serializer.registerClass(Board.class);
@@ -145,17 +142,10 @@ private void initializeSerializables() {
Serializer.registerClass(Piece.class);
Serializer.registerClass(BonusNode.class);
Serializer.registerClass(StartNode.class);
Serializer.registerClass(PlayerData.class);
Serializer.registerClass(HomeNode.class);
Serializer.registerClass(PowerCard.class);
Serializer.registerClass(TurboCard.class);
Serializer.registerClass(SwapCard.class);
Serializer.registerClass(ShieldCard.class);
Serializer.registerClass(HiddenCard.class);
Serializer.registerClass(Color.class, new EnumSerializer());
Serializer.registerClass(PieceState.class, new EnumSerializer());
Serializer.registerClass(ShieldState.class, new EnumSerializer());
Serializer.registerClass(BonusCard.class, new EnumSerializer());
Serializer.registerClass(PlayerDataMessage.class);
Serializer.registerClass(StartBriefingMessage.class);
}
private void registerListeners() {
@@ -208,31 +198,12 @@ private void messageReceived(HostedConnection source, ClientMessage message) {
pendingMessages.add(new ReceivedMessage(message, source.getId()));
}
/**
* This method will be used to handle all connections which are connected to the server.
* It will check if the maximum number of connected clients are already reached. If yes it will send a
* LobbyDenyMessage to the given hostedConnection parameter and close it, otherwise it will send a
* LobbyAcceptMessage to the given hostedConnection parameter. In Addition, if the number of connected clients is
* equal to 1 it will set the host of the game to the id of the given hostedConnection parameter.
*
* @param server as the server which is contains all connections as a Server object.
* @param hostedConnection as the connection which is added to the server as a HostedConnection object.
*/
@Override
public void connectionAdded(Server server, HostedConnection hostedConnection) {
System.out.println("new connection " + hostedConnection); //NON-NLS
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
if (this.myServer.getConnections().size() > Resources.MAX_PLAYERS) {
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyDenyMessage());
hostedConnection.close("");
} else {
if (hostedConnection.getAddress().contains("127.0.0.1") && this.logic.getGame().getHost() == -1) {
this.logic.getGame().setHost(hostedConnection.getId());
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage(hostedConnection.getId()));
} else {
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage());
}
if (this.myServer.getConnections().size() == 1) {
this.logic.getGame().setHost(hostedConnection.getId());
}
}
@@ -307,21 +278,4 @@ public void broadcast(ServerMessage message) {
public void disconnectClient(int id) {
this.myServer.getConnection(id).close("");
}
/**
* This method will be used to shut down the server.
* It will iterate threw all connections of myServer attribute and check if they are equal to null. If not they will
* be closed. After that the myServer attribute will be closed and this program will be exited with the exit code 0.
*/
@Override
public void shutdown() {
for (HostedConnection client : this.myServer.getConnections()) {
if (client != null) {
client.close("Host closed the server.");
}
}
this.myServer.close();
this.exit(0);
}
}

View File

@@ -206,19 +206,11 @@ public void addCeremonyParticipant(Color color, int pos, String name) {
ceremonyButtons.add(button);
if(state.equals(SubState.AWARD_CEREMONY)) {
button.hide();
button.show();
}
}
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
ceremonyDialog.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
ceremonyDialog.hide();
ceremonyDialog.show();
}
public void afterGameCleanup() {
ceremonyDialog.prepare();
}
}

View File

@@ -1,16 +1,31 @@
package pp.mdga.client.view;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaState;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.board.CameraHandler;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.dialog.InterruptDialog;
import pp.mdga.client.gui.GuiHandler;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.GameNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayerInGameNotification;
import pp.mdga.notification.RollDiceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.SelectableSwapNotification;
import pp.mdga.notification.ShieldActiveNotification;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class GameView extends MdgaView {
private BoardHandler boardHandler;
@@ -20,39 +35,28 @@ public class GameView extends MdgaView {
private ButtonLeft leaveButton;
private ButtonRight confirmButton;
private ButtonRight noPowerButton;
private Color ownColor = null;
private InterruptDialog interruptDialog;
private FilterPostProcessor fpp;
private Node guiHandlerNode = new Node();
public GameView(MdgaApp app) {
super(app);
setOwnColor(Color.AIRFORCE);
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
leaveButton = new ButtonLeft(app, overlayNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
noPowerButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Verzichten", 1);
interruptDialog = new InterruptDialog(app, guiNode);
fpp = new FilterPostProcessor(app.getAssetManager());
this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, rootNode, fpp);
guiHandler = new GuiHandler(app, guiHandlerNode);
guiHandler = new GuiHandler(app, guiNode);
guiNode.attachChild(guiHandlerNode);
}
@Override
public void onEnter() {
setOwnColor(Color.AIRFORCE);
camera.init(ownColor);
boardHandler.init();
guiHandler.init(ownColor);
@@ -60,6 +64,13 @@ public void onEnter() {
app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START);
// guiHandler.addPlayer(Color.AIRFORCE, "Cedric");
// guiHandler.addPlayer(Color.ARMY, "Ben");
// guiHandler.addPlayer(Color.CYBER, "Felix");
// guiHandler.addPlayer(Color.NAVY, "Daniel");
}
@Override
@@ -70,7 +81,6 @@ public void onLeave() {
confirmButton.hide();
noPowerButton.hide();
app.getViewPort().removeProcessor(fpp);
}
@@ -115,45 +125,10 @@ public Color getOwnColor() {
}
public void needConfirm() {
noPowerButton.hide();
confirmButton.show();
}
public void noConfirm() {
confirmButton.hide();
}
public void needNoPower() {
confirmButton.hide();
noPowerButton.show();
}
public void noNoPower() {
noPowerButton.show();
}
public void enterInterrupt(Color color) {
enterOverlay(Overlay.INTERRUPT);
guiNode.detachChild(guiHandlerNode);
app.getGuiNode().attachChild(guiNode);
app.getInputSynchronize().setClickAllowed(false);
interruptDialog.setColor(color);
interruptDialog.show();
}
public void leaveInterrupt() {
leaveOverlay(Overlay.INTERRUPT);
app.getGuiNode().detachChild(guiNode);
guiNode.attachChild(guiHandlerNode);
app.getInputSynchronize().setClickAllowed(true);
app.getAcousticHandler().playSound(MdgaSound.START);
interruptDialog.hide();
}
}

View File

@@ -18,7 +18,6 @@
import pp.mdga.client.button.LobbyButton;
import pp.mdga.client.button.SettingsButton;
import pp.mdga.game.Color;
import pp.mdga.message.client.StartGameMessage;
import pp.mdga.notification.GameNotification;
public class LobbyView extends MdgaView {
@@ -26,7 +25,6 @@ public class LobbyView extends MdgaView {
private ButtonLeft leaveButton;
private ButtonRight readyButton;
private ButtonRight startButton;
private LobbyButton cyberButton;
private LobbyButton airforceButton;
@@ -44,7 +42,6 @@ public LobbyView(MdgaApp app) {
leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1);
readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 1);
startButton = new ButtonRight(app, guiNode, () -> app.getGameLogic().selectStart(), "Starten", 7);
cyberButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.CYBER), Color.CYBER);
airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
@@ -64,10 +61,6 @@ public void onEnter() {
leaveButton.show();
readyButton.show();
if(app.getGameLogic().isHost()) {
startButton.show();
}
cyberButton.show();
airforceButton.show();
armyButton.show();
@@ -102,7 +95,6 @@ public void onEnter() {
public void onLeave() {
leaveButton.hide();
readyButton.hide();
startButton.hide();
airforceButton.hide();
armyButton.hide();
@@ -231,10 +223,6 @@ private void toggleTsk(Color color) {
break;
}
if(isReady) {
setReady(own, false);
}
switch (taken) {
case NOT:
app.getModelSynchronize().selectTsk(color);

View File

@@ -7,6 +7,9 @@
import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.dialog.StartDialog;
import java.net.Inet4Address;
import java.net.UnknownHostException;
public class MainView extends MdgaView {
private enum SubState {
HOST,
@@ -60,12 +63,12 @@ public void onUpdate(float tpf) {
@Override
protected void onEnterOverlay(Overlay overlay) {
guiNode.detachChild(background);
settingsNode.attachChild(background);
overlayNode.attachChild(background);
}
@Override
protected void onLeaveOverlay(Overlay overlay) {
settingsNode.detachChild(background);
overlayNode.detachChild(background);
guiNode.attachChild(background);
}
@@ -93,7 +96,6 @@ private void mainMenu() {
private void tryHost() {
int port = 0;
String text = hostDialog.getPort();
app.getGameLogic().selectHost("");
try {
port = Integer.parseInt(text);
@@ -106,6 +108,10 @@ private void tryHost() {
} catch (InterruptedException ignored) {
}
hostDialog.connectServerAsClient();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setHost(port);
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return;
@@ -121,7 +127,6 @@ private void tryJoin() {
int port = 0;
String ip = joinDialog.getIpt();
String portText = joinDialog.getPort();
app.getGameLogic().selectJoin("");
try {
// Validate the port
@@ -135,6 +140,11 @@ private void tryJoin() {
app.getModelSynchronize().setName(startDialog.getName());
joinDialog.setHostname(ip);
joinDialog.connectToServer();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setJoin(ip, port);
return;
}
} catch (IllegalArgumentException e) {
@@ -224,13 +234,5 @@ public void back() {
break;
}
}
public JoinDialog getJoinDialog() {
return joinDialog;
}
public HostDialog getHostDialog() {
return hostDialog;
}
}

View File

@@ -2,12 +2,9 @@
import com.jme3.asset.TextureKey;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Quad;
import com.jme3.system.NanoTimer;
import com.jme3.texture.Texture;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
@@ -25,7 +22,7 @@ public enum Overlay {
protected MdgaApp app;
protected Node rootNode = new Node("View Root");
protected Node guiNode = new Node("View Root GUI");
protected Node settingsNode = new Node("View Root Overlay");
protected Node overlayNode = new Node("View Root Overlay");
private SettingsButton settingsButton;
@@ -33,18 +30,15 @@ public enum Overlay {
private VideoSettingsDialog videoSettingsDialog;
private AudioSettingsDialog audioSettingsDialog;
protected LabelButton infoLabel = null;
protected NanoTimer infoTimer = new NanoTimer();
private int settingsDepth = 0;
public MdgaView(MdgaApp app) {
this.app = app;
settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
settingsDialog = new SettingsDialog(app, settingsNode, this);
videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this);
audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this);
settingsDialog = new SettingsDialog(app, overlayNode, this);
videoSettingsDialog = new VideoSettingsDialog(app, overlayNode, this);
audioSettingsDialog = new AudioSettingsDialog(app, overlayNode, this);
}
public void enter() {
@@ -86,11 +80,6 @@ public void update(float tpf) {
videoSettingsDialog.update();
audioSettingsDialog.update();
if (null != infoLabel && infoTimer.getTimeInSeconds() > 5) {
infoLabel.hide();
infoLabel = null;
}
onUpdate(tpf);
}
@@ -124,7 +113,7 @@ protected Geometry createBackground(String texturePath) {
public void enterSettings() {
enterOverlay(Overlay.SETTINGS);
app.getGuiNode().attachChild(settingsNode);
app.getGuiNode().attachChild(overlayNode);
settingsDialog.show();
@@ -134,7 +123,7 @@ public void enterSettings() {
public void leaveSettings() {
leaveOverlay(Overlay.SETTINGS);
app.getGuiNode().detachChild(settingsNode);
app.getGuiNode().detachChild(overlayNode);
settingsDialog.hide();
@@ -204,24 +193,4 @@ public void pressForward() {
ceremonyView.forward();
}
}
public void showInfo(String error, boolean isError) {
infoTimer.reset();
if(null != infoLabel) {
infoLabel.hide();
}
infoLabel = new LabelButton(app, guiNode, error, new Vector2f(5.5f, 2), new Vector2f(0.5f, AbstractButton.VERTICAL - 0.5f), false);
ColorRGBA color;
if(isError) {
color = ColorRGBA.Red.clone();
} else {
color = ColorRGBA.Green.clone();
}
infoLabel.setColor(ColorRGBA.Black, color);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -1,5 +1,7 @@
world 0,0 90
#tree_small 1,1 0
#tree_big 0,0 0
#Marine Pos
marine 4,-5 270
@@ -129,144 +131,3 @@ node_home_blue 4,0 0
node_home_blue 3,0 0
node_home_blue 2,0 0
node_home_blue 1,0 0
# Randomly Distributed Trees within Radius 12 to 40
treeSmall 10,15 180
treeBig -15,12 45
treeSmall -8,-22 270
treeBig 22,8 90
treeSmall -18,-10 135
treeBig 9,24 300
treeSmall 17,-9 60
treeBig -20,5 330
treeSmall -14,18 200
treeBig 25,-7 120
treeBig -12,-18 150
treeSmall 19,-16 45
treeBig 7,10 90
treeBig -19,-9 270
treeSmall 21,4 110
treeBig -11,17 300
treeSmall 3,-21 360
treeSmall -23,14 100
treeBig 4,26 330
treeSmall 12,13 270
treeBig -18,8 45
treeBig 11,-10 135
treeSmall 16,5 180
treeBig -13,-17 330
treeSmall -2,14 270
#treeBig 7,9 300
treeSmall 23,-10 240
treeBig -6,18 180
treeSmall 5,27 270
treeBig 14,-11 60
treeSmall 9,-16 180
treeBig -12,22 240
treeBig 18,7 360
treeSmall -24,-4 200
treeBig -8,21 300
treeSmall 12,-19 120
treeBig 6,-12 180
treeSmall -11,10 75
treeBig 9,6 270
treeSmall 8,-14 150
treeBig 3,18 30
treeSmall 17,13 100
treeBig -9,20 90
treeBig 6,-22 330
treeSmall -20,7 45
treeBig 21,11 150
treeSmall 15,-18 270
treeBig -3,-12 200
treeBig 12,-28 330
treeSmall -17,-7 120
treeBig -10,9 300
treeSmall 2,-14 240
treeBig 24,2 360
treeSmall 4,-13 300
treeBig -19,20 90
#treeSmall -11,5 45
treeBig 15,9 180
treeSmall -6,10 240
treeBig 3,15 30
treeSmall 9,-19 150
treeBig -21,-4 330
treeSmall 19,11 270
treeSmall 12,24 110
treeBig -13,15 45
treeSmall 7,-15 240
treeBig 26,-8 300
treeSmall -16,14 120
treeBig 14,18 360
treeSmall 8,21 100
treeBig -8,-18 240
treeSmall 9,15 180
treeBig 10,-20 270
treeSmall 2,27 90
treeBig 18,12 300
treeSmall -10,-14 150
treeBig -15,16 330
treeSmall -9,19 45
treeBig 17,-14 120
treeSmall 5,-25 180
treeBig 7,23 30
treeSmall -14,-12 200
treeBig 6,-16 300
treeSmall -20,-8 100
treeBig 4,11 240
treeSmall 24,-15 90
treeSmall -19,-19 360
treeBig 20,8 45
treeSmall 3,22 270
treeBig 13,-9 180
treeSmall -11,18 150
treeBig -17,-4 300
treeSmall 5,-14 240
treeBig 9,17 330
treeSmall 15,13 90
treeBig -21,18 30
treeSmall 6,20 100
treeBig -16,22 180
treeSmall -5,18 360
treeBig 22,11 45
treeSmall 10,-23 240
treeBig -10,-16 300
treeSmall -17,14 120
treeBig 20,4 150
treeSmall 11,-22 180
treeBig -24,-11 200
treeSmall 14,17 150
treeBig -8,-12 300
treeSmall 7,-18 100
treeBig -5,16 330
treeSmall 16,-14 200
treeBig 18,-8 90
treeSmall -23,-9 45
treeBig 24,10 300
treeSmall -4,19 180
treeBig 12,-5 330
treeSmall -19,16 100
treeBig 14,20 150
treeSmall 9,12 180
treeBig -22,8 60
treeSmall 6,18 360
treeBig 25,-9 45
treeBig -10,12 240
treeSmall 19,-17 100
treeSmall -13,19 90
treeSmall 16,-12 120
treeBig 22,-6 45
treeSmall -18,15 200
treeBig 14,-10 300
treeBig 6,10 330
treeSmall 17,18 90
treeBig -20,4 180
treeBig 19,-16 300
treeSmall -15,9 270
treeBig 12,22 360

File diff suppressed because one or more lines are too long

View File

@@ -1,32 +0,0 @@
# Blender MTL File: 'untitled.blend'
# Material Count: 3
newmtl Material.001
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd untiffftled.jpg
newmtl Material.002
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd untiffftled.jpg
newmtl Material.004
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd untiffftled.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 0 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 0 B

View File

@@ -0,0 +1,4 @@
package pp.mdga.client.settings;
public class AudioSettings {
}

View File

@@ -0,0 +1,4 @@
package pp.mdga.client.settings;
public class VideoSettings {
}

View File

@@ -1,79 +0,0 @@
package pp.mdga;
import java.util.ResourceBundle;
/**
* Provides access to the resource bundle of the game.
*
* @see #BUNDLE
*/
public class Resources {
/**
* Create Resources constants.
*/
public static final int MAX_PLAYERS = 4;
public static final int MAX_PIECES = 4;
public static final int MAX_EYES = 6;
/**
* The resource bundle for the MDGA game.
*/
public static final ResourceBundle BUNDLE = ResourceBundle.getBundle("mdga"); //NON-NLS
/**
* Gets a string for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static String stringLookup(String key) {
return BUNDLE.getString(key);
}
/**
* Gets a int for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static int intLookup(String key) {
return Integer.parseInt(BUNDLE.getString(key));
}
/**
* Gets a boolean for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static boolean boolLookup(String key) {
return Boolean.parseBoolean(BUNDLE.getString(key));
}
/**
* Gets a double for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static double doubleLookup(String key) {
return Double.parseDouble(BUNDLE.getString(key));
}
/**
* Private constructor to prevent instantiation.
*/
private Resources() { /* do not instantiate */ }
}

View File

@@ -1,8 +1,9 @@
package pp.mdga.client;
import pp.mdga.client.ceremonystate.CeremonyStates;
import pp.mdga.client.ceremonystate.PodiumState;
import pp.mdga.client.ceremonystate.StatisticsState;
import pp.mdga.client.ceremonyState.CeremonyStates;
import pp.mdga.client.ceremonyState.PodiumState;
import pp.mdga.client.ceremonyState.StatisticsState;
import pp.mdga.notification.CeremonyNotification;
public class CeremonyState extends ClientState {
@@ -11,38 +12,21 @@ public class CeremonyState extends ClientState {
private final PodiumState podiumState = new PodiumState(this, logic);
private final StatisticsState statisticsState = new StatisticsState(this, logic);
/**
* Creates a new CeremonyState
*
* @param parent the parent state
* @param logic the game logic
*/
public CeremonyState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
/**
* Enters the new state machine
*/
@Override
public void enter() {
setState(podiumState);
logic.addNotification(createCeremonyNotification());
}
/**
* exits this state
*/
@Override
public void exit() {
currentState.exit();
}
/**
* This method is used to set a new SubState
*
* @param state the state to be set
*/
public void setState(CeremonyStates state){
if(this.currentState != null){
this.currentState.exit();
@@ -51,29 +35,14 @@ public void setState(CeremonyStates state){
currentState = state;
}
/**
* This method get the PodiumState
*
* @return the PodiumState
*/
public PodiumState getPodiumState(){
return podiumState;
}
/**
* This method get the StatisticsState
*
* @return the StatisticsState
*/
public StatisticsState getStatisticsState(){
return statisticsState;
}
/**
* This method is used to get the current State
*
* @return the current State
*/
public CeremonyStates getState(){
return currentState;
}

View File

@@ -1,23 +1,18 @@
package pp.mdga.client;
import pp.mdga.Resources;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.game.Game;
import pp.mdga.game.Piece;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.ClientMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.InfoNotification;
import pp.mdga.notification.Notification;
import pp.mdga.notification.StartDialogNotification;
import pp.mdga.notification.*;
import java.util.ArrayList;
import java.util.Map;
import java.util.UUID;
/**
* The ClientGameLogic class is the main class for the client side of the game.
* It is responsible for handling the game logic on the client side.
*/
public class ClientGameLogic implements ServerInterpreter {
static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName());
@@ -26,8 +21,6 @@ public class ClientGameLogic implements ServerInterpreter {
private ClientState state;
private final ArrayList<Notification> notifications = new ArrayList<>();
private boolean isHost;
private int ownPlayerID;
private String ownPlayerName;
private final DialogsState dialogsState = new DialogsState(null, this);
private final GameState gameState = new GameState(null, this);
@@ -35,11 +28,6 @@ public class ClientGameLogic implements ServerInterpreter {
private final InterruptState interruptState = new InterruptState(null, this);
private final SettingsState settingsState = new SettingsState(null, this);
/**
* Creates a new ClientGameLogic
*
* @param clientSender the client sender
*/
public ClientGameLogic(ClientSender clientSender) {
this.game = new Game();
this.clientSender = clientSender;
@@ -47,26 +35,15 @@ public ClientGameLogic(ClientSender clientSender) {
state = dialogsState;
}
/**
* This method is used to send a message to the server
*
* @param msg the message to be sent
*/
public void send(ClientMessage msg) {
public void send(ClientMessage msg){
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
clientSender.send(msg);
}
/**
* This method is used to get a piece by its id
*
* @param pieceId the UUID of the piece
* @return the piece
*/
private Piece getPiece(UUID pieceId) {
for (var player : this.game.getPlayers().values()) {
for (Piece piece : player.getPieces()) {
if (piece.getUuid().equals(pieceId)) {
private Piece getPiece(UUID pieceId){
for(Map.Entry<Color, PlayerData> entry : game.getBoard().getPlayerData().entrySet()){
for(Piece piece : entry.getValue().getPieces()){
if(piece.getUuid().equals(pieceId)){
return piece;
}
}
@@ -74,610 +51,289 @@ private Piece getPiece(UUID pieceId) {
return null;
}
/**
* This method returns the clientSender
*
* @return the clientSender
*/
public ClientSender getClientSender() {
public ClientSender getClientSender(){
return clientSender;
}
/**
* This method is used to get the ownPlayerId
*
* @return the ownPlayerId
*/
public int getOwnPlayerId() {
return ownPlayerID;
}
/**
* This method is used to get the ownPlayerName
*
* @return the ownPlayerName
*/
public String getOwnPlayerName() {
return ownPlayerName;
}
/**
* This method is used to set the ownPlayerName
*
* @param ownPlayerName the ownPlayerName to be set
*/
public void setOwnPlayerName(String ownPlayerName) {
this.ownPlayerName = ownPlayerName;
}
/**
* This method is used to set the ownPlayerId
*
* @param ownPlayerId the ownPlayerId to be set
*/
public void setOwnPlayerId(int ownPlayerId) {
this.ownPlayerID = ownPlayerId;
}
/**
* This method returns the game
*
* @return the game
*/
public Game getGame() {
public Game getGame(){
return game;
}
/**
* This method returns the current State
*
* @return the current State
*/
public ClientState getState() {
public ClientState getState(){
return state;
}
/**
* This method returns if the client is a host
*
* @return if the client is a host
*/
public boolean isHost() {
public boolean isHost(){
return isHost;
}
/**
* This method returns the steps you can calculate steps
*
* @return the calculated moves as int
*/
public int getCalculatedMoves() {
return 0;
public int getCalculatedMoves(){
return game.getDiceEyes() * game.getDiceModifier();
}
/**
* This method sets if the player is a host
*
* @param isHost the boolean value
*/
public void setHost(boolean isHost) {
public void setHost(boolean isHost){
this.isHost = isHost;
}
/**
* This method calls the method received of the state
*
* @param msg the ActivePlayer message received
*/
@Override
public void received(ActivePlayerMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the AnyPiece message received
*/
@Override
public void received(AnyPieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Briefing message received
*/
@Override
public void received(BriefingMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Ceremony message received
*/
@Override
public void received(CeremonyMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Dice message received
*/
@Override
public void received(DieMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the DiceAgain message received
*/
@Override
public void received(DiceAgainMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the DiceNow message received
*/
@Override
public void received(DiceNowMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the EndOfGame message received
*/
@Override
public void received(EndOfTurnMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the GameOver message received
*/
@Override
public void received(LobbyAcceptMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the LobbyDeny message received
*/
@Override
public void received(LobbyDenyMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the LobbyPlayerJoin message received
*/
@Override
public void received(LobbyPlayerJoinedMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the LobbyPlayerLeave message received
*/
@Override
public void received(LobbyPlayerLeaveMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the MoveMessage message received
*/
@Override
public void received(MoveMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the NoTurn message received
*/
@Override
public void received(NoTurnMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PauseGame message received
*/
@Override
public void received(PauseGameMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PlayCard message received
*/
@Override
public void received(PlayCardMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PossibleCard message received
*/
@Override
public void received(PossibleCardsMessage msg) {
public void received(PossibleCardMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PossiblePiece message received
*/
@Override
public void received(PossiblePieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the RankingResponse message received
*/
@Override
public void received(RankingResponseMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the RankingRollAgain message received
*/
@Override
public void received(RankingRollAgainMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the ReconnectBriefing message received
*/
@Override
public void received(ReconnectBriefingMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the ResumeGame message received
*/
@Override
public void received(ResumeGameMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the ServerStartGame message received
*/
@Override
public void received(ServerStartGameMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the SelectTSK message received.
*/
@Override
public void received(ShutdownMessage msg) {
addNotification(new InfoNotification(Resources.stringLookup("server.shutdown")));
addNotification(new StartDialogNotification());
setState(dialogsState);
public void received(ShutdownMessage msg) {state.received(msg);}
@Override
public void received(StartBriefingMessage msg) {
state.received(msg);
}
/**
* Handles a IncorrectRequest message received from the server.
*
* @param msg the IncorrectRequest message received.
*/
@Override
public void received(IncorrectRequestMessage msg) {
addNotification(new InfoNotification(Resources.stringLookup("incorrect.request." + msg.getId())));
public void received(PlayerDataMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the StartPiece message received
*/
@Override
public void received(StartPieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the UpdateReady message received
*/
@Override
public void received(UpdateReadyMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the UpdateTSK message received
*/
@Override
public void received(UpdateTSKMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the WaitPiece message received
*/
@Override
public void received(WaitPieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Spectator message received.
*/
@Override
public void received(SpectatorMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the SelectPiece message received.
*/
@Override
public void received(SelectPieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method selectPiece
*
* @param pieceId the pieceID
*/
public void selectPiece(UUID pieceId) {
public void selectPiece(UUID pieceId){
state.selectPiece(getPiece(pieceId));
}
/**
* This method call the method selectNExt of the state
*/
public void selectNext() {
public void selectNext(){
state.selectNext();
}
/**
* This method calls the method selectCard of the state
*
* @param card the BonusCard to selected
*/
public void selectCard(BonusCard card) {
public void selectCard(BonusCard card){
state.selectCard(card);
}
/**
* This method call the method selectTsk of the state
*
* @param color the Color to be selected
*/
public void selectTsk(Color color) {
public void selectTsk(Color color){
state.selectTSK(color);
}
/**
* The method calls the method deselectTsk of the state
*
* @param color the color to be deselcted
*/
public void deselectTSK(Color color) {
public void deselectTSK(Color color){
state.deselectTSK(color);
}
/**
* This method calls the selectDice method of the state
*/
public void selectDice() {
public void selectDice(){
state.selectDice();
}
/**
* This method calls the selectName method of the state
*
* @param name the name to be set
*/
public void selectName(String name) {
public void selectName(String name){
state.setName(name);
}
/**
* This method calls a method of the state base on the parameter value
*
* @param ready the value if this method should ready or unready
*/
public void selectReady(boolean ready) {
if (ready) {
public void selectReady(boolean ready){
if(ready){
state.selectReady();
} else {
state.selectUnready();
}
}
/**
* This method calls the selectHost method of the state
*
* @param name the name of the player hosting
*/
public void selectHost(String name) {
public void selectHost(String name){
state.selectHost(name);
}
/**
* This method calls the selectLeave method of the state
*/
public void selectLeave() {
public void selectLeave(){
state.selectLeave();
}
/**
* This method calls the selectJoin method of the state
*
* @param ip the ip to cennect to
*/
public void selectJoin(String ip) {
public void selectJoin(String ip){
state.selectJoin(ip);
}
/**
* This method calls the selectAnimationEnd method of the state
*/
public void selectAnimationEnd() {
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
/**
* This method calls the selectStart method of the state
*/
public void selectStart() {
public void selectStart(){
state.selectStart();
}
/**
* This method calls the selectResume method of the state
*/
public void selectResume() {
public void selectResume(){
state.selectResume();
}
/**
* This method is used to transition between states
*
* @param state the new state
*/
public void setState(ClientState state) {
public void setState(ClientState state){
this.state.exit();
state.enter();
this.state = state;
}
/**
* This method is used to enter the interrupt state and save the previous state
*/
public void enterInterrupt() {
public void enterInterrupt(){
interruptState.enter();
interruptState.setPreviousState(state);
this.state = interruptState;
}
/**
* This method is used to get the GameState
*
* @return the GameState
*/
public GameState getGameState() {
public GameState getGameState(){
return gameState;
}
/**
* This method is used to get the CeremonyState
*
* @return the CeremonyState
*/
public CeremonyState getCeremony() {
public CeremonyState getCeremony(){
return ceremonyState;
}
/**
* This method is used to get the InterruptState
*
* @return the InterruptState
*/
public InterruptState getInterrupt() {
public InterruptState getInterrupt(){
return interruptState;
}
/**
* This method is used to get the DialogsState
*
* @return the DialogsState
*/
public DialogsState getDialogs() {
public DialogsState getDialogs(){
return dialogsState;
}
/**
* This method is used to get the SettingsState
*
* @return the SettingsState
*/
public SettingsState getSettings() {
public SettingsState getSettings(){
return settingsState;
}
/**
* This method is used to get the next notification
*
* @return the next notification
*/
public Notification getNotification() {
if (!notifications.isEmpty()) {
public Notification getNotification(){
if(!notifications.isEmpty()){
return notifications.remove(0);
} else {
return null;
}
}
/**
* This method is used to add a notification
*
* @param notification the notification to be added
*/
public void addNotification(Notification notification) {
public void addNotification(Notification notification){
notifications.add(notification);
}

View File

@@ -37,155 +37,159 @@ public String toString(){
@Override
public void received(ActivePlayerMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(AnyPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(BriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(CeremonyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(DieMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(DiceAgainMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(DiceNowMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(EndOfTurnMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyAcceptMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyDenyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyPlayerJoinedMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyPlayerLeaveMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(MoveMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(NoTurnMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PauseGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PlayCardMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PossibleCardsMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
public void received(PossibleCardMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PossiblePieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(RankingResponseMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(RankingRollAgainMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ReconnectBriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ResumeGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ServerStartGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());}
public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);}
@Override
public void received(StartPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(UpdateReadyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(UpdateTSKMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(SpectatorMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(SelectPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(WaitPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(IncorrectRequestMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
public void received(StartBriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
public void received(PlayerDataMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
public void selectPiece(Piece piece) {
@@ -248,11 +252,6 @@ public void selectResume(){
LOGGER.log(Level.DEBUG, "Resume not allowed");
}
/**
* This method is used to create a CeremonyNotification
*
* @return the created CeremonyNotification
*/
protected CeremonyNotification createCeremonyNotification(){
CeremonyNotification notification = new CeremonyNotification();
for (var player : logic.getGame().getPlayers().entrySet()){

View File

@@ -1,9 +1,9 @@
package pp.mdga.client;
import pp.mdga.client.dialogstate.DialogStates;
import pp.mdga.client.dialogstate.LobbyState;
import pp.mdga.client.dialogstate.NetworkDialogState;
import pp.mdga.client.dialogstate.StartDialogState;
import pp.mdga.client.dialogState.DialogStates;
import pp.mdga.client.dialogState.LobbyState;
import pp.mdga.client.dialogState.NetworkDialogState;
import pp.mdga.client.dialogState.StartDialogState;
import pp.mdga.game.Color;
import pp.mdga.message.server.*;
@@ -11,41 +11,30 @@ public class DialogsState extends ClientState {
private DialogStates currentState;
private int ownPlayerID;
private String ownPlayerName;
private final LobbyState lobbyState = new LobbyState(this, logic);
private final NetworkDialogState networkDialogState = new NetworkDialogState(this, logic);
private final StartDialogState startDialogState = new StartDialogState(this, logic);
/**
* Creates a new DialogsState
*
* @param parent the parent state
* @param logic the game logic
*/
public DialogsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
/**
* exits this state
*/
@Override
public void exit(){
currentState.exit();
}
/**
* Enters the new state machine
*/
@Override
public void enter(){
setState(startDialogState);
ownPlayerID = 0;
ownPlayerName = null;
}
/**
* This method is used to set a new SubState
*
* @param newState the state to be set
*/
public void setState(DialogStates newState){
if(currentState != null){
currentState.exit();
@@ -54,188 +43,114 @@ public void setState(DialogStates newState){
currentState = newState;
}
/**
* This method is used to get the lobbyState
*
* @return the lobbyState
*/
public int getOwnPlayerId() {
return ownPlayerID;
}
public String getOwnPlayerName() {
return ownPlayerName;
}
public void setOwnPlayerName(String ownPlayerName) {
this.ownPlayerName = ownPlayerName;
}
public void setOwnPlayerId(int ownPlayerId) {
this.ownPlayerID = ownPlayerId;
}
public LobbyState getLobby() {
return lobbyState;
}
/**
* This method is used to get the networkDialogState
*
* @return the networkDialogState
*/
public NetworkDialogState getNetworkDialog() {
return networkDialogState;
}
/**
* This method is used to get the startDialogState
*
* @return the startDialogState
*/
public StartDialogState getStartDialog() {
return startDialogState;
}
/**
* This method is used to call the selectLeave method of the current state
*/
@Override
public void selectLeave(){
currentState.selectLeave();
}
/**
* This method is used to call the selectName method of the current state
*
* @param name the name to be set
*/
@Override
public void setName(String name){
currentState.setName(name);
}
/**
* This method is used to call the selectTSK method of the current state
*
* @param color the color to be set
*/
@Override
public void selectTSK(Color color){
currentState.selectTSK(color);
}
/**
* This method is used to call the deselectTSK method of the current state
*
* @param color the color to be deselected
*/
@Override
public void deselectTSK(Color color){
currentState.deselectTSK(color);
}
/**
* This method is used to call the selectReady method of the current state
*/
@Override
public void selectReady(){
currentState.selectReady();
}
/**
* This method is used to call the selectUnready method of the current state
*/
@Override
public void selectUnready(){
currentState.selectUnready();
}
/**
* This method is used to call the selectStart method of the current state
*/
@Override
public void selectStart(){
currentState.selectStart();
}
/**
* This method is used to call the selectJoin method of the current state
*
* @param string the string to be set
*/
@Override
public void selectJoin(String string){
currentState.selectJoin(string);
}
/**
* This method is used to call the selectHost method of the current state
*
* @param name the name to be set
*/
@Override
public void selectHost(String name){
currentState.selectHost(name);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyPlayerJoin message received
*/
@Override
public void received(LobbyPlayerJoinedMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyPlayerLeave message received
*/
@Override
public void received(LobbyPlayerLeaveMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the UpdateTSKMessage message received
*/
@Override
public void received(UpdateTSKMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the UpdateReady message received
*/
@Override
public void received(UpdateReadyMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the ServerStartGame message received
*/
@Override
public void received(ServerStartGameMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyAccept message received
*/
@Override
public void received(LobbyAcceptMessage msg){
public void received(PlayerDataMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyDeny message received
*/
@Override
public void received(LobbyDenyMessage msg){
public void received(StartBriefingMessage msg){
currentState.received(msg);
}
/**
* This method is used to get the current state
*/
public DialogStates getState() {
return currentState;
}

View File

@@ -1,12 +1,10 @@
package pp.mdga.client;
import pp.mdga.client.gamestate.*;
import pp.mdga.client.gameState.*;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.message.client.LeaveGameMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.InterruptNotification;
import pp.mdga.notification.StartDialogNotification;
public class GameState extends ClientState {
@@ -60,271 +58,132 @@ public void setState(GameStates newState){
state = newState;
}
/**
* This method is used to call the selectAnimationEnd method of the current state
*/
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
/**
* This method is used to call the selectDice method of the current state
*/
@Override
public void selectDice(){
state.selectDice();
}
/**
* This method is used to call the selectPiece method of the current state
*
* @param piece the piece to be selected
*/
@Override
public void selectPiece(Piece piece){
state.selectPiece(piece);
}
/**
* This method is used to call the selectCard method of the current state
*
* @param card the card to be selected
*/
@Override
public void selectCard(BonusCard card){
state.selectCard(card);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(PauseGameMessage msg){
logic.enterInterrupt();
logic.addNotification(new InterruptNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor()));
}
@Override
public void selectLeave(){
logic.send(new LeaveGameMessage());
logic.addNotification(new StartDialogNotification());
logic.setState(logic.getDialogs());
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(DieMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(RankingRollAgainMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(RankingResponseMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(SelectPieceMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(WaitPieceMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(StartPieceMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(NoTurnMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(MoveMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(CeremonyMessage msg){
logic.addNotification(createCeremonyNotification());
logic.setState(logic.getCeremony());
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(EndOfTurnMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(SpectatorMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(DiceAgainMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(PossibleCardsMessage msg){
public void received(PossibleCardMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(PlayCardMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(DiceNowMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(ActivePlayerMessage msg){
state.received(msg);
}
/**
* This method returns the current state
*
* @return the current state
*/
public GameStates getState(){
return state;
}
/**
* This method returns the AnimationState
*
* @return the AnimationState
*/
public AnimationState getAnimation() {
return animationState;
}
/**
* This method returns the DetermineStartPlayerState
*
* @return the DetermineStartPlayerState
*/
public DetermineStartPlayerState getDetermineStartPlayer() {
return determineStartPlayerState;
}
/**
* This method returns the SpectatorState
*
* @return the SpectatorState
*/
public SpectatorState getSpectator() {
return spectatorState;
}
/**
* This method returns the TurnState
*
* @return the TurnState
*/
public TurnState getTurn() {
return turnState;
}
/**
* This method returns the WaitingState
*
* @return the WaitingState
*/
public WaitingState getWaiting() {
return waitingState;
}

View File

@@ -1,9 +1,9 @@
package pp.mdga.client;
import pp.mdga.client.settingsstate.AudioSettingsState;
import pp.mdga.client.settingsstate.MainSettingsState;
import pp.mdga.client.settingsstate.SettingStates;
import pp.mdga.client.settingsstate.VideoSettingsState;
import pp.mdga.client.settingsState.AudioSettingsState;
import pp.mdga.client.settingsState.MainSettingsState;
import pp.mdga.client.settingsState.SettingStates;
import pp.mdga.client.settingsState.VideoSettingsState;
public class SettingsState extends ClientState {
@@ -49,23 +49,14 @@ public SettingStates getState(){
return currentState;
}
/**
* Returns the main settings state
*/
public MainSettingsState getMainSettingsState(){
return mainSettingsState;
}
/**
* Returns the audio settings state
*/
public AudioSettingsState getAudioSettingsState(){
return audioSettingsState;
}
/**
* Returns the video settings state
*/
public VideoSettingsState getVideoSettingsState(){
return videoSettingsState;
}

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonystate;
package pp.mdga.client.ceremonyState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonystate;
package pp.mdga.client.ceremonyState;
import pp.mdga.client.CeremonyState;
import pp.mdga.client.ClientGameLogic;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonystate;
package pp.mdga.client.ceremonyState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogstate;
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogstate;
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
@@ -6,14 +6,18 @@
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import pp.mdga.game.Player;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.*;
import pp.mdga.message.server.*;
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
import pp.mdga.message.server.PlayerDataMessage;
import pp.mdga.message.server.ServerStartGameMessage;
import pp.mdga.message.server.StartBriefingMessage;
import pp.mdga.message.server.UpdateReadyMessage;
import pp.mdga.message.server.UpdateTSKMessage;
import pp.mdga.notification.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
public class LobbyState extends DialogStates {
@@ -26,7 +30,7 @@ public LobbyState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.send(new JoinedLobbyMessage(logic.getOwnPlayerName()));
logic.send(new JoinedLobbyMessage(parent.getOwnPlayerName()));
}
@Override
@@ -56,58 +60,61 @@ public void selectReady() {
}
@Override
public void selectUnready() {
public void selectUnready(){
logic.send(new LobbyNotReadyMessage());
}
@Override
public void selectStart() {
if (logic.isHost() && logic.getGame().areAllReady()) {
logic.send(new StartGameMessage());
public void selectStart(){
if(logic.isHost() && logic.getGame().allReady()){
logic.send(new StartGameMessage(false));
} else if(logic.isHost() && !logic.getGame().allReady()) {
logic.send(new StartGameMessage(true));
} else {
logic.send(new StartGameMessage());
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
}
}
@Override
public void received(ServerStartGameMessage msg) {
for (Player player: msg.getPlayers()) {
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
if (entry.getValue().getColor() == player.getColor()) {
this.logic.getGame().getPlayers().put(entry.getKey(), player);
}
}
}
public void received(StartBriefingMessage msg){
logic.getGame().setBoard(msg.getBoard());
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
for (var player : logic.getGame().getPlayers().values()) {
List<UUID> pieces = new ArrayList<>();
for (Piece piece : player.getPieces()) {
pieces.add(piece.getUuid());
}
public void received(PlayerDataMessage msg){
logic.getGame().getBoard().addPlayerData(msg.getColor(), msg.getPlayerData());
}
@Override
public void received(ServerStartGameMessage msg){
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(parent.getOwnPlayerId()).getColor()));
for (Map.Entry<Color, PlayerData> entry : logic.getGame().getBoard().getPlayerData().entrySet()) {
List<UUID> pieceList = new ArrayList<>();
for(Piece piece : entry.getValue().getPieces()){
System.out.println(piece.getUuid());
pieceList.add(piece.getUuid());
}
logic.addNotification(new PlayerInGameNotification(player.getColor(), pieces, player.getName()));
logic.addNotification(new PlayerInGameNotification(entry.getKey(), pieceList , logic.getGame().getPlayerByColor(entry.getKey()).getName()));
}
logic.setState(logic.getGameState());
}
@Override
public void received(LobbyPlayerJoinedMessage msg) {
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
logic.setOwnPlayerId(msg.getId());
public void received(LobbyPlayerJoinedMessage msg){
if(msg.getPlayer().getName().equals(parent.getOwnPlayerName())){
parent.setOwnPlayerId(msg.getId());
}
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
if (msg.isHost() && msg.getId() == parent.getOwnPlayerId()){
logic.setHost(true);
}
logic.addNotification(new TskSelectNotification(msg.getPlayer().getColor(), msg.getPlayer().getName(), msg.getPlayer().getName().equals(logic.getOwnPlayerName())));
logic.addNotification(new TskSelectNotification(msg.getPlayer().getColor(), msg.getPlayer().getName(), msg.getPlayer().getName().equals(parent.getOwnPlayerName())));
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
}
@Override
public void received(UpdateTSKMessage msg) {
if (msg.isTaken()) {
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId() == msg.getId()));
public void received(UpdateTSKMessage msg){
if(msg.isTaken()) {
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), parent.getOwnPlayerId()== msg.getId()));
} else {
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
}
@@ -116,13 +123,13 @@ public void received(UpdateTSKMessage msg) {
}
@Override
public void received(LobbyPlayerLeaveMessage msg) {
public void received(LobbyPlayerLeaveMessage msg){
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
logic.getGame().getPlayers().remove(msg.getId());
}
@Override
public void received(UpdateReadyMessage msg) {
public void received(UpdateReadyMessage msg){
//TODO server sendet kein update on UNready
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());

View File

@@ -0,0 +1,34 @@
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.DialogsState;
import pp.mdga.notification.LobbyDialogNotification;
public class NetworkDialogState extends DialogStates {
private final DialogsState parent;
public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}
public void selectJoin(String IP) {
parent.setState(parent.getLobby());
logic.addNotification(new LobbyDialogNotification());
}
}

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogstate;
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
@@ -8,44 +8,41 @@ public class StartDialogState extends DialogStates {
private final DialogsState parent;
/**
* Constructor for the StartDialogState
* @param parent the parent state
* @param logic the logic
*/
public StartDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
/**
* Enter the state
*/
@Override
public void enter() {
}
/**
* Exit the state
*/
@Override
public void exit() {
}
@Override
public void selectJoin(String name) {
parent.setOwnPlayerName(name);
parent.setState(parent.getNetworkDialog());
logic.setHost(false);
}
@Override
public void selectHost(String name) {
parent.setOwnPlayerName(name);
parent.setState(parent.getLobby());
logic.setHost(true);
}
/**
* Set the name
*
* @param name the name
*/
@Override
public void setName(String name) {
logic.setOwnPlayerName(name);
parent.setState(parent.getNetworkDialog());
parent.setOwnPlayerName(name);
}
/**
* Select the leave option
*/
@Override
public void selectLeave() {
parent.exit();

View File

@@ -1,72 +0,0 @@
package pp.mdga.client.dialogstate;
import pp.mdga.Resources;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.DialogsState;
import pp.mdga.message.server.LobbyAcceptMessage;
import pp.mdga.message.server.LobbyDenyMessage;
import pp.mdga.notification.InfoNotification;
import pp.mdga.notification.LobbyDialogNotification;
public class NetworkDialogState extends DialogStates {
private final DialogsState parent;
/**
* Constructor for the NetworkDialogState
* @param parent the parent state
* @param logic the logic
*/
public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
/**
* Enter the state
*/
@Override
public void enter() {
LOGGER.log(System.Logger.Level.INFO, "Entered {0}", this);
}
/**
* Exit the state
*/
@Override
public void exit() {
}
/**
* Select the leave option
*/
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}
/**
* This method is called when the server accepts the client into the lobby
*
* @param msg the LobbyAcceptMessage
*/
@Override
public void received(LobbyAcceptMessage msg) {
logic.getGame().setHost(msg.getHost());
logic.setHost(logic.getGame().isHost());
parent.setState(parent.getLobby());
logic.addNotification(new LobbyDialogNotification());
}
/**
* This method is called when the server denies the client into the lobby
*
* @param msg the LobbyDenyMessage
*/
@Override
public void received(LobbyDenyMessage msg) {
logic.addNotification(new InfoNotification(Resources.stringLookup("lobby.deny.join")));
parent.setState(parent.getStartDialog());
}
}

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.gamestate;
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,14 +1,11 @@
package pp.mdga.client.gamestate;
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.ActivePlayerMessage;
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage;
@@ -20,33 +17,12 @@ public class DetermineStartPlayerState extends GameStates {
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
private final Intro intro = new Intro(this, logic);
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (GameState) parent;
}
public RollRankingDiceState getRollRankingDice() {
return rollRankingDiceState;
}
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
public DetermineStartPlayerStates getState(){
return state;
}
public Intro getIntro(){
return intro;
}
public GameState getParent() {
return parent;
}
@Override
public void enter() {
this.setState(this.rollRankingDiceState);
@@ -70,11 +46,6 @@ public void selectDice() {
state.selectDice();
}
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
@Override
public void received(DieMessage msg){
state.received(msg);
@@ -90,8 +61,19 @@ public void received(RankingResponseMessage msg){
state.received(msg);
}
@Override
public void received(ActivePlayerMessage msg){
state.received(msg);
public RollRankingDiceState getRollRankingDice() {
return rollRankingDiceState;
}
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
public DetermineStartPlayerStates getState(){
return state;
}
public GameState getParent() {
return parent;
}
}

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.gamestate;
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
@@ -12,45 +12,40 @@
import pp.mdga.notification.SwapPieceNotification;
import pp.mdga.notification.ThrowPieceNotification;
import java.util.UUID;
public abstract class GameStates extends ClientState {
public GameStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
protected void handlePowerCard(PlayCardMessage msg) {
if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
protected void handlePowerCard(PlayCardMessage msg){
if (msg.getCard().equals(BonusCard.TURBO)){
logic.getGame().setDiceModifier(msg.getDiceModifier());
} else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) {
handleShield(msg.getPieces().get(0).getUuid());
} else if (msg.getCard().equals(BonusCard.SHIELD)){
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
} else {
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
}
} else {
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
}
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard());
logic.getGame().getDiscardPile().add(msg.getCard());
}
protected void throwPiece(Piece piece) {
protected void throwPiece(Piece piece){
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
logic.getGame().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
piece.setState(PieceState.WAITING);
}
private void handleShield(UUID uuid) {
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(uuid)) % 10 != 0) {
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(uuid));
} else {
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(uuid));
}
}
}

View File

@@ -1,14 +1,11 @@
package pp.mdga.client.gamestate;
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.HomeMoveNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayCardNotification;
import pp.mdga.notification.*;
public class SpectatorState extends GameStates {
@@ -30,15 +27,15 @@ public void exit() {
}
@Override
public void received(CeremonyMessage msg) {
public void received(CeremonyMessage msg){
logic.setState(logic.getCeremony());
}
@Override
public void received(DieMessage msg) {
//logic.getGame().setDiceEyes(msg.getDiceEye());
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if (msg.getDiceEye() == 6) {
if(msg.getDiceEye() == 6){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6();
}
@@ -46,8 +43,8 @@ public void received(DieMessage msg) {
}
@Override
public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
public void received(PlayCardMessage msg){
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -55,26 +52,26 @@ public void received(PlayCardMessage msg) {
}
@Override
public void received(ActivePlayerMessage msg) {
public void received(ActivePlayerMessage msg){
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation());
}
@Override
public void received(MoveMessage msg) {
public void received(MoveMessage msg){
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()) {
if (msg.isHomeMove()){
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
} else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().increasePiecesThrown();
}
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else {

View File

@@ -1,14 +1,14 @@
package pp.mdga.client.gamestate;
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gamestate.turnstate.MovePieceState;
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gamestate.turnstate.RollDiceState;
import pp.mdga.client.gamestate.turnstate.TurnStates;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gameState.turnState.MovePieceState;
import pp.mdga.client.gameState.turnState.PlayPowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.client.gameState.turnState.RollDiceState;
import pp.mdga.client.gameState.turnState.TurnStates;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;
@@ -108,7 +108,7 @@ public void received(DiceAgainMessage msg){
}
@Override
public void received(PossibleCardsMessage msg){
public void received(PossibleCardMessage msg){
state.received(msg);
}

View File

@@ -1,10 +1,9 @@
package pp.mdga.client.gamestate;
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.game.Piece;
import pp.mdga.game.PieceState;
import pp.mdga.game.*;
import pp.mdga.message.server.*;
import pp.mdga.notification.*;
@@ -28,21 +27,21 @@ public void exit() {
}
@Override
public void received(CeremonyMessage msg) {
public void received(CeremonyMessage msg){
logic.setState(logic.getCeremony());
}
@Override
public void received(DiceNowMessage msg) {
public void received(DiceNowMessage msg){
logic.addNotification(new DiceNowNotification());
parent.setState(parent.getTurn());
}
@Override
public void received(DieMessage msg) {
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
if (msg.getDiceEye() == 6) {
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6();
}
@@ -50,8 +49,8 @@ public void received(DieMessage msg) {
}
@Override
public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
public void received(PlayCardMessage msg){
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -59,21 +58,21 @@ public void received(PlayCardMessage msg) {
}
@Override
public void received(ActivePlayerMessage msg) {
public void received(ActivePlayerMessage msg){
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation());
}
@Override
public void received(MoveMessage msg) {
public void received(MoveMessage msg){
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()) {
if (msg.isHomeMove()){
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
for(int i = msg.getTargetIndex() + 1; i < 4; i++){
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
pieceToMove.setState(PieceState.HOME);
break;
}
@@ -85,7 +84,7 @@ public void received(MoveMessage msg) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().increasePiecesThrown();
}
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.determinestartplayerstate;
package pp.mdga.client.gameState.determineStartPlayerState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.GameStates;
import pp.mdga.client.gameState.GameStates;
public abstract class DetermineStartPlayerStates extends GameStates {
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.determinestartplayerstate;
package pp.mdga.client.gameState.determineStartPlayerState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.client.gameState.DetermineStartPlayerState;
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage;
import pp.mdga.notification.DiceNowNotification;
@@ -28,12 +28,13 @@ public void exit() {
@Override
public void selectDice(){
System.out.println("selectDice");
logic.send(new RequestDieMessage());
}
@Override
public void received(DieMessage msg){
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getDialogs().getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
parent.setState(parent.getWaitRanking());
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
}
}

View File

@@ -0,0 +1,40 @@
package pp.mdga.client.gameState.determineStartPlayerState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.DetermineStartPlayerState;
import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage;
import pp.mdga.notification.ActivePlayerNotification;
public class WaitRankingState extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent;
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(RankingRollAgainMessage msg){
parent.setState(parent.getRollRankingDice());
}
@Override
public void received(RankingResponseMessage msg){
logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
parent.getParent().setState(parent.getParent().getWaiting());
}
}

View File

@@ -1,9 +1,9 @@
package pp.mdga.client.gamestate.turnstate;
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gameState.turnState.choosePieceState.*;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate;
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.*;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate;
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.PlayCardNotification;
@@ -20,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
handlePowerCard(playCardMessage);
}

View File

@@ -1,17 +1,17 @@
package pp.mdga.client.gamestate.turnstate;
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gamestate.turnstate.powercardstate.ChoosePowerCardState;
import pp.mdga.client.gamestate.turnstate.powercardstate.PowerCardStates;
import pp.mdga.client.gamestate.turnstate.powercardstate.ShieldState;
import pp.mdga.client.gamestate.turnstate.powercardstate.SwapState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState;
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates;
import pp.mdga.client.gameState.turnState.powerCardState.ShieldState;
import pp.mdga.client.gameState.turnState.powerCardState.SwapState;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.message.server.PossibleCardsMessage;
import pp.mdga.message.server.PossibleCardMessage;
import pp.mdga.message.server.PossiblePieceMessage;
public class PowerCardState extends TurnStates {
@@ -48,7 +48,7 @@ public void setState(PowerCardStates state) {
}
@Override
public void received(PossibleCardsMessage msg){
public void received(PossibleCardMessage msg){
state.received(msg);
}

View File

@@ -1,13 +1,10 @@
package pp.mdga.client.gamestate.turnstate;
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.NoTurnMessage;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.RollDiceNotification;
public class RollDiceState extends TurnStates {
@@ -20,7 +17,7 @@ public RollDiceState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.addNotification(new DiceNowNotification());
}
@Override
@@ -32,11 +29,6 @@ public TurnState getParent() {
return parent;
}
@Override
public void selectDice(){
logic.send(new RequestDieMessage());
}
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
parent.setState(parent.getChoosePiece());

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate;
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.GameStates;
import pp.mdga.client.gameState.GameStates;
public abstract class TurnStates extends GameStates {
public TurnStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.TurnStates;
import pp.mdga.client.gameState.turnState.TurnStates;
public abstract class ChoosePieceStates extends TurnStates {
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,11 +1,12 @@
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;
import pp.mdga.message.server.StartPieceMessage;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.WaitMoveNotification;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
@@ -31,26 +31,24 @@ public void exit() {
}
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
public void setPossiblePieces(ArrayList<Piece> possiblePieces){
this.possiblePieces = possiblePieces;
}
@Override
public void selectPiece(Piece piece) {
ArrayList<Piece> pieces = new ArrayList<>();
public void selectPiece(Piece piece){
if(possiblePieces.contains(piece)){
pieces.add(piece);
logic.send(new SelectedPiecesMessage(pieces));
logic.send(new SelectedPiecesMessage(piece.getUuid()));
}
}
@Override
public void received(MoveMessage msg) {
public void received(MoveMessage msg){
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()) {
if(msg.isHomeMove()){
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
} else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());

View File

@@ -1,14 +1,12 @@
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
public class StartPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
@@ -32,10 +30,8 @@ public void exit() {
@Override
public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){
pieces.add(piece);
logic.send(new SelectedPiecesMessage(pieces));
logic.send(new SelectedPiecesMessage(piece.getUuid()));
}
}

View File

@@ -1,16 +1,13 @@
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.game.PieceState;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
import java.util.List;
public class WaitingPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
@@ -32,10 +29,8 @@ public void exit() {
@Override
public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){
pieces.add(piece);
logic.send(new SelectedPiecesMessage(pieces));
logic.send(new SelectedPiecesMessage(piece.getUuid()));
}
}

View File

@@ -1,15 +1,14 @@
package pp.mdga.client.gamestate.turnstate.powercardstate;
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.game.BonusCard;
import pp.mdga.game.card.*;
import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.SelectCardMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.message.server.PossibleCardsMessage;
import pp.mdga.message.server.PossibleCardMessage;
import pp.mdga.message.server.PossiblePieceMessage;
import pp.mdga.notification.SelectableCardsNotification;
@@ -22,7 +21,7 @@
public class ChoosePowerCardState extends PowerCardStates {
private final PowerCardState parent;
private ArrayList<PowerCard> possibleCards = new ArrayList<>();
private ArrayList<BonusCard> possibleCards;
/**
* Constructor
@@ -39,6 +38,8 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
*/
@Override
public void enter() {
possibleCards = new ArrayList<>();
//TODO: logic.send(new RequestPossibleCardsMessage());
}
/**
@@ -46,7 +47,7 @@ public void enter() {
*/
@Override
public void exit() {
possibleCards = new ArrayList<>();
possibleCards = null;
}
/**
@@ -54,15 +55,9 @@ public void exit() {
* @param msg possible cards message
*/
@Override
public void received(PossibleCardsMessage msg){
possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards();
ArrayList<BonusCard> possibleBonusCards = new ArrayList<>();
for (PowerCard card : possibleCards) {
if (!possibleBonusCards.contains(card.getCard())) {
possibleBonusCards.add(card.getCard());
}
}
logic.addNotification(new SelectableCardsNotification(possibleBonusCards));
public void received(PossibleCardMessage msg){
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
logic.addNotification(new SelectableCardsNotification(possibleCards));
}
/**
@@ -72,7 +67,7 @@ public void received(PossibleCardsMessage msg){
@Override
public void selectCard(BonusCard card){
if(card != null){
logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card)));
logic.send(new SelectCardMessage(card));
} else {
logic.send(new NoPowerCardMessage());
}
@@ -84,9 +79,10 @@ public void selectCard(BonusCard card){
*/
@Override
public void received(PlayCardMessage msg){
if(msg.getCard().getCard().equals(BonusCard.TURBO)){
parent.getParent().getPlayPowerCard().setPlayCard(msg);
parent.getParent().setState(parent.getParent().getPlayPowerCard());
if(msg.getCard().equals(BonusCard.TURBO)){
logic.getGame().setDiceModifier(msg.getDiceModifier());
} else {
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
}
}

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate.powercardstate;
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.TurnStates;
import pp.mdga.client.gameState.turnState.TurnStates;
public abstract class PowerCardStates extends TurnStates {
public PowerCardStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate.powercardstate;
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gamestate.turnstate.powercardstate;
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage;

View File

@@ -1,85 +0,0 @@
package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.game.Player;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DrawCardNotification;
import pp.mdga.notification.MovePieceNotification;
import java.util.Map;
public class Intro extends DetermineStartPlayerStates{
private final DetermineStartPlayerState parent;
private int animationCounter = 0;
/**
* Constructor for Intro
*
* @param parent the parent state
* @param logic the client game logic
*/
public Intro(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
/**
* This method is used to get the parent state;
*
* @return the parent state
*/
public DetermineStartPlayerState getParent(){
return parent;
}
/**
* This method is used to enter this state and play all necessary intro animations.
*/
@Override
public void enter() {
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
//logic.addNotification(new WaitMoveNotification(entry.getValue().getPieces()[0].getUuid()));
logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
animationCounter++;
if(entry.getKey() == logic.getOwnPlayerId()){
logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0).getCard()));
} else {
logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), entry.getValue().getHandCards().get(0).getCard()));
}
}
}
/**
* This method i s used to exit this state.
*/
@Override
public void exit() {
animationCounter = 0;
}
/**
* This method is used when the view has completed the animation.
*/
@Override
public void selectAnimationEnd(){
animationCounter--;
if(animationCounter != 0){
return;
}
logic.send(new AnimationEndMessage());
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
parent.getParent().setState(parent.getParent().getTurn());
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
} else {
parent.getParent().setState(parent.getParent().getWaiting());
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
}
}
}

View File

@@ -1,58 +0,0 @@
package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.ActivePlayerNotification;
public class WaitRankingState extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent;
private boolean canChange = false;
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
private void changeToIntro(){
if(!canChange){
canChange = true;
return;
}
parent.setState(parent.getIntro());
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(DiceNowMessage msg){
parent.setState(parent.getRollRankingDice());
}
@Override
public void received(RankingResponseMessage msg){
}
@Override
public void selectAnimationEnd(){
changeToIntro();
logic.send(new AnimationEndMessage());
}
@Override
public void received(ActivePlayerMessage msg){
logic.getGame().setActiveColor(msg.getColor());
changeToIntro();
}
}

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsstate;
package pp.mdga.client.settingsState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsstate;
package pp.mdga.client.settingsState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsstate;
package pp.mdga.client.settingsState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsstate;
package pp.mdga.client.settingsState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -2,88 +2,56 @@
import com.jme3.network.serializing.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* This class will be used to hold all Board relevant data.
*/
@Serializable
public class Board {
/**
* The size of the board.
*/
public static final int BOARD_SIZE = 40;
/**
* Create Board attributes.
*/
private Map<Color, PlayerData> playerData = new HashMap<>();
private final Node[] infield;
/**
* This constructor is used to create a new board
*/
public Board() {
infield = new Node[BOARD_SIZE];
initializeBoard();
}
/**
* Initializes the board by setting up the nodes.
* Start nodes, bonus nodes, and regular nodes are created based on their positions.
*/
private void initializeBoard() {
for (int i = 0; i < BOARD_SIZE; i++) {
if (isStartNode(i)) {
infield[i] = createStartNode(i);
} else if (isBonusNode(i)) {
infield = new Node[40];
for (int i = 0; i < 40; i++) {
if (i % 10 == 0) {
infield[i] = new StartNode(
i == 0 ? Color.AIRFORCE :
i == 10 ? Color.CYBER :
i == 20 ? Color.NAVY :
Color.ARMY
);
} else if (i == 4 || i == 14 || i == 24 || i == 34) {
infield[i] = new BonusNode();
} else {
infield[i] = new Node(null);
infield[i] = new Node();
}
}
}
/**
* Checks if the given index is a start node.
* This method will be used to add the given color and playerData parameters to the playerData attribute of
* Board class.
*
* @param i the index to check
* @return true if the index is a start node, false otherwise
* @param color as the color of the player as a Color enumeration.
* @param playerData as the playerData of the player as a PlayerData object.
*/
private boolean isStartNode(int i) {
return i % 10 == 0;
public void addPlayerData(Color color, PlayerData playerData) {
this.playerData.put(color, playerData);
}
/**
* Checks if the given index is a bonus node.
* This method returns the playerData
*
* @param i the index to check
* @return true if the index is a bonus node, false otherwise
* @return the playerData
*/
private boolean isBonusNode(int i) {
return i % 10 == 4;
}
/**
* Creates a start node with the appropriate color based on the index.
*
* @param i the index of the start node
* @return a new StartNode with the corresponding color
*/
private StartNode createStartNode(int i) {
return new StartNode(Color.getColor(i));
}
/**
* This method returns the index of a specific piece on the board
*
* @param piece the piece to be searched for
* @return the index of the piece
*/
public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) {
if (infield[i].getOccupant() == piece) {
return i;
}
}
return -1;
public Map<Color, PlayerData> getPlayerData() {
return playerData;
}
/**
@@ -105,8 +73,18 @@ public void setPieceOnBoard(int index, Piece piece) {
infield[index].setOccupant(piece);
}
@Override
public String toString() {
return "Default Board";
/**
* This method returns the index of a specific piece on the board
*
* @param piece the piece to be searched for
* @return the index of the piece
*/
public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) {
if (infield[i].getOccupant() == piece) {
return i;
}
}
return -1;
}
}

Some files were not shown because too many files have changed in this diff Show More