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
208 changed files with 7228 additions and 13367 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,3 @@
.run/
.gradle .gradle
build/ build/
#!gradle/wrapper/gradle-wrapper.jar #!gradle/wrapper/gradle-wrapper.jar

View File

@@ -16,4 +16,4 @@
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
</method> </method>
</configuration> </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, tank,
world(1.2f), world(1.2f),
shieldRing("Models/shieldRing/shieldRing.j3o", null), shieldRing("Models/shieldRing/shieldRing.j3o", null),
treeSmall(1.2f), treeSmall,
treeBig(1.2f), treeBig,
turboCard, turboCard,
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.png"), turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.j3o"),
swapCard, swapCard,
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"), swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.j3o"),
shieldCard, shieldCard,
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"), shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.j3o"),
dice, dice
missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
; ;
private final String modelPath; private final String modelPath;

View File

@@ -27,7 +27,6 @@
import pp.mdga.notification.SelectableCardsNotification; import pp.mdga.notification.SelectableCardsNotification;
import java.util.List; import java.util.List;
import java.util.UUID;
public class InputSynchronizer { public class InputSynchronizer {
@@ -40,11 +39,6 @@ public class InputSynchronizer {
private CardControl hoverCard; private CardControl hoverCard;
private PieceControl hoverPiece; private PieceControl hoverPiece;
private boolean clickAllowed = true;
private boolean isRotateLeft = false;
private boolean isRotateRight = false;
/** /**
* Constructor initializes the InputSynchronizer with the application context. * Constructor initializes the InputSynchronizer with the application context.
* Sets up input mappings and listeners for user interactions. * Sets up input mappings and listeners for user interactions.
@@ -60,18 +54,6 @@ public class InputSynchronizer {
setupInput(); 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. * 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("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN)); 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("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right 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("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J)); inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); 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"); 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. * 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; rightMousePressed = isPressed;
} }
if(name.equals("Click") && isPressed) { if(name.equals("Click") && isPressed) {
if(!clickAllowed) {
return;
}
if (app.getView() instanceof GameView gameView) { if (app.getView() instanceof GameView gameView) {
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class); DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class); CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
@@ -143,40 +121,13 @@ else if(boardSelect != null) {
} }
if (name.equals("Left")) { if(name.equals("Test") &&isPressed){
isRotateLeft = !isRotateLeft;
}
if (name.equals("Right")) {
isRotateRight = !isRotateRight;
}
if(name.equals("Test2") &&isPressed){
if(app.getView() instanceof GameView gameView){ 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.AIRFORCE, 1);
// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2); // gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3); // gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4); // gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
// gameView.getGuiHandler().showDice(); 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);
} }
} }
} }
@@ -351,12 +302,4 @@ public void setRotation(float rotationAngle){
public int getScroll() { public int getScroll() {
return scrollValue; return scrollValue;
} }
public void setClickAllowed(boolean allowed) {
clickAllowed = allowed;
}
public boolean isClickAllowed() {
return clickAllowed;
}
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,15 +28,6 @@ enum SoundAsset {
POWERUP("powerup.wav"), POWERUP("powerup.wav"),
ROBOT_READY("robotReady.wav"), ROBOT_READY("robotReady.wav"),
UNIT_READY("unitReady.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"); CONNECTED("connected.wav");
private final String path; 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 com.jme3.scene.control.AbstractControl;
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp; 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.MoveControl;
import pp.mdga.client.animation.JetAnimation;
import pp.mdga.client.gui.DiceControl; import pp.mdga.client.gui.DiceControl;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import java.util.*; import java.util.*;
@@ -202,7 +200,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
* @param y The y-coordinate on the grid * @param y The y-coordinate on the grid
* @return The corresponding world position * @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); return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
} }
@@ -445,7 +443,6 @@ private void throwPiece(UUID uuid){
// Synchronisation oder Animation // Synchronisation oder Animation
pieceControl.rotateInit(); pieceControl.rotateInit();
app.getAcousticHandler().playSound(MdgaSound.LOSE);
app.getModelSynchronize().animationEnd(); app.getModelSynchronize().animationEnd();
} }
@@ -723,32 +720,10 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
*/ */
public void throwPieceAnim(UUID uuid){ public void throwPieceAnim(UUID uuid){
pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getSpatial().addControl(new MoveControl(
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), ()->throwPiece(uuid)) 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();
} }
/** /**

View File

@@ -7,8 +7,6 @@
import com.jme3.math.Quaternion; import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; 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.scene.Spatial;
import com.jme3.shadow.DirectionalLightShadowFilter; import com.jme3.shadow.DirectionalLightShadowFilter;
import com.jme3.shadow.EdgeFilteringMode; import com.jme3.shadow.EdgeFilteringMode;
@@ -39,8 +37,6 @@ public class CameraHandler {
private Color ownColor; private Color ownColor;
private boolean init; private boolean init;
private boolean initRot; private boolean initRot;
private SSAOFilter ssaoFilter;
private FXAAFilter fxaaFilter;
/** /**
* Constructor for the CameraHandler. Initializes the camera settings and lighting. * Constructor for the CameraHandler. Initializes the camera settings and lighting.
@@ -69,9 +65,6 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
dlsf.setEnabled(true); dlsf.setEnabled(true);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON); dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
dlsf.setShadowIntensity(0.7f); 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); 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().addLight(ambient);
app.getRootNode().attachChild(sky); app.getRootNode().attachChild(sky);
fpp.addFilter(dlsf); fpp.addFilter(dlsf);
fpp.addFilter(ssaoFilter);
fpp.addFilter(fxaaFilter);
init = true; init = true;
initRot = true; initRot = true;
this.ownColor = ownColor; this.ownColor = ownColor;

View File

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

View File

@@ -1,63 +1,4 @@
package pp.mdga.client.dialog; package pp.mdga.client.dialog;
import com.jme3.math.Vector2f; public class InterruptDialog {
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;
}
}
} }

View File

@@ -92,16 +92,4 @@ public void resetPort() {
public void connectToServer() { public void connectToServer() {
connectServer(); 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 String hostname;
private int portNumber; private int portNumber;
private Future<Object> connectionFuture; private Future<Object> connectionFuture;
private MdgaServer serverInstance;
private Thread serverThread;
public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) { public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
super(app, node); super(app, node);
@@ -30,6 +28,7 @@ public void setPortNumber(int portNumber) {
this.portNumber = portNumber; this.portNumber = portNumber;
} }
protected Object initNetwork() { protected Object initNetwork() {
try { try {
this.network.initNetwork(this.hostname, this.portNumber); this.network.initNetwork(this.hostname, this.portNumber);
@@ -40,49 +39,25 @@ protected Object initNetwork() {
} }
protected void connectServer() { protected void connectServer() {
try { try {
connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork); connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
} catch (NumberFormatException var2) { } catch (NumberFormatException var2) {
throw new NumberFormatException("Port must be a number"); throw new NumberFormatException("Port must be a number");
} }
} }
protected void startServer() { protected void startServer() {
serverThread = new Thread(() -> { (new Thread(() -> {
try { try {
serverInstance = new MdgaServer(portNumber); MdgaServer mdgaServer = new MdgaServer(portNumber);
serverInstance.run(); mdgaServer.run();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
});
serverThread.start(); })).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;
}
} }
public void update(float delta) { public void update(float delta) {
@@ -90,14 +65,14 @@ public void update(float delta) {
try { try {
this.connectionFuture.get(); this.connectionFuture.get();
} catch (ExecutionException ignored) { } catch (ExecutionException ignored) {
// TODO: implement // todo: implement
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
} }
public NetworkSupport getNetwork() { public NetworkSupport getNetwork(){
return network; return network;
} }
} }

View File

@@ -177,109 +177,6 @@ public String getName() {
"CarryPro", "CarryPro",
"ProBaiter", "ProBaiter",
"GameWarden", "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(); Random random = new Random();

View File

@@ -3,20 +3,13 @@
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.ButtonLeft; import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight; import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.MenuButton; import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView; import pp.mdga.client.view.MdgaView;
import java.util.prefs.Preferences;
public class VideoSettingsDialog extends Dialog { public class VideoSettingsDialog extends Dialog {
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
private ButtonRight fullscreenButton;
private MenuButton backButton; private MenuButton backButton;
private ButtonRight restartButton;
private ButtonLeft hdButton9; private ButtonLeft hdButton9;
private ButtonLeft fullHdButton9; private ButtonLeft fullHdButton9;
@@ -36,24 +29,20 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück"); backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
restartButton = new ButtonRight(app, node, MdgaApp::restartApp, "Neustart", 1); // MenuButton für verschiedene Auflösungen erstellen
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f), "hd 16:9", 10);
fullscreenButton = new ButtonRight(app, node, () -> updateResolution(0, 0, 0, true), "Vollbild", 1); 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);
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);
hdButton10 = new ButtonRight(app, node, () -> updateResolution(1280, 800, 1.0f, false), "hd 16:10", 10); hdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1280, 800, 1.0f), "hd 16:10", 10);
fullHdButton10 = new ButtonRight(app, node, () -> updateResolution(1920, 1200, 2.25f, false), "full 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, () -> updateResolution(2560, 1600, 4.0f, false), "wqhd 16:10", 10); wqhdButton10 = new ButtonRight(app, node, () -> app.updateResolution(2560, 1600, 4.0f), "wqhd 16:10", 10);
float offset = 2.8f; float offset = 2.8f;
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset)); hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
hdButton10.setPos(new Vector2f(hdButton10.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; offset += 1.5f;
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset)); fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
@@ -79,7 +68,6 @@ protected void onShow() {
fullHdButton10.show(); fullHdButton10.show();
wqhdButton10.show(); wqhdButton10.show();
fullscreenButton.show();
backButton.show(); backButton.show();
} }
@@ -95,9 +83,7 @@ protected void onHide() {
fullHdButton10.hide(); fullHdButton10.hide();
wqhdButton10.hide(); wqhdButton10.hide();
fullscreenButton.hide();
backButton.hide(); backButton.hide();
restartButton.hide();
} }
public void update() { public void update() {
@@ -105,12 +91,4 @@ public void update() {
return; 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"); Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Black); mat.setColor("Color", ColorRGBA.Black);
circle.setMaterial(mat); circle.setMaterial(mat);
// root.attachChild(circle); root.attachChild(circle);
BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt"); BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt");
num = new BitmapText(guiFont); num = new BitmapText(guiFont);
num.setSize(0.3f); num.setSize(0.3f);

View File

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

View File

@@ -85,19 +85,6 @@ public void addCard(BonusCard card) {
bonusCardControlMap.get(card).setNumCard(newNum); 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() { public void clearSelectableCards() {
for (CardControl control : selectableCards) { for (CardControl control : selectableCards) {
control.setSelectable(false); control.setSelectable(false);
@@ -131,8 +118,6 @@ public void selectCard(CardControl cardControl) {
cardControl.select(); cardControl.select();
cardSelect = getKeyByValue(bonusCardControlMap, cardControl); cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
} }
app.getModelSynchronize().selectCard(cardSelect);
} }
public Camera getCardLayerCamera() { public Camera getCardLayerCamera() {

View File

@@ -74,31 +74,8 @@ public void hideDice() {
cardLayerHandler.hideDice(); cardLayerHandler.hideDice();
} }
//add own handCard public void addCard(BonusCard card) {
public void addCardOwn(BonusCard card) {
cardLayerHandler.addCard(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() { public void clearSelectableCards() {
@@ -148,11 +125,9 @@ public void hideText(){
actionTextHandler.hide(); actionTextHandler.hide();
} }
//addCard Enemy (DrawCardNotification)
public void drawCard(Color color) { public void drawCard(Color color) {
//Color != ownColor if (ownColor == color) actionTextHandler.drawCardOwn(color);
actionTextHandler.drawCard(playerNameHandler.getName(color), color); else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
playerNameHandler.addCard(color);
} }
public void finish(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.BitmapFont;
import com.jme3.font.BitmapText; import com.jme3.font.BitmapText;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings; import com.jme3.system.AppSettings;
import com.jme3.ui.Picture; import com.jme3.ui.Picture;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Vector;
public class PlayerNameHandler { public class PlayerNameHandler {
private final BitmapFont playerFont; private final BitmapFont playerFont;
private final Node playerNameNode; private final Node playerNameNode;
private final List<Color> playerOrder; private final List<Color> playerOrder;
private final Map<Color, String> colorNameMap; private final Map<Color, String> colorNameMap;
private final Map<Color, Integer> colorCardMap;
private final AppSettings appSettings; private final AppSettings appSettings;
private final AssetManager assetManager; private final AssetManager assetManager;
private Color ownColor; private Color ownColor;
@@ -47,7 +43,6 @@ public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings ap
playerNameNode = new Node("player name node"); playerNameNode = new Node("player name node");
playerOrder = new ArrayList<>(); playerOrder = new ArrayList<>();
colorNameMap = new HashMap<>(); colorNameMap = new HashMap<>();
colorCardMap = new HashMap<>();
this.appSettings = appSettings; this.appSettings = appSettings;
this.assetManager = assetManager; this.assetManager = assetManager;
} }
@@ -69,38 +64,13 @@ private void drawPlayers(){
if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name"); if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
Node nameParent = new Node("nameParent"); Node nameParent = new Node("nameParent");
nameParent.attachChild(createName(colorNameMap.get(color), i == 0, color == ownColor));
nameParent.attachChild(createColor(color)); 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); nameParent.setLocalTranslation(50,appSettings.getWindowHeight()-PADDING_TOP- MARGIN_NAMES *i,0);
playerNameNode.attachChild(nameParent); 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){ private String imagePath(Color color){
String root = "./Images/name_pictures/"; String root = "./Images/name_pictures/";
return switch(color){ 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); BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45 //renderedSize = 45
hudText.setSize(TEXT_SIZE); hudText.setSize(TEXT_SIZE);
@@ -154,18 +124,5 @@ public String getName(Color color){
return colorNameMap.get(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.*;
import com.jme3.network.serializing.Serializer; import com.jme3.network.serializing.Serializer;
import com.jme3.network.serializing.serializers.EnumSerializer; import com.jme3.network.serializing.serializers.EnumSerializer;
import pp.mdga.Resources;
import pp.mdga.game.*; import pp.mdga.game.*;
import pp.mdga.game.card.*;
import pp.mdga.message.client.*; import pp.mdga.message.client.*;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
@@ -125,7 +123,7 @@ private void initializeSerializables() {
Serializer.registerClass(NoTurnMessage.class); Serializer.registerClass(NoTurnMessage.class);
Serializer.registerClass(PauseGameMessage.class); Serializer.registerClass(PauseGameMessage.class);
Serializer.registerClass(PlayCardMessage.class); Serializer.registerClass(PlayCardMessage.class);
Serializer.registerClass(PossibleCardsMessage.class); Serializer.registerClass(PossibleCardMessage.class);
Serializer.registerClass(PossiblePieceMessage.class); Serializer.registerClass(PossiblePieceMessage.class);
Serializer.registerClass(RankingResponseMessage.class); Serializer.registerClass(RankingResponseMessage.class);
Serializer.registerClass(RankingRollAgainMessage.class); Serializer.registerClass(RankingRollAgainMessage.class);
@@ -137,7 +135,6 @@ private void initializeSerializables() {
Serializer.registerClass(UpdateReadyMessage.class); Serializer.registerClass(UpdateReadyMessage.class);
Serializer.registerClass(UpdateTSKMessage.class); Serializer.registerClass(UpdateTSKMessage.class);
Serializer.registerClass(WaitPieceMessage.class); Serializer.registerClass(WaitPieceMessage.class);
Serializer.registerClass(IncorrectRequestMessage.class);
Serializer.registerClass(Player.class); Serializer.registerClass(Player.class);
Serializer.registerClass(Statistic.class); Serializer.registerClass(Statistic.class);
Serializer.registerClass(Board.class); Serializer.registerClass(Board.class);
@@ -145,17 +142,10 @@ private void initializeSerializables() {
Serializer.registerClass(Piece.class); Serializer.registerClass(Piece.class);
Serializer.registerClass(BonusNode.class); Serializer.registerClass(BonusNode.class);
Serializer.registerClass(StartNode.class); Serializer.registerClass(StartNode.class);
Serializer.registerClass(PlayerData.class);
Serializer.registerClass(HomeNode.class); Serializer.registerClass(HomeNode.class);
Serializer.registerClass(PowerCard.class); Serializer.registerClass(PlayerDataMessage.class);
Serializer.registerClass(TurboCard.class); Serializer.registerClass(StartBriefingMessage.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());
} }
private void registerListeners() { private void registerListeners() {
@@ -208,31 +198,12 @@ private void messageReceived(HostedConnection source, ClientMessage message) {
pendingMessages.add(new ReceivedMessage(message, source.getId())); 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 @Override
public void connectionAdded(Server server, HostedConnection hostedConnection) { public void connectionAdded(Server server, HostedConnection hostedConnection) {
System.out.println("new connection " + hostedConnection); //NON-NLS System.out.println("new connection " + hostedConnection); //NON-NLS
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
if (this.myServer.getConnections().size() == 1) {
if (this.myServer.getConnections().size() > Resources.MAX_PLAYERS) { this.logic.getGame().setHost(hostedConnection.getId());
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());
}
} }
} }
@@ -307,21 +278,4 @@ public void broadcast(ServerMessage message) {
public void disconnectClient(int id) { public void disconnectClient(int id) {
this.myServer.getConnection(id).close(""); 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); ceremonyButtons.add(button);
if(state.equals(SubState.AWARD_CEREMONY)) { if(state.equals(SubState.AWARD_CEREMONY)) {
button.hide();
button.show(); button.show();
} }
} }
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) { 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.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; package pp.mdga.client.view;
import com.jme3.post.FilterPostProcessor; 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.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler; import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.board.CameraHandler; import pp.mdga.client.board.CameraHandler;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.ButtonLeft; import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight; import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.dialog.InterruptDialog;
import pp.mdga.client.gui.GuiHandler; import pp.mdga.client.gui.GuiHandler;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color; 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 { public class GameView extends MdgaView {
private BoardHandler boardHandler; private BoardHandler boardHandler;
@@ -20,38 +35,28 @@ public class GameView extends MdgaView {
private ButtonLeft leaveButton; private ButtonLeft leaveButton;
private ButtonRight confirmButton; private ButtonRight confirmButton;
private ButtonRight noPowerButton;
private Color ownColor = null; private Color ownColor = null;
private InterruptDialog interruptDialog;
private FilterPostProcessor fpp; private FilterPostProcessor fpp;
private Node guiHandlerNode = new Node();
public GameView(MdgaApp app) { public GameView(MdgaApp app) {
super(app); super(app);
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); 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()); fpp = new FilterPostProcessor(app.getAssetManager());
this.camera = new CameraHandler(app, fpp); this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, rootNode, fpp); this.boardHandler = new BoardHandler(app, rootNode, fpp);
guiHandler = new GuiHandler(app, guiHandlerNode); guiHandler = new GuiHandler(app, guiNode);
guiNode.attachChild(guiHandlerNode);
} }
@Override @Override
public void onEnter() { public void onEnter() {
setOwnColor(Color.AIRFORCE);
camera.init(ownColor); camera.init(ownColor);
boardHandler.init(); boardHandler.init();
guiHandler.init(ownColor); guiHandler.init(ownColor);
@@ -59,6 +64,13 @@ public void onEnter() {
app.getViewPort().addProcessor(fpp); app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START); 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 @Override
@@ -69,7 +81,6 @@ public void onLeave() {
confirmButton.hide(); confirmButton.hide();
noPowerButton.hide();
app.getViewPort().removeProcessor(fpp); app.getViewPort().removeProcessor(fpp);
} }
@@ -114,45 +125,10 @@ public Color getOwnColor() {
} }
public void needConfirm() { public void needConfirm() {
noPowerButton.hide();
confirmButton.show(); confirmButton.show();
} }
public void noConfirm() { public void noConfirm() {
confirmButton.hide(); 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.LobbyButton;
import pp.mdga.client.button.SettingsButton; import pp.mdga.client.button.SettingsButton;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.message.client.StartGameMessage;
import pp.mdga.notification.GameNotification; import pp.mdga.notification.GameNotification;
public class LobbyView extends MdgaView { public class LobbyView extends MdgaView {
@@ -26,7 +25,6 @@ public class LobbyView extends MdgaView {
private ButtonLeft leaveButton; private ButtonLeft leaveButton;
private ButtonRight readyButton; private ButtonRight readyButton;
private ButtonRight startButton;
private LobbyButton cyberButton; private LobbyButton cyberButton;
private LobbyButton airforceButton; private LobbyButton airforceButton;
@@ -44,7 +42,6 @@ public LobbyView(MdgaApp app) {
leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1); leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1);
readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 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); cyberButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.CYBER), Color.CYBER);
airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE); airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
@@ -64,10 +61,6 @@ public void onEnter() {
leaveButton.show(); leaveButton.show();
readyButton.show(); readyButton.show();
if(app.getGameLogic().isHost()) {
startButton.show();
}
cyberButton.show(); cyberButton.show();
airforceButton.show(); airforceButton.show();
armyButton.show(); armyButton.show();
@@ -102,7 +95,6 @@ public void onEnter() {
public void onLeave() { public void onLeave() {
leaveButton.hide(); leaveButton.hide();
readyButton.hide(); readyButton.hide();
startButton.hide();
airforceButton.hide(); airforceButton.hide();
armyButton.hide(); armyButton.hide();
@@ -231,10 +223,6 @@ private void toggleTsk(Color color) {
break; break;
} }
if(isReady) {
setReady(own, false);
}
switch (taken) { switch (taken) {
case NOT: case NOT:
app.getModelSynchronize().selectTsk(color); app.getModelSynchronize().selectTsk(color);

View File

@@ -7,6 +7,9 @@
import pp.mdga.client.dialog.JoinDialog; import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.dialog.StartDialog; import pp.mdga.client.dialog.StartDialog;
import java.net.Inet4Address;
import java.net.UnknownHostException;
public class MainView extends MdgaView { public class MainView extends MdgaView {
private enum SubState { private enum SubState {
HOST, HOST,
@@ -60,12 +63,12 @@ public void onUpdate(float tpf) {
@Override @Override
protected void onEnterOverlay(Overlay overlay) { protected void onEnterOverlay(Overlay overlay) {
guiNode.detachChild(background); guiNode.detachChild(background);
settingsNode.attachChild(background); overlayNode.attachChild(background);
} }
@Override @Override
protected void onLeaveOverlay(Overlay overlay) { protected void onLeaveOverlay(Overlay overlay) {
settingsNode.detachChild(background); overlayNode.detachChild(background);
guiNode.attachChild(background); guiNode.attachChild(background);
} }
@@ -93,7 +96,6 @@ private void mainMenu() {
private void tryHost() { private void tryHost() {
int port = 0; int port = 0;
String text = hostDialog.getPort(); String text = hostDialog.getPort();
app.getGameLogic().selectHost("");
try { try {
port = Integer.parseInt(text); port = Integer.parseInt(text);
@@ -106,6 +108,10 @@ private void tryHost() {
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
} }
hostDialog.connectServerAsClient(); hostDialog.connectServerAsClient();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setHost(port); app.getModelSynchronize().setHost(port);
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); //app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return; return;
@@ -121,7 +127,6 @@ private void tryJoin() {
int port = 0; int port = 0;
String ip = joinDialog.getIpt(); String ip = joinDialog.getIpt();
String portText = joinDialog.getPort(); String portText = joinDialog.getPort();
app.getGameLogic().selectJoin("");
try { try {
// Validate the port // Validate the port
@@ -135,6 +140,11 @@ private void tryJoin() {
app.getModelSynchronize().setName(startDialog.getName()); app.getModelSynchronize().setName(startDialog.getName());
joinDialog.setHostname(ip); joinDialog.setHostname(ip);
joinDialog.connectToServer(); joinDialog.connectToServer();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setJoin(ip, port);
return; return;
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@@ -224,13 +234,5 @@ public void back() {
break; 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.asset.TextureKey;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Quad;
import com.jme3.system.NanoTimer;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound; import pp.mdga.client.acoustic.MdgaSound;
@@ -25,7 +22,7 @@ public enum Overlay {
protected MdgaApp app; protected MdgaApp app;
protected Node rootNode = new Node("View Root"); protected Node rootNode = new Node("View Root");
protected Node guiNode = new Node("View Root GUI"); 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; private SettingsButton settingsButton;
@@ -33,18 +30,15 @@ public enum Overlay {
private VideoSettingsDialog videoSettingsDialog; private VideoSettingsDialog videoSettingsDialog;
private AudioSettingsDialog audioSettingsDialog; private AudioSettingsDialog audioSettingsDialog;
protected LabelButton infoLabel = null;
protected NanoTimer infoTimer = new NanoTimer();
private int settingsDepth = 0; private int settingsDepth = 0;
public MdgaView(MdgaApp app) { public MdgaView(MdgaApp app) {
this.app = app; this.app = app;
settingsButton = new SettingsButton(app, guiNode, this::enterSettings); settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
settingsDialog = new SettingsDialog(app, settingsNode, this); settingsDialog = new SettingsDialog(app, overlayNode, this);
videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this); videoSettingsDialog = new VideoSettingsDialog(app, overlayNode, this);
audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this); audioSettingsDialog = new AudioSettingsDialog(app, overlayNode, this);
} }
public void enter() { public void enter() {
@@ -86,11 +80,6 @@ public void update(float tpf) {
videoSettingsDialog.update(); videoSettingsDialog.update();
audioSettingsDialog.update(); audioSettingsDialog.update();
if (null != infoLabel && infoTimer.getTimeInSeconds() > 5) {
infoLabel.hide();
infoLabel = null;
}
onUpdate(tpf); onUpdate(tpf);
} }
@@ -124,7 +113,7 @@ protected Geometry createBackground(String texturePath) {
public void enterSettings() { public void enterSettings() {
enterOverlay(Overlay.SETTINGS); enterOverlay(Overlay.SETTINGS);
app.getGuiNode().attachChild(settingsNode); app.getGuiNode().attachChild(overlayNode);
settingsDialog.show(); settingsDialog.show();
@@ -134,7 +123,7 @@ public void enterSettings() {
public void leaveSettings() { public void leaveSettings() {
leaveOverlay(Overlay.SETTINGS); leaveOverlay(Overlay.SETTINGS);
app.getGuiNode().detachChild(settingsNode); app.getGuiNode().detachChild(overlayNode);
settingsDialog.hide(); settingsDialog.hide();
@@ -204,24 +193,4 @@ public void pressForward() {
ceremonyView.forward(); 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 world 0,0 90
#tree_small 1,1 0
#tree_big 0,0 0
#Marine Pos #Marine Pos
marine 4,-5 270 marine 4,-5 270
@@ -129,144 +131,3 @@ node_home_blue 4,0 0
node_home_blue 3,0 0 node_home_blue 3,0 0
node_home_blue 2,0 0 node_home_blue 2,0 0
node_home_blue 1,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; package pp.mdga.client;
import pp.mdga.client.ceremonystate.CeremonyStates; import pp.mdga.client.ceremonyState.CeremonyStates;
import pp.mdga.client.ceremonystate.PodiumState; import pp.mdga.client.ceremonyState.PodiumState;
import pp.mdga.client.ceremonystate.StatisticsState; import pp.mdga.client.ceremonyState.StatisticsState;
import pp.mdga.notification.CeremonyNotification;
public class CeremonyState extends ClientState { public class CeremonyState extends ClientState {
@@ -11,38 +12,21 @@ public class CeremonyState extends ClientState {
private final PodiumState podiumState = new PodiumState(this, logic); private final PodiumState podiumState = new PodiumState(this, logic);
private final StatisticsState statisticsState = new StatisticsState(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) { public CeremonyState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
/**
* Enters the new state machine
*/
@Override @Override
public void enter() { public void enter() {
setState(podiumState); setState(podiumState);
logic.addNotification(createCeremonyNotification()); logic.addNotification(createCeremonyNotification());
} }
/**
* exits this state
*/
@Override @Override
public void exit() { public void exit() {
currentState.exit(); currentState.exit();
} }
/**
* This method is used to set a new SubState
*
* @param state the state to be set
*/
public void setState(CeremonyStates state){ public void setState(CeremonyStates state){
if(this.currentState != null){ if(this.currentState != null){
this.currentState.exit(); this.currentState.exit();
@@ -51,29 +35,14 @@ public void setState(CeremonyStates state){
currentState = state; currentState = state;
} }
/**
* This method get the PodiumState
*
* @return the PodiumState
*/
public PodiumState getPodiumState(){ public PodiumState getPodiumState(){
return podiumState; return podiumState;
} }
/**
* This method get the StatisticsState
*
* @return the StatisticsState
*/
public StatisticsState getStatisticsState(){ public StatisticsState getStatisticsState(){
return statisticsState; return statisticsState;
} }
/**
* This method is used to get the current State
*
* @return the current State
*/
public CeremonyStates getState(){ public CeremonyStates getState(){
return currentState; return currentState;
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,9 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.settingsstate.AudioSettingsState; import pp.mdga.client.settingsState.AudioSettingsState;
import pp.mdga.client.settingsstate.MainSettingsState; import pp.mdga.client.settingsState.MainSettingsState;
import pp.mdga.client.settingsstate.SettingStates; import pp.mdga.client.settingsState.SettingStates;
import pp.mdga.client.settingsstate.VideoSettingsState; import pp.mdga.client.settingsState.VideoSettingsState;
public class SettingsState extends ClientState { public class SettingsState extends ClientState {
@@ -49,23 +49,14 @@ public SettingStates getState(){
return currentState; return currentState;
} }
/**
* Returns the main settings state
*/
public MainSettingsState getMainSettingsState(){ public MainSettingsState getMainSettingsState(){
return mainSettingsState; return mainSettingsState;
} }
/**
* Returns the audio settings state
*/
public AudioSettingsState getAudioSettingsState(){ public AudioSettingsState getAudioSettingsState(){
return audioSettingsState; return audioSettingsState;
} }
/**
* Returns the video settings state
*/
public VideoSettingsState getVideoSettingsState(){ public VideoSettingsState getVideoSettingsState(){
return videoSettingsState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.CeremonyState;
import pp.mdga.client.ClientGameLogic; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
@@ -6,14 +6,18 @@
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.Player; import pp.mdga.game.Player;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.*; 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 pp.mdga.notification.*;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class LobbyState extends DialogStates { public class LobbyState extends DialogStates {
@@ -26,7 +30,7 @@ public LobbyState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
logic.send(new JoinedLobbyMessage(logic.getOwnPlayerName())); logic.send(new JoinedLobbyMessage(parent.getOwnPlayerName()));
} }
@Override @Override
@@ -56,58 +60,61 @@ public void selectReady() {
} }
@Override @Override
public void selectUnready() { public void selectUnready(){
logic.send(new LobbyNotReadyMessage()); logic.send(new LobbyNotReadyMessage());
} }
@Override @Override
public void selectStart() { public void selectStart(){
if (logic.isHost() && logic.getGame().areAllReady()) { if(logic.isHost() && logic.getGame().allReady()){
logic.send(new StartGameMessage()); logic.send(new StartGameMessage(false));
} else if(logic.isHost() && !logic.getGame().allReady()) {
logic.send(new StartGameMessage(true));
} else { } else {
logic.send(new StartGameMessage());
LOGGER.log(System.Logger.Level.ERROR, "You are not the host"); LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
} }
} }
@Override @Override
public void received(ServerStartGameMessage msg) { public void received(StartBriefingMessage 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);
}
}
}
logic.getGame().setBoard(msg.getBoard()); 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<>(); public void received(PlayerDataMessage msg){
for (Piece piece : player.getPieces()) { logic.getGame().getBoard().addPlayerData(msg.getColor(), msg.getPlayerData());
pieces.add(piece.getUuid()); }
@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()); logic.setState(logic.getGameState());
} }
@Override @Override
public void received(LobbyPlayerJoinedMessage msg) { public void received(LobbyPlayerJoinedMessage msg){
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) { if(msg.getPlayer().getName().equals(parent.getOwnPlayerName())){
logic.setOwnPlayerId(msg.getId()); parent.setOwnPlayerId(msg.getId());
} }
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) { if (msg.isHost() && msg.getId() == parent.getOwnPlayerId()){
logic.setHost(true); 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()); logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
} }
@Override @Override
public void received(UpdateTSKMessage msg) { public void received(UpdateTSKMessage msg){
if (msg.isTaken()) { if(msg.isTaken()) {
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId() == msg.getId())); logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), parent.getOwnPlayerId()== msg.getId()));
} else { } else {
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor())); logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
} }
@@ -116,13 +123,13 @@ public void received(UpdateTSKMessage msg) {
} }
@Override @Override
public void received(LobbyPlayerLeaveMessage msg) { public void received(LobbyPlayerLeaveMessage msg){
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor())); logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
logic.getGame().getPlayers().remove(msg.getId()); logic.getGame().getPlayers().remove(msg.getId());
} }
@Override @Override
public void received(UpdateReadyMessage msg) { public void received(UpdateReadyMessage msg){
//TODO server sendet kein update on UNready //TODO server sendet kein update on UNready
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady())); logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
@@ -8,44 +8,41 @@ public class StartDialogState extends DialogStates {
private final DialogsState parent; private final DialogsState parent;
/**
* Constructor for the StartDialogState
* @param parent the parent state
* @param logic the logic
*/
public StartDialogState(ClientState parent, ClientGameLogic logic) { public StartDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.parent = (DialogsState) parent; this.parent = (DialogsState) parent;
} }
/**
* Enter the state
*/
@Override @Override
public void enter() { public void enter() {
} }
/**
* Exit the state
*/
@Override @Override
public void exit() { 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 @Override
public void setName(String name) { public void setName(String name) {
logic.setOwnPlayerName(name);
parent.setState(parent.getNetworkDialog()); parent.setState(parent.getNetworkDialog());
parent.setOwnPlayerName(name);
} }
/**
* Select the leave option
*/
@Override @Override
public void selectLeave() { public void selectLeave() {
parent.exit(); 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates; 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.RollRankingDiceState; import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.ActivePlayerMessage;
import pp.mdga.message.server.DieMessage; import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.RankingResponseMessage; import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage; 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 RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic); private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
private final Intro intro = new Intro(this, logic);
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) { public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.parent = (GameState) parent; 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 @Override
public void enter() { public void enter() {
this.setState(this.rollRankingDiceState); this.setState(this.rollRankingDiceState);
@@ -70,11 +46,6 @@ public void selectDice() {
state.selectDice(); state.selectDice();
} }
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
state.received(msg); state.received(msg);
@@ -90,8 +61,19 @@ public void received(RankingResponseMessage msg){
state.received(msg); state.received(msg);
} }
@Override public RollRankingDiceState getRollRankingDice() {
public void received(ActivePlayerMessage msg){ return rollRankingDiceState;
state.received(msg); }
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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
@@ -12,45 +12,40 @@
import pp.mdga.notification.SwapPieceNotification; import pp.mdga.notification.SwapPieceNotification;
import pp.mdga.notification.ThrowPieceNotification; import pp.mdga.notification.ThrowPieceNotification;
import java.util.UUID;
public abstract class GameStates extends ClientState { public abstract class GameStates extends ClientState {
public GameStates(ClientState parent, ClientGameLogic logic) { public GameStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
protected void handlePowerCard(PlayCardMessage msg) { protected void handlePowerCard(PlayCardMessage msg){
if (msg.getCard().getCard().equals(BonusCard.TURBO)) { if (msg.getCard().equals(BonusCard.TURBO)){
logic.getGame().setDiceModifier(msg.getDiceModifier()); logic.getGame().setDiceModifier(msg.getDiceModifier());
} else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) { } else if (msg.getCard().equals(BonusCard.SHIELD)){
handleShield(msg.getPieces().get(0).getUuid()); 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 { } else {
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid()); Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid()); Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece); int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid())); logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece); logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
} }
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard());
logic.getGame().getDiscardPile().add(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().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.addNotification(new ThrowPieceNotification(piece.getUuid()));
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown(); logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
logic.getGame().getGameStatistics().increasePiecesBeingThrown(); logic.getGame().getGameStatistics().increasePiecesBeingThrown();
piece.setState(PieceState.WAITING); 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.ActivePlayerNotification; import pp.mdga.notification.*;
import pp.mdga.notification.HomeMoveNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayCardNotification;
public class SpectatorState extends GameStates { public class SpectatorState extends GameStates {
@@ -30,15 +27,15 @@ public void exit() {
} }
@Override @Override
public void received(CeremonyMessage msg) { public void received(CeremonyMessage msg){
logic.setState(logic.getCeremony()); logic.setState(logic.getCeremony());
} }
@Override @Override
public void received(DieMessage msg) { public void received(DieMessage msg){
//logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); // 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().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();
} }
@@ -46,8 +43,8 @@ public void received(DieMessage msg) {
} }
@Override @Override
public void received(PlayCardMessage msg) { public void received(PlayCardMessage msg){
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
handlePowerCard(msg); handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed(); logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -55,26 +52,26 @@ public void received(PlayCardMessage msg) {
} }
@Override @Override
public void received(ActivePlayerMessage msg) { public void received(ActivePlayerMessage msg){
logic.addNotification(new ActivePlayerNotification(msg.getColor())); logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor()); logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(MoveMessage msg) { public void received(MoveMessage msg){
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()) { if (msg.isHomeMove()){
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant(); 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 { } else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant()); throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().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.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else { } 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState; import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gamestate.turnstate.MovePieceState; import pp.mdga.client.gameState.turnState.MovePieceState;
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState; import pp.mdga.client.gameState.turnState.PlayPowerCardState;
import pp.mdga.client.gamestate.turnstate.PowerCardState; import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.client.gamestate.turnstate.RollDiceState; import pp.mdga.client.gameState.turnState.RollDiceState;
import pp.mdga.client.gamestate.turnstate.TurnStates; import pp.mdga.client.gameState.turnState.TurnStates;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
@@ -47,11 +47,6 @@ public void setState(TurnStates state){
this.state = state; this.state = state;
} }
@Override
public void selectDice(){
state.selectDice();
}
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece){
state.selectPiece(piece); state.selectPiece(piece);
@@ -113,7 +108,7 @@ public void received(DiceAgainMessage msg){
} }
@Override @Override
public void received(PossibleCardsMessage msg){ public void received(PossibleCardMessage msg){
state.received(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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.game.Piece; import pp.mdga.game.*;
import pp.mdga.game.PieceState;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.*; import pp.mdga.notification.*;
@@ -28,21 +27,21 @@ public void exit() {
} }
@Override @Override
public void received(CeremonyMessage msg) { public void received(CeremonyMessage msg){
logic.setState(logic.getCeremony()); logic.setState(logic.getCeremony());
} }
@Override @Override
public void received(DiceNowMessage msg) { public void received(DiceNowMessage msg){
logic.addNotification(new DiceNowNotification()); logic.addNotification(new DiceNowNotification());
parent.setState(parent.getTurn()); parent.setState(parent.getTurn());
} }
@Override @Override
public void received(DieMessage msg) { public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes())); // 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().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();
} }
@@ -50,8 +49,8 @@ public void received(DieMessage msg) {
} }
@Override @Override
public void received(PlayCardMessage msg) { public void received(PlayCardMessage msg){
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
handlePowerCard(msg); handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed(); logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -59,21 +58,21 @@ public void received(PlayCardMessage msg) {
} }
@Override @Override
public void received(ActivePlayerMessage msg) { public void received(ActivePlayerMessage msg){
logic.addNotification(new ActivePlayerNotification(msg.getColor())); logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor()); logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(MoveMessage msg) { public void received(MoveMessage msg){
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()) { if (msg.isHomeMove()){
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant(); 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);
for (int i = msg.getTargetIndex() + 1; i < 4; i++) { for(int i = msg.getTargetIndex() + 1; i < 4; i++){
if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) { if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
pieceToMove.setState(PieceState.HOME); pieceToMove.setState(PieceState.HOME);
break; break;
} }
@@ -85,7 +84,7 @@ public void received(MoveMessage msg) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().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.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else { } 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.GameStates; import pp.mdga.client.gameState.GameStates;
public abstract class DetermineStartPlayerStates extends GameStates { public abstract class DetermineStartPlayerStates extends GameStates {
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage; import pp.mdga.message.server.DieMessage;
import pp.mdga.notification.DiceNowNotification; import pp.mdga.notification.DiceNowNotification;
@@ -28,12 +28,13 @@ public void exit() {
@Override @Override
public void selectDice(){ public void selectDice(){
System.out.println("selectDice");
logic.send(new RequestDieMessage()); logic.send(new RequestDieMessage());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getDialogs().getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
parent.setState(parent.getWaitRanking()); 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState; import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*; import pp.mdga.client.gameState.turnState.choosePieceState.*;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.client.AnimationEndMessage;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
@@ -46,7 +46,7 @@ public void received(SpectatorMessage msg){
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceAgainMessage msg){
parent.setState(parent.getRollDice()); parent.setState(parent.getRollDice());
} }

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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.client.AnimationEndMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.PlayCardNotification; import pp.mdga.notification.PlayCardNotification;
@@ -20,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
handlePowerCard(playCardMessage); handlePowerCard(playCardMessage);
} }
@@ -35,7 +35,7 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd(){
logic.send(new AnimationEndMessage());
parent.setState(parent.getRollDice()); parent.setState(parent.getRollDice());
logic.send(new AnimationEndMessage());
} }
} }

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

View File

@@ -1,14 +1,10 @@
package pp.mdga.client.gamestate.turnstate; package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; 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.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage; import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.NoTurnMessage; import pp.mdga.message.server.NoTurnMessage;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.RollDiceNotification;
public class RollDiceState extends TurnStates { public class RollDiceState extends TurnStates {
@@ -21,7 +17,7 @@ public RollDiceState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
logic.addNotification(new DiceNowNotification());
} }
@Override @Override
@@ -33,27 +29,11 @@ public TurnState getParent() {
return parent; return parent;
} }
@Override
public void selectDice(){
logic.send(new RequestDieMessage());
}
@Override
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),false)); parent.setState(parent.getChoosePiece());
} }
@Override
public void selectAnimationEnd(){
logic.send(new AnimationEndMessage());
}
// @Override
// public void received(ChoosePieceStateMessage msg){
// parent.setState(parent.getChoosePiece());
// }
@Override @Override
public void received(NoTurnMessage msg){ public void received(NoTurnMessage msg){
parent.getParent().setState(parent.getParent().getWaiting()); parent.getParent().setState(parent.getParent().getWaiting());

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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.GameStates; import pp.mdga.client.gameState.GameStates;
public abstract class TurnStates extends GameStates { public abstract class TurnStates extends GameStates {
public TurnStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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 abstract class ChoosePieceStates extends TurnStates {
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.message.server.StartPieceMessage; import pp.mdga.message.server.StartPieceMessage;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.SelectableMoveNotification; import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.WaitMoveNotification; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; 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; this.possiblePieces = possiblePieces;
} }
@Override @Override
public void selectPiece(Piece piece) { public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(possiblePieces.contains(piece)){ if(possiblePieces.contains(piece)){
pieces.add(piece); logic.send(new SelectedPiecesMessage(piece.getUuid()));
logic.send(new SelectedPiecesMessage(pieces));
} }
} }
@Override @Override
public void received(MoveMessage msg) { public void received(MoveMessage msg){
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()) { if(msg.isHomeMove()){
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); 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 { } else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant()); 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
public class StartPieceState extends ChoosePieceStates { public class StartPieceState extends ChoosePieceStates {
private final ChoosePieceState parent; private final ChoosePieceState parent;
@@ -32,10 +30,8 @@ public void exit() {
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){ if(moveablePiece.equals(piece)){
pieces.add(piece); logic.send(new SelectedPiecesMessage(piece.getUuid()));
logic.send(new SelectedPiecesMessage(pieces));
} }
} }

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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.game.PieceState; import pp.mdga.game.PieceState;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
import java.util.List;
public class WaitingPieceState extends ChoosePieceStates { public class WaitingPieceState extends ChoosePieceStates {
private final ChoosePieceState parent; private final ChoosePieceState parent;
@@ -32,10 +29,8 @@ public void exit() {
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){ if(moveablePiece.equals(piece)){
pieces.add(piece); logic.send(new SelectedPiecesMessage(piece.getUuid()));
logic.send(new SelectedPiecesMessage(pieces));
} }
} }

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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.BonusCard;
import pp.mdga.game.card.*;
import pp.mdga.message.client.NoPowerCardMessage; import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.SelectCardMessage; import pp.mdga.message.client.SelectCardMessage;
import pp.mdga.message.server.DiceNowMessage; import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PlayCardMessage; 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.message.server.PossiblePieceMessage;
import pp.mdga.notification.SelectableCardsNotification; import pp.mdga.notification.SelectableCardsNotification;
@@ -22,7 +21,7 @@
public class ChoosePowerCardState extends PowerCardStates { public class ChoosePowerCardState extends PowerCardStates {
private final PowerCardState parent; private final PowerCardState parent;
private ArrayList<PowerCard> possibleCards = new ArrayList<>(); private ArrayList<BonusCard> possibleCards;
/** /**
* Constructor * Constructor
@@ -39,6 +38,8 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
*/ */
@Override @Override
public void enter() { public void enter() {
possibleCards = new ArrayList<>();
//TODO: logic.send(new RequestPossibleCardsMessage());
} }
/** /**
@@ -46,7 +47,7 @@ public void enter() {
*/ */
@Override @Override
public void exit() { public void exit() {
possibleCards = new ArrayList<>(); possibleCards = null;
} }
/** /**
@@ -54,15 +55,9 @@ public void exit() {
* @param msg possible cards message * @param msg possible cards message
*/ */
@Override @Override
public void received(PossibleCardsMessage msg){ public void received(PossibleCardMessage msg){
possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards(); possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
ArrayList<BonusCard> possibleBonusCards = new ArrayList<>(); logic.addNotification(new SelectableCardsNotification(possibleCards));
for (PowerCard card : possibleCards) {
if (!possibleBonusCards.contains(card.getCard())) {
possibleBonusCards.add(card.getCard());
}
}
logic.addNotification(new SelectableCardsNotification(possibleBonusCards));
} }
/** /**
@@ -72,7 +67,7 @@ public void received(PossibleCardsMessage msg){
@Override @Override
public void selectCard(BonusCard card){ public void selectCard(BonusCard card){
if(card != null){ if(card != null){
logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card))); logic.send(new SelectCardMessage(card));
} else { } else {
logic.send(new NoPowerCardMessage()); logic.send(new NoPowerCardMessage());
} }
@@ -84,9 +79,10 @@ public void selectCard(BonusCard card){
*/ */
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg){
if(msg.getCard().getCard().equals(BonusCard.TURBO)){ if(msg.getCard().equals(BonusCard.TURBO)){
parent.getParent().getPlayPowerCard().setPlayCard(msg); logic.getGame().setDiceModifier(msg.getDiceModifier());
parent.getParent().setState(parent.getParent().getPlayPowerCard()); } 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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 abstract class PowerCardStates extends TurnStates {
public PowerCardStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

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