removed unused imports and reformatted the code for code style

This commit is contained in:
Daniel Grigencha
2024-12-11 05:34:34 +01:00
parent d8816be811
commit aa44b84648
155 changed files with 1662 additions and 3882 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,21 +0,0 @@
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000070ba272e8104, pid=54211, tid=54346
#
# JRE version: OpenJDK Runtime Environment Temurin-20.0.2+9 (20.0.2+9) (build 20.0.2+9)
# Java VM: OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (20.0.2+9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xee8104] SystemDictionary::find_or_define_helper(Symbol*, Handle, InstanceKlass*, JavaThread*)+0x304
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/cedric/ProgProjekt/Gruppe-01/Projekte/mdga/client/core.54211)
#
# If you would like to submit a bug report, please visit:
# https://github.com/adoptium/adoptium-support/issues
#
--------------- S U M M A R Y ------------
Command Line: -Ddebugger.agent.enable.coroutines=true -Djava.util.logging.config.file=logging.properties -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:40559 -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea pp.mdga.client.MdgaApp
Host: AMD Ryzen 5 8640HS w/ Radeon 760M Graphics, 12 cores, 14G,

View File

@@ -1,171 +0,0 @@
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fc14e0eef41, pid=60653, tid=60689
#
# JRE version: OpenJDK Runtime Environment (21.0.5+11) (build 21.0.5+11)
# Java VM: OpenJDK 64-Bit Server VM (21.0.5+11, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C [libgallium-24.2.8-arch1.1.so+0x8eef41]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/cedric/ProgProjekt/Gruppe-01/Projekte/mdga/client/core.60653)
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- S U M M A R Y ------------
Command Line: -Ddebugger.agent.enable.coroutines=true -Djava.util.logging.config.file=logging.properties -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:39131 -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea pp.mdga.client.MdgaApp
Host: AMD Ryzen 5 8640HS w/ Radeon 760M Graphics, 12 cores, 14G, Manjaro Linux
Time: Sun Dec 8 18:11:23 2024 CET elapsed time: 295.650309 seconds (0d 0h 4m 55s)
--------------- T H R E A D ---------------
Current thread (0x00007fc17ca803b0): JavaThread "jME3 Main" [_thread_in_native, id=60689, stack(0x00007fc159425000,0x00007fc159525000) (1024K)]
Stack: [0x00007fc159425000,0x00007fc159525000], sp=0x00007fc159522300, free space=1012k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libgallium-24.2.8-arch1.1.so+0x8eef41]
C [libgallium-24.2.8-arch1.1.so+0xf4a849]
C [libgallium-24.2.8-arch1.1.so+0x6ccb71]
C [libgallium-24.2.8-arch1.1.so+0x6c58ae]
C [libgallium-24.2.8-arch1.1.so+0x6c6013]
C [libgallium-24.2.8-arch1.1.so+0x6cddf8]
C [libgallium-24.2.8-arch1.1.so+0x141327]
C [libgallium-24.2.8-arch1.1.so+0x5fc8b]
C [libGLX_mesa.so.0+0x4f2e0]
C [libGLX_mesa.so.0+0x40496]
C [libGLX_mesa.so.0+0x2efa5]
J 2042 org.lwjgl.system.JNI.invokePV(JJ)V (0 bytes) @ 0x00007fc16c1abb6f [0x00007fc16c1abaa0+0x00000000000000cf]
J 4039 c1 org.lwjgl.glfw.GLFW.glfwSwapBuffers(J)V (21 bytes) @ 0x00007fc164d8684c [0x00007fc164d86760+0x00000000000000ec]
J 3912 c1 com.jme3.system.lwjgl.LwjglWindow.runLoop()V (177 bytes) @ 0x00007fc164d44b34 [0x00007fc164d442c0+0x0000000000000874]
j com.jme3.system.lwjgl.LwjglWindow.run()V+54
j java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5 java.base@21.0.5
j java.lang.Thread.run()V+19 java.base@21.0.5
v ~StubRoutines::call_stub 0x00007fc16bb37cc6
V [libjvm.so+0x6d0894]
V [libjvm.so+0x6d14fd]
V [libjvm.so+0x79a7be]
V [libjvm.so+0x6cac55]
V [libjvm.so+0x9d62c1]
C [libc.so.6+0x9439d]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 2042 org.lwjgl.system.JNI.invokePV(JJ)V (0 bytes) @ 0x00007fc16c1abafc [0x00007fc16c1abaa0+0x000000000000005c]
J 4039 c1 org.lwjgl.glfw.GLFW.glfwSwapBuffers(J)V (21 bytes) @ 0x00007fc164d8684c [0x00007fc164d86760+0x00000000000000ec]
J 3912 c1 com.jme3.system.lwjgl.LwjglWindow.runLoop()V (177 bytes) @ 0x00007fc164d44b34 [0x00007fc164d442c0+0x0000000000000874]
j com.jme3.system.lwjgl.LwjglWindow.run()V+54
j java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5 java.base@21.0.5
j java.lang.Thread.run()V+19 java.base@21.0.5
v ~StubRoutines::call_stub 0x00007fc16bb37cc6
siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x00000000000000c9
Registers:
RAX=0x0000000000000000, RBX=0x00007fc09825b2a0, RCX=0x0000000000000006, RDX=0x0000000028200000
RSP=0x00007fc159522300, RBP=0x00007fc159522310, RSI=0x00007fc0998d3604, RDI=0x00007fc09825b7a0
R8 =0x0000000000000006, R9 =0x00000000aa959a6a, R10=0x0000000000000263, R11=0x00007fc099bc36c0
R12=0x00007fc0998d35e0, R13=0x000000058bc5f100, R14=0x000000058bc5f140, R15=0x0000000000000040
RIP=0x00007fc14e0eef41, EFLAGS=0x0000000000010202, CSGSFS=0x002b000000000033, ERR=0x0000000000000004
TRAPNO=0x000000000000000e
Register to memory mapping:
RAX=0x0 is null
RBX=0x00007fc09825b2a0 points into unknown readable memory: 0x00007fc098239c40 | 40 9c 23 98 c0 7f 00 00
RCX=0x0000000000000006 is an unknown value
RDX=0x0000000028200000 is an unknown value
RSP=0x00007fc159522300 is pointing into the stack for thread: 0x00007fc17ca803b0
RBP=0x00007fc159522310 is pointing into the stack for thread: 0x00007fc17ca803b0
RSI=0x00007fc0998d3604 points into unknown readable memory: 00 00 00 00
RDI=0x00007fc09825b7a0 points into unknown readable memory: 0x00001c7c00000265 | 65 02 00 00 7c 1c 00 00
R8 =0x0000000000000006 is an unknown value
R9 =0x00000000aa959a6a is an unknown value
R10=0x0000000000000263 is an unknown value
R11=0x00007fc099bc36c0 points into unknown readable memory: 0x00007fc14e121570 | 70 15 12 4e c1 7f 00 00
R12=0x00007fc0998d35e0 points into unknown readable memory: 0x0000000000000000 | 00 00 00 00 00 00 00 00
R13=0x000000058bc5f100 is an unknown value
R14=0x000000058bc5f140 is an unknown value
R15=0x0000000000000040 is an unknown value
Top of Stack: (sp=0x00007fc159522300)
0x00007fc159522300: 00007fc09825b2a0 ffffffffffffffff
0x00007fc159522310: 00007fc1595223d0 00007fc14e74a849
0x00007fc159522320: 0000000000000000 00000000cc0016c8
0x00007fc159522330: 00007fc09920b000 00007fc100000004
0x00007fc159522340: 00007fc100000001 00007fc100000000
0x00007fc159522350: ffff800100000002 00007fc09825b7a0
0x00007fc159522360: 00007fc1595223e0 0000000100000b02
0x00007fc159522370: 0000000000000000 00007fc0983eca88
0x00007fc159522380: 00007fc100000000 00007fc099e33780
0x00007fc159522390: 00007fc159523170 b36c5690f9bb0900
0x00007fc1595223a0: 00007fc15951fd20 00007fc0983eca80
0x00007fc1595223b0: 00007fc09825b2a0 00007fc0983edb60
0x00007fc1595223c0: 00007fc098415b10 00007fc0983ec850
0x00007fc1595223d0: 00007fc159523280 00007fc14deccb71
0x00007fc1595223e0: 00000bdc00000000 00007fc100000000
0x00007fc1595223f0: 00007fc159523290 00007fc159523294
0x00007fc159522400: 00007fc159523320 00007fc159523324
0x00007fc159522410: 00007fc1595231b0 00007fc1595231b4
0x00007fc159522420: 00007fc159522860 00007fc164c8401c
0x00007fc159522430: 00007fc159523310 00007fc159523314
0x00007fc159522440: 00007fc1595232a0 00007fc1595232a4
0x00007fc159522450: 00007fc159522860 00007fc159523334
0x00007fc159522460: 00007fc159523400 00007fc159523404
0x00007fc159522470: 00007fc1595232d0 00007fc1595232d4
0x00007fc159522480: 00007fc16bc61f10 00007fc0c80123d0
0x00007fc159522490: 00007fc1595231f0 00007fc1595231f4
0x00007fc1595224a0: 00007fc1595223e0 00000000e31c914f
0x00007fc1595224b0: 00007fc159523350 00007fc159523354
0x00007fc1595224c0: 00007fc1595232e0 00007fc1595232e4
0x00007fc1595224d0: 00007f0000000000 00000000e3193478
0x00007fc1595224e0: 00007fc159523440 00007fc159523444
0x00007fc1595224f0: 00007fc159523310 00007fc159523314
Instructions: (pc=0x00007fc14e0eef41)
0x00007fc14e0eee41: 0f 1e fa 55 48 83 c6 24 48 89 e5 41 55 41 54 53
0x00007fc14e0eee51: 48 89 fb 48 83 ec 08 8b 97 00 05 00 00 44 0f b7
0x00007fc14e0eee61: 6e f0 48 8b 87 08 05 00 00 49 89 d4 45 01 ec 48
0x00007fc14e0eee71: 8d 3c 90 42 8d 14 ad 00 00 00 00 ff 15 ee 7e c3
0x00007fc14e0eee81: 01 44 89 a3 00 05 00 00 48 83 c4 08 5b 41 5c 41
0x00007fc14e0eee91: 5d 5d c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3
0x00007fc14e0eeea1: 0f 1e fa 55 48 89 e5 41 57 41 56 41 55 41 54 41
0x00007fc14e0eeeb1: 89 f4 53 48 89 fb 48 83 ec 08 4e 8b b4 e7 88 09
0x00007fc14e0eeec1: 00 00 8b 97 00 05 00 00 48 8b 87 08 05 00 00 45
0x00007fc14e0eeed1: 0f b7 7e 14 49 89 d5 49 8d 76 24 48 8d 3c 90 45
0x00007fc14e0eeee1: 01 fd 42 8d 14 bd 00 00 00 00 ff 15 7f 7e c3 01
0x00007fc14e0eeef1: 44 89 ab 00 05 00 00 4e 89 b4 e3 d8 09 00 00 48
0x00007fc14e0eef01: 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 90 f3
0x00007fc14e0eef11: 0f 1e fa 55 89 f0 48 89 e5 41 54 53 4c 8b a4 c7
0x00007fc14e0eef21: 88 09 00 00 48 89 fb e8 73 ff ff ff 49 8b 84 24
0x00007fc14e0eef31: 80 01 00 00 ba 00 00 20 28 48 8d bb 00 05 00 00
0x00007fc14e0eef41: 0f b6 88 c9 00 00 00 48 8b b0 b0 00 00 00 48 8b
0x00007fc14e0eef51: 83 f0 04 00 00 ff 90 00 01 00 00 49 8b 04 24 48
0x00007fc14e0eef61: 85 c0 74 13 48 89 df be ff ff ff ff 5b 41 5c 5d
0x00007fc14e0eef71: ff e0 0f 1f 44 00 00 5b 41 5c 5d c3 0f 1f 00 f3
0x00007fc14e0eef81: 0f 1e fa 66 0f ef c0 31 c9 ba 01 00 00 00 0f 11
0x00007fc14e0eef91: 87 d8 09 00 00 0f 11 87 e8 09 00 00 0f 11 87 f8
0x00007fc14e0eefa1: 09 00 00 0f 11 87 08 0a 00 00 0f 11 87 18 0a 00
0x00007fc14e0eefb1: 00 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48
0x00007fc14e0eefc1: 83 bc cf 88 09 00 00 00 74 0d 48 89 d0 48 d3 e0
0x00007fc14e0eefd1: 48 09 87 80 09 00 00 48 83 c1 01 48 83 f9 0a 75
0x00007fc14e0eefe1: de c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3
0x00007fc14e0eeff1: 0f 1e fa 55 48 89 e5 41 56 41 89 d6 41 55 41 89
0x00007fc14e0ef001: f5 8d 34 b5 28 00 00 00 41 54 49 89 fc bf 01 00
0x00007fc14e0ef011: 00 00 53 ff 15 7e 89 c3 01 48 89 c3 48 85 c0 74
0x00007fc14e0ef021: 2a 66 44 89 68 1a 41 0f b6 ce 48 8d 78 08 41 0f
0x00007fc14e0ef031: b6 94 24 97 08 00 00 49 8d b4 24 90 02 00 00 c0
Stack slot to memory mapping:
stack at sp + 0 slots: 0x00007fc09825b2a0 points into unknown readable memory: 0x00007fc098239c40 | 40 9c 23 98 c0 7f 00 00
stack at sp + 1 slots: 0xffffffffffffffff is an unknown value
stack at sp + 2 slots: 0x00007fc1595223d0 is pointing into the stack for thread: 0x00007fc17ca803b0
stack at sp + 3 slots: 0x00007fc14e74a849: <offset 0x0000000000f4a849> in /usr/lib/libgallium-24.2.8-arch1.1.so at 0x00007fc14d800000
stack at sp + 4 slots: 0x0 is null
stack at sp + 5 slots:

View File

@@ -45,8 +45,7 @@ public enum Asset {
tankShootTop("Models/tank/tankShoot_top.j3o", "Models/tank/tank_diff.png"), tankShootTop("Models/tank/tankShoot_top.j3o", "Models/tank/tank_diff.png"),
treesSmallBackground("Models/treeSmall/treesSmallBackground.j3o", "Models/treeSmall/treeSmall_diff.png", 1.2f), treesSmallBackground("Models/treeSmall/treesSmallBackground.j3o", "Models/treeSmall/treeSmall_diff.png", 1.2f),
treesBigBackground("Models/treeBig/treesBigBackground.j3o", "Models/treeBig/treeBig_diff.png", 1.2f), treesBigBackground("Models/treeBig/treesBigBackground.j3o", "Models/treeBig/treeBig_diff.png", 1.2f),
shell shell;
;
private final String modelPath; private final String modelPath;
private final String diffPath; private final String diffPath;
@@ -83,7 +82,8 @@ public enum Asset {
Asset(String modelPath) { Asset(String modelPath) {
String folderFileName = "./" + ROOT + name() + "/" + name(); String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = modelPath; this.modelPath = modelPath;
this.diffPath = folderFileName + "_diff.png";; this.diffPath = folderFileName + "_diff.png";
;
this.size = 1f; this.size = 1f;
} }
@@ -106,7 +106,7 @@ public enum Asset {
* @param diffPath Path to the diffuse texture file. * @param diffPath Path to the diffuse texture file.
* @param size Scaling factor for the asset. * @param size Scaling factor for the asset.
*/ */
Asset(String modelPath, String diffPath, float size){ Asset(String modelPath, String diffPath, float size) {
this.modelPath = modelPath; this.modelPath = modelPath;
this.diffPath = diffPath; this.diffPath = diffPath;
this.size = size; this.size = size;

View File

@@ -12,19 +12,13 @@
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl; import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;
import pp.mdga.client.board.NodeControl; import pp.mdga.client.board.NodeControl;
import pp.mdga.client.board.OutlineControl; import pp.mdga.client.board.OutlineControl;
import pp.mdga.client.board.PieceControl; import pp.mdga.client.board.PieceControl;
import pp.mdga.client.gui.CardControl; import pp.mdga.client.gui.CardControl;
import pp.mdga.client.gui.DiceControl; import pp.mdga.client.gui.DiceControl;
import pp.mdga.client.view.GameView; import pp.mdga.client.view.GameView;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import pp.mdga.notification.FinishNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -61,13 +55,13 @@ public class InputSynchronizer {
} }
public void update(float tpf) { public void update(float tpf) {
if(isRotateLeft && isRotateRight) { if (isRotateLeft && isRotateRight) {
return; return;
} }
if(isRotateLeft) { if (isRotateLeft) {
rotationAngle += 180 * tpf; rotationAngle += 180 * tpf;
} }
if(isRotateRight) { if (isRotateRight) {
rotationAngle -= 180 * tpf; rotationAngle -= 180 * tpf;
} }
} }
@@ -94,6 +88,7 @@ private void setupInput() {
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Left", "Right", "Test"); inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Left", "Right", "Test");
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown"); inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
} }
UUID p = null; UUID p = null;
/** /**
* Handles action-based input events such as key presses and mouse clicks. * Handles action-based input events such as key presses and mouse clicks.
@@ -110,8 +105,8 @@ public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("RotateRightMouse")) { if (name.equals("RotateRightMouse")) {
rightMousePressed = isPressed; rightMousePressed = isPressed;
} }
if(name.equals("Click") && isPressed) { if (name.equals("Click") && isPressed) {
if(!clickAllowed) { if (!clickAllowed) {
return; return;
} }
@@ -120,23 +115,20 @@ public void onAction(String name, boolean isPressed, float tpf) {
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class); CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class); OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
if(diceSelect != null) { if (diceSelect != null) {
app.getModelSynchronize().rolledDice(); app.getModelSynchronize().rolledDice();
} } else if (cardLayerSelect != null) {
else if(cardLayerSelect != null) {
//cardSelect //cardSelect
if(cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect); if (cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect);
} } else if (boardSelect != null) {
else if(boardSelect != null) {
//boardSelect //boardSelect
if(boardSelect instanceof PieceControl pieceControl){ if (boardSelect instanceof PieceControl pieceControl) {
if(pieceControl.isSelectable()) gameView.getBoardHandler().pieceSelect(pieceControl); if (pieceControl.isSelectable()) gameView.getBoardHandler().pieceSelect(pieceControl);
} }
if(boardSelect instanceof NodeControl nodeControl){ if (boardSelect instanceof NodeControl nodeControl) {
// //
} }
} } else {
else {
//both null //both null
} }
} }
@@ -149,14 +141,14 @@ else if(boardSelect != null) {
if (name.equals("Right")) { if (name.equals("Right")) {
isRotateRight = !isRotateRight; isRotateRight = !isRotateRight;
} }
if(name.equals("Test2") &&isPressed){ if (name.equals("Test2") && isPressed) {
if(app.getView() instanceof GameView gameView){ if (app.getView() instanceof GameView gameView) {
if(p == null) { if (p == null) {
p = UUID.randomUUID(); p = UUID.randomUUID();
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID())); gameView.getBoardHandler().addPlayer(Color.AIRFORCE, List.of(p, UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()));
gameView.getBoardHandler().movePieceStartAnim(p,0); gameView.getBoardHandler().movePieceStartAnim(p, 0);
gameView.getBoardHandler().outlineMove(List.of(p),List.of(2),List.of(false)); gameView.getBoardHandler().outlineMove(List.of(p), List.of(2), List.of(false));
//gameView.getBoardHandler().movePieceAnim(p,0, 8); //gameView.getBoardHandler().movePieceAnim(p,0, 8);
} else { } else {
gameView.getBoardHandler().throwPiece(p, Color.ARMY); gameView.getBoardHandler().throwPiece(p, Color.ARMY);
@@ -177,7 +169,6 @@ else if(boardSelect != null) {
//gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD); //gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD);
} }
} }
} }
@@ -191,17 +182,13 @@ else if(boardSelect != null) {
public void onAnalog(String name, float value, float tpf) { public void onAnalog(String name, float value, float tpf) {
if (name.equals("MouseLeft") && rightMousePressed) { if (name.equals("MouseLeft") && rightMousePressed) {
rotationAngle -= value * 360f; rotationAngle -= value * 360f;
} } else if (name.equals("MouseRight") && rightMousePressed) {
else if (name.equals("MouseRight") && rightMousePressed) {
rotationAngle += value * 360f; rotationAngle += value * 360f;
} } else if (name.equals("MouseScrollUp")) {
else if (name.equals("MouseScrollUp")) {
scrollValue = Math.max(1, scrollValue - 5); scrollValue = Math.max(1, scrollValue - 5);
} } else if (name.equals("MouseScrollDown")) {
else if (name.equals("MouseScrollDown")) {
scrollValue = Math.min(100, scrollValue + 5); scrollValue = Math.min(100, scrollValue + 5);
} } else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("MouseVertical")) {
else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("MouseVertical")){
hoverPiece(); hoverPiece();
hoverCard(); hoverCard();
} }
@@ -212,12 +199,13 @@ else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("M
* Detects the hovered piece and updates its hover state. * Detects the hovered piece and updates its hover state.
*/ */
private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T> controlType) { private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T> controlType) {
if(cam == null || root == null || controlType == null) return null; if (cam == null || root == null || controlType == null) return null;
CollisionResults results = new CollisionResults(); CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize()); Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize());
root.collideWith(ray, results); root.collideWith(ray, results);
for(CollisionResult collisionResult : results){ for (CollisionResult collisionResult : results) {
if(collisionResult.getGeometry().getControl(controlType) != null) return collisionResult.getGeometry().getControl(controlType); if (collisionResult.getGeometry().getControl(controlType) != null)
return collisionResult.getGeometry().getControl(controlType);
} }
return null; return null;
} }
@@ -226,16 +214,16 @@ private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T>
* Detects the hovered card and updates its hover state. * Detects the hovered card and updates its hover state.
*/ */
private <T extends AbstractControl> T checkHoverOrtho(Camera cam, Node root, Class<T> controlType) { private <T extends AbstractControl> T checkHoverOrtho(Camera cam, Node root, Class<T> controlType) {
if(cam == null || root == null || controlType == null) return null; if (cam == null || root == null || controlType == null) return null;
CollisionResults results = new CollisionResults(); CollisionResults results = new CollisionResults();
Vector3f mousePos = getMousePos(cam); Vector3f mousePos = getMousePos(cam);
mousePos.setZ(cam.getLocation().getZ()); mousePos.setZ(cam.getLocation().getZ());
Ray ray = new Ray(mousePos, getMousePos(cam).subtract(mousePos).normalize()); Ray ray = new Ray(mousePos, getMousePos(cam).subtract(mousePos).normalize());
root.collideWith(ray, results); root.collideWith(ray, results);
if (results.size() > 0) { if (results.size() > 0) {
for(CollisionResult res : results ){ for (CollisionResult res : results) {
T control = res.getGeometry().getControl(controlType); T control = res.getGeometry().getControl(controlType);
if(control != null) return control; if (control != null) return control;
} }
} }
return null; return null;
@@ -344,7 +332,7 @@ public float getRotation() {
return (rotationAngle / 2) % 360; return (rotationAngle / 2) % 360;
} }
public void setRotation(float rotationAngle){ public void setRotation(float rotationAngle) {
this.rotationAngle = rotationAngle; this.rotationAngle = rotationAngle;
} }

View File

@@ -1,20 +1,14 @@
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.animation.TimerManager; import pp.mdga.client.animation.TimerManager;
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.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
@@ -27,40 +21,64 @@ public class MdgaApp extends SimpleApplication {
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class); private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
/** Handles acoustic effects and state-based sounds. */ /**
* Handles acoustic effects and state-based sounds.
*/
private AcousticHandler acousticHandler; private AcousticHandler acousticHandler;
/** Synchronizes notifications throughout the application. */ /**
* Synchronizes notifications throughout the application.
*/
private NotificationSynchronizer notificationSynchronizer; private NotificationSynchronizer notificationSynchronizer;
/** Manages input events and synchronization. */ /**
* Manages input events and synchronization.
*/
private InputSynchronizer inputSynchronizer; private InputSynchronizer inputSynchronizer;
/** Synchronizes game models. */ /**
* Synchronizes game models.
*/
private ModelSynchronizer modelSynchronizer; private ModelSynchronizer modelSynchronizer;
/** The currently active view in the application. */ /**
* The currently active view in the application.
*/
private MdgaView view = null; private MdgaView view = null;
/** The current state of the application. */ /**
* The current state of the application.
*/
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 final float imageScale = prefs.getInt("scale", 1);
/** The main menu view. */ /**
* The main menu view.
*/
private MainView mainView; private MainView mainView;
/** The lobby view. */ /**
* The lobby view.
*/
private LobbyView lobbyView; private LobbyView lobbyView;
/** The game view. */ /**
* The game view.
*/
private GameView gameView; private GameView gameView;
/** The ceremony view. */ /**
* The ceremony view.
*/
private CeremonyView ceremonyView; private CeremonyView ceremonyView;
/** The client game logic. */ /**
* The client game logic.
*/
private final ClientGameLogic clientGameLogic; private final ClientGameLogic clientGameLogic;
private ExecutorService executor; private ExecutorService executor;
@@ -87,7 +105,7 @@ public static void main(String[] args) {
AppSettings settings = new AppSettings(true); AppSettings settings = new AppSettings(true);
settings.setSamples(128); settings.setSamples(128);
if(prefs.getBoolean("fullscreen", false)) { if (prefs.getBoolean("fullscreen", false)) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = (int) screenSize.getWidth(); int screenWidth = (int) screenSize.getWidth();
int screenHeight = (int) screenSize.getHeight(); int screenHeight = (int) screenSize.getHeight();
@@ -270,12 +288,12 @@ public ExecutorService getExecutor() {
return this.executor; return this.executor;
} }
public ServerConnection getNetworkSupport(){ 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, boolean isFullscreen) {
if(isFullscreen) { if (isFullscreen) {
int baseWidth = 1280; int baseWidth = 1280;
int baseHeight = 720; int baseHeight = 720;
float baseAspectRatio = (float) baseWidth / baseHeight; float baseAspectRatio = (float) baseWidth / baseHeight;
@@ -326,7 +344,7 @@ public void afterGameCleanup() {
ceremonyView.afterGameCleanup(); ceremonyView.afterGameCleanup();
} }
public GameView getGameView(){ public GameView getGameView() {
return gameView; return gameView;
} }

View File

@@ -23,15 +23,15 @@ public class ModelSynchronizer {
} }
public void animationEnd() { public void animationEnd() {
if(app.getNotificationSynchronizer().waitForAnimation) { if (app.getNotificationSynchronizer().waitForAnimation) {
app.getNotificationSynchronizer().waitForAnimation = false; app.getNotificationSynchronizer().waitForAnimation = false;
} else { } else {
app.getGameLogic().selectAnimationEnd(); app.getGameLogic().selectAnimationEnd();
} }
} }
public void select(UUID a, UUID b){ public void select(UUID a, UUID b) {
if(swap) selectSwap(a,b); if (swap) selectSwap(a, b);
else selectPiece(a); else selectPiece(a);
} }
@@ -42,7 +42,7 @@ public void selectSwap(UUID a, UUID b) {
this.b = b; this.b = b;
GameView gameView = (GameView) app.getView(); GameView gameView = (GameView) app.getView();
if(a != null && b != null) { if (a != null && b != null) {
gameView.needConfirm(); gameView.needConfirm();
} else { } else {
gameView.noConfirm(); gameView.noConfirm();
@@ -56,7 +56,7 @@ public void selectPiece(UUID piece) {
this.a = piece; this.a = piece;
GameView gameView = (GameView) app.getView(); GameView gameView = (GameView) app.getView();
if(piece != null) { if (piece != null) {
gameView.needConfirm(); gameView.needConfirm();
} else { } else {
gameView.noConfirm(); gameView.noConfirm();
@@ -71,7 +71,7 @@ public void selectCard(BonusCard card) {
GameView gameView = (GameView) app.getView(); GameView gameView = (GameView) app.getView();
if(card != null) { if (card != null) {
gameView.needConfirm(); gameView.needConfirm();
} else { } else {
gameView.showNoPower(); gameView.showNoPower();
@@ -85,7 +85,7 @@ public void confirm() {
gameView.getGuiHandler().hideText(); gameView.getGuiHandler().hideText();
if(a != null && b != null) { if (a != null && b != null) {
app.getGameLogic().selectPiece(a); app.getGameLogic().selectPiece(a);
app.getGameLogic().selectPiece(b); app.getGameLogic().selectPiece(b);
gameView.getBoardHandler().clearSelectable(); gameView.getBoardHandler().clearSelectable();
@@ -144,7 +144,7 @@ public void enter(MdgaState state) {
//app.enter(state); //app.enter(state);
} }
public void setSwap(boolean swap){ public void setSwap(boolean swap) {
this.swap = swap; this.swap = swap;
} }

View File

@@ -33,13 +33,13 @@ public class NotificationSynchronizer {
public void update() { public void update() {
while (timer.getTimeInSeconds() >= delay) { while (timer.getTimeInSeconds() >= delay) {
if(waitForAnimation) { if (waitForAnimation) {
return; return;
} }
Notification n = app.getGameLogic().getNotification(); Notification n = app.getGameLogic().getNotification();
if(n == null) { if (n == null) {
return; return;
} }
@@ -48,12 +48,12 @@ public void update() {
timer.reset(); timer.reset();
delay = 0; delay = 0;
if(n instanceof InfoNotification infoNotification) { if (n instanceof InfoNotification infoNotification) {
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError()); app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
return; return;
} }
if(n != null) { if (n != null) {
switch (app.getState()) { switch (app.getState()) {
case MAIN: case MAIN:
handleMain(n); handleMain(n);
@@ -71,7 +71,7 @@ public void update() {
throw new RuntimeException("no notification expected: " + n.getClass().getName()); throw new RuntimeException("no notification expected: " + n.getClass().getName());
} }
if(0 == MdgaApp.DEBUG_MULTIPLIER) { if (0 == MdgaApp.DEBUG_MULTIPLIER) {
delay = 0; delay = 0;
} }
} }
@@ -84,7 +84,7 @@ private void handleMain(Notification notification) {
} else if (notification instanceof StartDialogNotification) { } else if (notification instanceof StartDialogNotification) {
//nothing //nothing
} else { } else {
throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName()); throw new RuntimeException("notification not expected in main: " + notification.getClass().getName());
} }
} }
@@ -98,7 +98,7 @@ private void handleLobby(Notification notification) {
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.getGameView().setOwnColor(n.getOwnColor());
@@ -119,7 +119,7 @@ private void handleGame(Notification notification) {
guiHandler.addCardOwn(n.getBonusCard()); guiHandler.addCardOwn(n.getBonusCard());
app.getAcousticHandler().playSound(MdgaSound.BONUS); app.getAcousticHandler().playSound(MdgaSound.BONUS);
delay = STANDARD_DELAY; delay = STANDARD_DELAY;
} else if(notification instanceof RankingResponceNotification n) { } else if (notification instanceof RankingResponceNotification n) {
guiHandler.hideText(); guiHandler.hideText();
n.getRankingResults().forEach((c, i) -> { n.getRankingResults().forEach((c, i) -> {
guiHandler.rollRankingResult(c, i); guiHandler.rollRankingResult(c, i);
@@ -129,7 +129,7 @@ private void handleGame(Notification notification) {
guiHandler.hideText(); guiHandler.hideText();
boardHandler.hideDice(); boardHandler.hideDice();
gameView.getGuiHandler().setActivePlayer(n.getColor()); gameView.getGuiHandler().setActivePlayer(n.getColor());
if(n.getColor() != ownColor) boardHandler.showDice(n.getColor()); if (n.getColor() != ownColor) boardHandler.showDice(n.getColor());
app.getAcousticHandler().playSound(MdgaSound.UI90); app.getAcousticHandler().playSound(MdgaSound.UI90);
delay = STANDARD_DELAY; delay = STANDARD_DELAY;
} else if (notification instanceof CeremonyNotification ceremonyNotification) { } else if (notification instanceof CeremonyNotification ceremonyNotification) {
@@ -173,12 +173,11 @@ private void handleGame(Notification notification) {
} else if (notification instanceof InterruptNotification notification1) { } else if (notification instanceof InterruptNotification notification1) {
gameView.enterInterrupt(notification1.getColor()); gameView.enterInterrupt(notification1.getColor());
} else if (notification instanceof MovePieceNotification n) { } else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) { if (n.isMoveStart()) {
//StartMove //StartMove
boardHandler.movePieceStartAnim(n.getPiece(), n.getMoveIndex()); boardHandler.movePieceStartAnim(n.getPiece(), n.getMoveIndex());
waitForAnimation = true; waitForAnimation = true;
} } else {
else {
//InfieldMove //InfieldMove
boardHandler.movePieceAnim(n.getPiece(), n.getStartIndex(), n.getMoveIndex()); boardHandler.movePieceAnim(n.getPiece(), n.getStartIndex(), n.getMoveIndex());
waitForAnimation = true; waitForAnimation = true;
@@ -190,15 +189,15 @@ private void handleGame(Notification notification) {
} else if (notification instanceof RemoveShieldNotification n) { } else if (notification instanceof RemoveShieldNotification n) {
boardHandler.unshieldPiece(n.getPieceUuid()); boardHandler.unshieldPiece(n.getPieceUuid());
} else if (notification instanceof PlayCardNotification n) { } else if (notification instanceof PlayCardNotification n) {
if(n.getCard() == BonusCard.TURBO) { if (n.getCard() == BonusCard.TURBO) {
app.getAcousticHandler().playSound(MdgaSound.TURBO); app.getAcousticHandler().playSound(MdgaSound.TURBO);
guiHandler.turbo(); guiHandler.turbo();
} else if(n.getCard() == BonusCard.SHIELD) { } else if (n.getCard() == BonusCard.SHIELD) {
app.getAcousticHandler().playSound(MdgaSound.SHIELD); app.getAcousticHandler().playSound(MdgaSound.SHIELD);
} else if(n.getCard() == BonusCard.SWAP) { } else if (n.getCard() == BonusCard.SWAP) {
app.getAcousticHandler().playSound(MdgaSound.SWAP); app.getAcousticHandler().playSound(MdgaSound.SWAP);
} }
if(n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard()); if (n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard());
else guiHandler.playCardEnemy(n.getColor(), n.getCard()); else guiHandler.playCardEnemy(n.getColor(), n.getCard());
new Timer().schedule(new TimerTask() { new Timer().schedule(new TimerTask() {
@@ -208,17 +207,16 @@ public void run() {
} }
}, 2200 * MdgaApp.DEBUG_MULTIPLIER); }, 2200 * MdgaApp.DEBUG_MULTIPLIER);
} 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(); gameView.leaveInterrupt();
} else if (notification instanceof RollDiceNotification n) { } else if (notification instanceof RollDiceNotification n) {
gameView.getGuiHandler().hideText(); gameView.getGuiHandler().hideText();
if(n.getColor() == ownColor){ if (n.getColor() == ownColor) {
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1); guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
waitForAnimation = true; waitForAnimation = true;
} } else {
else {
if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor()); if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
else guiHandler.showRolledDice(n.getEyes(), n.getColor()); else guiHandler.showRolledDice(n.getEyes(), n.getColor());
} }
@@ -246,9 +244,9 @@ public void run() {
} else if (notification instanceof SelectableShieldNotification n) { } else if (notification instanceof SelectableShieldNotification n) {
boardHandler.outlineShield(n.getPieces()); boardHandler.outlineShield(n.getPieces());
modelSynchronizer.setSwap(false); modelSynchronizer.setSwap(false);
} else if (notification instanceof TurboActiveNotification){ } else if (notification instanceof TurboActiveNotification) {
//nothing //nothing
} 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 in game: " + notification.getClass().getName());

View File

@@ -3,7 +3,8 @@
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
public class Util { public class Util {
private Util(){} private Util() {
}
/** /**
* Performs linear interpolation between two values. * Performs linear interpolation between two values.
@@ -41,7 +42,7 @@ public static Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
* @param x The interpolation parameter (0 <= x <= 1). * @param x The interpolation parameter (0 <= x <= 1).
* @return The adjusted interpolation value. * @return The adjusted interpolation value.
*/ */
public static float easeInOut(float x){ public static float easeInOut(float x) {
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2); return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
} }
} }

View File

@@ -4,7 +4,10 @@
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.MdgaState; import pp.mdga.client.MdgaState;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Random;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
public class AcousticHandler { public class AcousticHandler {
@@ -226,11 +229,11 @@ private float lerp(float start, float end, float t) {
/** /**
* Updates the state of audio playback, handling track transitions and volume adjustments. * Updates the state of audio playback, handling track transitions and volume adjustments.
* * <p>
* This method ensures smooth transitions between tracks using fade-in and fade-out effects. * This method ensures smooth transitions between tracks using fade-in and fade-out effects.
* It also handles cases where no track is playing, starting a scheduled track immediately at full volume. * It also handles cases where no track is playing, starting a scheduled track immediately at full volume.
* The method prioritizes the latest scheduled track if multiple scheduling occurs quickly. * The method prioritizes the latest scheduled track if multiple scheduling occurs quickly.
* * <p>
* Behavior: * Behavior:
* 1. If nothing is scheduled and no track is playing, it exits early. * 1. If nothing is scheduled and no track is playing, it exits early.
* 2. If a scheduled track exists and no track is playing, the scheduled track starts immediately at full volume. * 2. If a scheduled track exists and no track is playing, the scheduled track starts immediately at full volume.
@@ -239,7 +242,7 @@ private float lerp(float start, float end, float t) {
* 4. If a track transition is in progress (fading), it processes the fade-out and fade-in states. * 4. If a track transition is in progress (fading), it processes the fade-out and fade-in states.
* If a new track is scheduled during this process, it interrupts the current transition and prioritizes the new track. * If a new track is scheduled during this process, it interrupts the current transition and prioritizes the new track.
* 5. If no fading is needed and a track is playing, it ensures the track's volume is updated. * 5. If no fading is needed and a track is playing, it ensures the track's volume is updated.
* * <p>
* Special cases: * Special cases:
* - If no track is playing and a new track is scheduled, it starts the track immediately without fading. * - If no track is playing and a new track is scheduled, it starts the track immediately without fading.
* - If a new track is scheduled during fading, it resets the transition to prioritize the new track. * - If a new track is scheduled during fading, it resets the transition to prioritize the new track.
@@ -291,23 +294,23 @@ private void updateVolumeAndTrack() {
/** /**
* Manages the fading process during audio track transitions. * Manages the fading process during audio track transitions.
* * <p>
* This method handles the fade-out of the currently playing (old) track, manages any pause between the fade-out * This method handles the fade-out of the currently playing (old) track, manages any pause between the fade-out
* and fade-in, and initiates the fade-in for the new track if applicable. It ensures smooth transitions between * and fade-in, and initiates the fade-in for the new track if applicable. It ensures smooth transitions between
* tracks while maintaining the correct volume adjustments. * tracks while maintaining the correct volume adjustments.
* * <p>
* Behavior: * Behavior:
* 1. **Outfade:** Gradually decreases the volume of the `old` track over the duration of `FADE_DURATION`. * 1. **Outfade:** Gradually decreases the volume of the `old` track over the duration of `FADE_DURATION`.
* Once the outfade completes, the `old` track is paused and cleared. * Once the outfade completes, the `old` track is paused and cleared.
* 2. **Pause Handling:** Waits for a defined pause (if applicable) before initiating the infade for the next track. * 2. **Pause Handling:** Waits for a defined pause (if applicable) before initiating the infade for the next track.
* 3. **Infade:** If a `scheduled` track exists and the outfade and pause are complete, it begins playing * 3. **Infade:** If a `scheduled` track exists and the outfade and pause are complete, it begins playing
* the new track (`playing`) and initiates the infade process. * the new track (`playing`) and initiates the infade process.
* * <p>
* Key Details: * Key Details:
* - The outfade volume adjustment is interpolated linearly from full volume to zero using the `lerp` function. * - The outfade volume adjustment is interpolated linearly from full volume to zero using the `lerp` function.
* - The pause duration is retrieved from the scheduled track if it is specified. * - The pause duration is retrieved from the scheduled track if it is specified.
* - If a new track is scheduled during the fade process, it is handled by external logic to prioritize transitions. * - If a new track is scheduled during the fade process, it is handled by external logic to prioritize transitions.
* * <p>
* Preconditions: * Preconditions:
* - `fading` is expected to be `true` when this method is called. * - `fading` is expected to be `true` when this method is called.
* - The method is invoked as part of the `updateVolumeAndTrack` process. * - The method is invoked as part of the `updateVolumeAndTrack` process.
@@ -343,10 +346,10 @@ private void handleFadeProcess() {
/** /**
* Manages the fade-in process for the currently playing track. * Manages the fade-in process for the currently playing track.
* * <p>
* This method gradually increases the volume of the `playing` track from zero to full volume * This method gradually increases the volume of the `playing` track from zero to full volume
* over the duration of `CROSSFADE_DURATION`. It ensures a smooth transition into the new track. * over the duration of `CROSSFADE_DURATION`. It ensures a smooth transition into the new track.
* * <p>
* Behavior: * Behavior:
* 1. If no track is set as `playing`, the method exits early, as there is nothing to fade in. * 1. If no track is set as `playing`, the method exits early, as there is nothing to fade in.
* 2. Linearly interpolates the volume of the `playing` track from 0.0 to 1.0 based on the elapsed * 2. Linearly interpolates the volume of the `playing` track from 0.0 to 1.0 based on the elapsed
@@ -354,12 +357,12 @@ private void handleFadeProcess() {
* 3. Once the fade-in is complete (when `infadeTime` exceeds `CROSSFADE_DURATION`), the method: * 3. Once the fade-in is complete (when `infadeTime` exceeds `CROSSFADE_DURATION`), the method:
* - Marks the fade process (`fading`) as complete. * - Marks the fade process (`fading`) as complete.
* - Ensures the `playing` track is updated to its full volume. * - Ensures the `playing` track is updated to its full volume.
* * <p>
* Key Details: * Key Details:
* - Uses the `lerp` function to calculate the volume level for the `playing` track during the fade-in. * - Uses the `lerp` function to calculate the volume level for the `playing` track during the fade-in.
* - Ensures the volume is always a value between 0.0 and 1.0. * - Ensures the volume is always a value between 0.0 and 1.0.
* - The `infadeTime` parameter should be relative to the start of the fade-in process. * - The `infadeTime` parameter should be relative to the start of the fade-in process.
* * <p>
* Preconditions: * Preconditions:
* - The `playing` track must be initialized and actively fading in for this method to have an effect. * - The `playing` track must be initialized and actively fading in for this method to have an effect.
* - The method is invoked as part of the `updateVolumeAndTrack` process. * - The method is invoked as part of the `updateVolumeAndTrack` process.
@@ -402,7 +405,7 @@ private void addGameTracks() {
* a new track will be scheduled to play. If the list of game tracks is empty, it will be refreshed. * a new track will be scheduled to play. If the list of game tracks is empty, it will be refreshed.
*/ */
private void updateGameTracks() { private void updateGameTracks() {
if(null == playing) { if (null == playing) {
return; return;
} }

View File

@@ -4,4 +4,5 @@
* A record that encapsulates a sound asset along with its playback settings: * A record that encapsulates a sound asset along with its playback settings:
* the relative volume (subVolume) and a delay before it starts playing. * the relative volume (subVolume) and a delay before it starts playing.
*/ */
record SoundAssetDelayVolume(SoundAsset asset, float subVolume, float delay) {} record SoundAssetDelayVolume(SoundAsset asset, float subVolume, float delay) {
}

View File

@@ -5,14 +5,12 @@
public class ActionControl extends InitControl { public class ActionControl extends InitControl {
private final Runnable runnable; private final Runnable runnable;
public ActionControl(Runnable runnable){ public ActionControl(Runnable runnable) {
this.runnable = runnable; this.runnable = runnable;
} }
protected void action() {
if (null != runnable) {
protected void action(){
if(null != runnable) {
runnable.run(); runnable.run();
} }
} }

View File

@@ -47,13 +47,13 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
* Configures the fire and smoke emitters with appearance, behavior, and lifespan. * Configures the fire and smoke emitters with appearance, behavior, and lifespan.
*/ */
private void initializeEmitter() { private void initializeEmitter() {
fire = new ParticleEmitter("Effect", Type.Triangle,50); fire = new ParticleEmitter("Effect", Type.Triangle, 50);
fire.setMaterial(mat); fire.setMaterial(mat);
fire.setImagesX(2); fire.setImagesX(2);
fire.setImagesY(2); fire.setImagesY(2);
fire.setStartColor(ColorRGBA.Yellow); fire.setStartColor(ColorRGBA.Yellow);
fire.setEndColor(ColorRGBA.Red); fire.setEndColor(ColorRGBA.Red);
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f)); fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f, 0.2f, 4f));
fire.getParticleInfluencer().setVelocityVariation(0.4f); fire.getParticleInfluencer().setVelocityVariation(0.4f);
fire.setStartSize(0.7f); fire.setStartSize(0.7f);
fire.setEndSize(1.8f); fire.setEndSize(1.8f);
@@ -64,13 +64,13 @@ private void initializeEmitter() {
fire.setLocalTranslation(location); fire.setLocalTranslation(location);
smoke = new ParticleEmitter("Effect2", Type.Triangle,40); smoke = new ParticleEmitter("Effect2", Type.Triangle, 40);
smoke.setMaterial(mat); smoke.setMaterial(mat);
smoke.setImagesX(3); smoke.setImagesX(3);
smoke.setImagesY(3); smoke.setImagesY(3);
smoke.setStartColor(ColorRGBA.DarkGray); smoke.setStartColor(ColorRGBA.DarkGray);
smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1)); smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.7f)); smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 0.7f));
smoke.getParticleInfluencer().setVelocityVariation(0.5f); smoke.getParticleInfluencer().setVelocityVariation(0.5f);
smoke.setStartSize(0.8f); smoke.setStartSize(0.8f);
smoke.setEndSize(1.5f); smoke.setEndSize(1.5f);
@@ -109,7 +109,8 @@ protected void controlUpdate(float tpf) {
} }
@Override @Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {} protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
}); });
rootNode.attachChild(smoke); rootNode.attachChild(smoke);
@@ -127,7 +128,8 @@ protected void controlUpdate(float tpf) {
} }
@Override @Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {} protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
}); });
} }
} }

View File

@@ -1,10 +1,9 @@
package pp.mdga.client.animation; package pp.mdga.client.animation;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import pp.mdga.client.InitControl; import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import static pp.mdga.client.Util.linInt; import static pp.mdga.client.Util.linInt;

View File

@@ -12,10 +12,6 @@
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.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.view.GameView;
import java.util.UUID;
/** /**
* The {@code JetAnimation} class handles the animation of a jet model in a 3D environment. * The {@code JetAnimation} class handles the animation of a jet model in a 3D environment.
@@ -88,7 +84,8 @@ private void spawnJet() {
rootNode.attachChild(jetModel); rootNode.attachChild(jetModel);
} }
/**actionAfter /**
* actionAfter
* Animates the jet along a Bezier curve path, triggers the explosion effect at the appropriate time, * Animates the jet along a Bezier curve path, triggers the explosion effect at the appropriate time,
* and performs cleanup operations after the animation completes. * and performs cleanup operations after the animation completes.
*/ */
@@ -106,7 +103,7 @@ protected void controlUpdate(float tpf) {
elapsedTime += tpf; elapsedTime += tpf;
float progress = elapsedTime / animationDuration; float progress = elapsedTime / animationDuration;
if(elapsedTime > 4.2f) { if (elapsedTime > 4.2f) {
explosion.trigger(); explosion.trigger();
} }
@@ -127,11 +124,12 @@ protected void controlUpdate(float tpf) {
} }
@Override @Override
protected void controlRender(RenderManager rm, ViewPort vp) {} protected void controlRender(RenderManager rm, ViewPort vp) {
}
}); });
} }
private void endAnim(){ private void endAnim() {
actionAfter.run(); actionAfter.run();
} }

View File

@@ -6,11 +6,11 @@
import com.jme3.material.RenderState; import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import pp.mdga.client.InitControl;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import java.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class MatrixAnimation extends ActionControl { public class MatrixAnimation extends ActionControl {
private MdgaApp app; private MdgaApp app;
@@ -23,7 +23,7 @@ public class MatrixAnimation extends ActionControl {
private float timeElapsed = 0f; private float timeElapsed = 0f;
private enum MatrixState{ private enum MatrixState {
RADAR_ON, RADAR_ON,
RADAR_OFF, RADAR_OFF,
MATRIX_ON, MATRIX_ON,
@@ -32,7 +32,7 @@ private enum MatrixState{
private MatrixState state; private MatrixState state;
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable){ public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable) {
super(runnable); super(runnable);
this.app = app; this.app = app;
this.radarPos = radarPos; this.radarPos = radarPos;
@@ -48,15 +48,14 @@ protected void initSpatial() {
@Override @Override
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
if(!init) return; if (!init) return;
timeElapsed += tpf; timeElapsed += tpf;
switch (state) {
switch(state){
case RADAR_ON -> { case RADAR_ON -> {
if(timeElapsed >= 2f){ if (timeElapsed >= 2f) {
state = MatrixState.RADAR_OFF; state = MatrixState.RADAR_OFF;
timeElapsed = 0; timeElapsed = 0;
radarEmitter.setParticlesPerSec(0); radarEmitter.setParticlesPerSec(0);
@@ -68,7 +67,7 @@ protected void controlUpdate(float tpf) {
} }
} }
case RADAR_OFF -> { case RADAR_OFF -> {
if(timeElapsed >= 0.1f){ if (timeElapsed >= 0.1f) {
state = MatrixState.MATRIX_ON; state = MatrixState.MATRIX_ON;
timeElapsed = 0; timeElapsed = 0;
matrix(); matrix();
@@ -76,12 +75,12 @@ protected void controlUpdate(float tpf) {
} }
case MATRIX_ON -> { case MATRIX_ON -> {
if(timeElapsed >= 3f){ if (timeElapsed >= 3f) {
state = MatrixState.MATRIX_OFF; state = MatrixState.MATRIX_OFF;
timeElapsed = 0; timeElapsed = 0;
turnOff(); turnOff();
app.getTimerManager().addTask(3f, () -> app.enqueue(() -> { app.getTimerManager().addTask(3f, () -> app.enqueue(() -> {
for (ParticleEmitter particleEmitter : activeEmitter){ for (ParticleEmitter particleEmitter : activeEmitter) {
app.getRootNode().detachChild(particleEmitter); app.getRootNode().detachChild(particleEmitter);
} }
System.out.println("delete particle"); System.out.println("delete particle");
@@ -90,7 +89,7 @@ protected void controlUpdate(float tpf) {
} }
} }
case MATRIX_OFF -> { case MATRIX_OFF -> {
if(timeElapsed >= 0.5f){ if (timeElapsed >= 0.5f) {
init = false; init = false;
spatial.removeControl(this); spatial.removeControl(this);
action(); action();
@@ -99,13 +98,13 @@ protected void controlUpdate(float tpf) {
} }
} }
private void turnOff(){ private void turnOff() {
for (ParticleEmitter particleEmitter : activeEmitter){ for (ParticleEmitter particleEmitter : activeEmitter) {
particleEmitter.setParticlesPerSec(0f); particleEmitter.setParticlesPerSec(0f);
} }
} }
private void radar(){ private void radar() {
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/radar_beam.png")); mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/radar_beam.png"));
ParticleEmitter emitter = new ParticleEmitter("Effect", Type.Triangle, 50); ParticleEmitter emitter = new ParticleEmitter("Effect", Type.Triangle, 50);
@@ -123,26 +122,26 @@ private void radar(){
float life = 2.6f; float life = 2.6f;
emitter.setLowLife(life); emitter.setLowLife(life);
emitter.setHighLife(life); emitter.setHighLife(life);
emitter.setLocalTranslation(radarPos.add(new Vector3f(0,0,5))); emitter.setLocalTranslation(radarPos.add(new Vector3f(0, 0, 5)));
emitter.setParticlesPerSec(1.8f); emitter.setParticlesPerSec(1.8f);
app.getRootNode().attachChild(emitter); app.getRootNode().attachChild(emitter);
radarEmitter = emitter; radarEmitter = emitter;
} }
private void matrix(){ private void matrix() {
for(int i = 0; i < 5; i++){ for (int i = 0; i < 5; i++) {
particleStream( particleStream(
generateMatrixColor(), generateMatrixColor(),
generateMatrixColor(), generateMatrixColor(),
getRandomFloat(0,1f), getRandomFloat(0, 1f),
getRandomPosition(), getRandomPosition(),
getRandomFloat(1,2) getRandomFloat(1, 2)
); );
} }
} }
private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vector3f pos, float spawnVar){ private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vector3f pos, float spawnVar) {
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/particle_cir.png")); mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/particle_cir.png"));
@@ -160,7 +159,7 @@ private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vect
matrix.setGravity(0, 0, 2f); matrix.setGravity(0, 0, 2f);
matrix.setLowLife(3f); matrix.setLowLife(3f);
matrix.setHighLife(3f); matrix.setHighLife(3f);
matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0,0,15))); matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0, 0, 15)));
matrix.setParticlesPerSec(spawnVar); matrix.setParticlesPerSec(spawnVar);
app.getRootNode().attachChild(matrix); app.getRootNode().attachChild(matrix);
activeEmitter.add(matrix); activeEmitter.add(matrix);
@@ -178,7 +177,7 @@ public static Vector3f getRandomPosition() {
float x = radius * (float) Math.cos(angle); float x = radius * (float) Math.cos(angle);
float y = radius * (float) Math.sin(angle); float y = radius * (float) Math.sin(angle);
return new Vector3f(x,y,0); return new Vector3f(x, y, 0);
} }
public static float getRandomFloat(float start, float end) { public static float getRandomFloat(float start, float end) {

View File

@@ -17,8 +17,6 @@
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 java.util.UUID;
/** /**
* The {@code MissileAnimation} class handles the animation of a missile moving along a parabolic path * The {@code MissileAnimation} class handles the animation of a missile moving along a parabolic path
* towards a target point in a 3D environment. It also triggers an explosion at the target upon impact. * towards a target point in a 3D environment. It also triggers an explosion at the target upon impact.
@@ -64,13 +62,13 @@ public MissileAnimation(MdgaApp app, Node rootNode, Vector3f target, float fligh
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/vapor_cloud.png")); mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/vapor_cloud.png"));
smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,400); smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle, 400);
smoke.setMaterial(mat); smoke.setMaterial(mat);
smoke.setImagesX(3); smoke.setImagesX(3);
smoke.setImagesY(3); smoke.setImagesY(3);
smoke.setStartColor(ColorRGBA.DarkGray); smoke.setStartColor(ColorRGBA.DarkGray);
smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1)); smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.0f)); smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 0.0f));
smoke.getParticleInfluencer().setVelocityVariation(0.1f); smoke.getParticleInfluencer().setVelocityVariation(0.1f);
smoke.setStartSize(0.8f); smoke.setStartSize(0.8f);
smoke.setEndSize(1.5f); smoke.setEndSize(1.5f);
@@ -120,7 +118,7 @@ private void animateMissile() {
@Override @Override
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
if(elapsedTime > 6) { if (elapsedTime > 6) {
endAnim(); endAnim();
rootNode.detachChild(missileNode); rootNode.detachChild(missileNode);
this.spatial.removeControl(this); this.spatial.removeControl(this);
@@ -162,7 +160,7 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
}); });
} }
private void endAnim(){ private void endAnim() {
actionAfter.run(); actionAfter.run();
} }

View File

@@ -2,7 +2,8 @@
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import static pp.mdga.client.Util.*; import static pp.mdga.client.Util.easeInOut;
import static pp.mdga.client.Util.quadInt;
/** /**
* A control that smoothly moves a spatial from an initial position to an end position * A control that smoothly moves a spatial from an initial position to an end position
@@ -32,11 +33,11 @@ public class MoveControl extends ActionControl {
* @param endPos The target position of the spatial. * @param endPos The target position of the spatial.
* @param actionAfter A Runnable that will be executed after the movement finishes. * @param actionAfter A Runnable that will be executed after the movement finishes.
*/ */
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter) {
this(initPos, endPos, actionAfter, 2, 1, true); this(initPos, endPos, actionAfter, 2, 1, true);
} }
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, float height, float duration, boolean easing){ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, float height, float duration, boolean easing) {
super(actionAfter); super(actionAfter);
moving = false; moving = false;
this.initPos = initPos; this.initPos = initPos;
@@ -70,7 +71,7 @@ protected void initSpatial() {
*/ */
@Override @Override
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
if(!moving) return; if (!moving) return;
timer += tpf; timer += tpf;
float t = timer / duration; float t = timer / duration;
@@ -78,22 +79,20 @@ protected void controlUpdate(float tpf) {
float interpolated = easing ? easeInOut(t) : t; float interpolated = easing ? easeInOut(t) : t;
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, interpolated)); spatial.setLocalTranslation(quadInt(initPos, middlePos, endPos, interpolated));
if(t >= 1) end(); if (t >= 1) end();
} }
/** /**
* Ends the movement by stopping the interpolation, running the action after the movement, * Ends the movement by stopping the interpolation, running the action after the movement,
* and removing this control from the spatial. * and removing this control from the spatial.
*/ */
private void end(){ private void end() {
moving = false; moving = false;
spatial.removeControl(this); spatial.removeControl(this);
action(); action();
} }
} }

View File

@@ -3,17 +3,12 @@
import com.jme3.effect.ParticleEmitter; import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh; import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Quaternion; import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import pp.mdga.client.InitControl;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound; import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.TankTopControl; import pp.mdga.client.board.TankTopControl;
@@ -22,7 +17,6 @@
import java.util.TimerTask; import java.util.TimerTask;
import static com.jme3.material.Materials.LIGHTING; import static com.jme3.material.Materials.LIGHTING;
import static com.jme3.material.Materials.UNSHADED;
public class ShellAnimation extends ActionControl { public class ShellAnimation extends ActionControl {
private static final float FLYING_DURATION = 1.25f; private static final float FLYING_DURATION = 1.25f;
@@ -30,7 +24,7 @@ public class ShellAnimation extends ActionControl {
private TankTopControl tankTopControl; private TankTopControl tankTopControl;
private MdgaApp app; private MdgaApp app;
public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter){ public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter) {
super(actionAfter); super(actionAfter);
this.tankTopControl = tankTopControl; this.tankTopControl = tankTopControl;
this.app = app; this.app = app;
@@ -44,14 +38,14 @@ protected void initSpatial() {
app.getRootNode().attachChild(createShell()); app.getRootNode().attachChild(createShell());
} }
private Vector3f getShootPos(){ private Vector3f getShootPos() {
Vector3f localOffset = new Vector3f(0, -5.4f, 2.9f); Vector3f localOffset = new Vector3f(0, -5.4f, 2.9f);
Quaternion turretRotation = tankTopControl.getSpatial().getLocalRotation(); Quaternion turretRotation = tankTopControl.getSpatial().getLocalRotation();
Vector3f transformedOffset = turretRotation.mult(localOffset); Vector3f transformedOffset = turretRotation.mult(localOffset);
return tankTopControl.getSpatial().getLocalTranslation().add(transformedOffset); return tankTopControl.getSpatial().getLocalTranslation().add(transformedOffset);
} }
private void shoot(){ private void shoot() {
app.getAcousticHandler().playSound(MdgaSound.TANK_SHOOT); app.getAcousticHandler().playSound(MdgaSound.TANK_SHOOT);
Vector3f shootPos = getShootPos(); Vector3f shootPos = getShootPos();
createEffect( createEffect(
@@ -71,7 +65,7 @@ private void shoot(){
0.3f, 0.8f, 0.3f, 0.8f,
10, 10,
0.1f, 0.35f, 0.1f, 0.35f,
new ColorRGBA(0.5f,0.5f,0.5f,0.5f), new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f),
ColorRGBA.Black ColorRGBA.Black
); );
@@ -80,7 +74,7 @@ private void shoot(){
shell.addControl(new ShellControl(this::hitExplosion, shootPos, spatial.getLocalTranslation(), FLYING_HEIGHT, FLYING_DURATION, app.getAssetManager())); shell.addControl(new ShellControl(this::hitExplosion, shootPos, spatial.getLocalTranslation(), FLYING_HEIGHT, FLYING_DURATION, app.getAssetManager()));
} }
private Spatial createShell(){ private Spatial createShell() {
Spatial model = app.getAssetManager().loadModel(Asset.shell.getModelPath()); Spatial model = app.getAssetManager().loadModel(Asset.shell.getModelPath());
model.scale(.16f); model.scale(.16f);
model.setLocalTranslation(tankTopControl.getSpatial().getLocalTranslation()); model.setLocalTranslation(tankTopControl.getSpatial().getLocalTranslation());
@@ -90,21 +84,21 @@ private Spatial createShell(){
Vector3f direction = targetPos.subtract(shootPos).normalize(); Vector3f direction = targetPos.subtract(shootPos).normalize();
Quaternion rotation = new Quaternion(); Quaternion rotation = new Quaternion();
rotation.lookAt(direction, new Vector3f(1,0,0)); // Assuming UNIT_Y is the up vector rotation.lookAt(direction, new Vector3f(1, 0, 0)); // Assuming UNIT_Y is the up vector
model.setLocalRotation(rotation); model.setLocalRotation(rotation);
model.rotate(FastMath.HALF_PI,0,0); model.rotate(FastMath.HALF_PI, 0, 0);
Material mat = new Material(app.getAssetManager(), LIGHTING); Material mat = new Material(app.getAssetManager(), LIGHTING);
mat.setBoolean("UseMaterialColors", true); mat.setBoolean("UseMaterialColors", true);
ColorRGBA color = ColorRGBA.fromRGBA255(143,117,0,255); ColorRGBA color = ColorRGBA.fromRGBA255(143, 117, 0, 255);
mat.setColor("Diffuse", color); mat.setColor("Diffuse", color);
mat.setColor("Ambient", color); mat.setColor("Ambient", color);
model.setMaterial(mat); model.setMaterial(mat);
return model; return model;
} }
private void hitExplosion(){ private void hitExplosion() {
app.getAcousticHandler().playSound(MdgaSound.TANK_EXPLOSION); app.getAcousticHandler().playSound(MdgaSound.TANK_EXPLOSION);
createEffect( createEffect(
spatial.getLocalTranslation().setZ(1), spatial.getLocalTranslation().setZ(1),
@@ -130,7 +124,7 @@ private void createEffect(Vector3f shootPos,
float startSize, float endSize, float startSize, float endSize,
float velocity, float velocity,
float lowLife, float highLife, float lowLife, float highLife,
ColorRGBA start, ColorRGBA end){ ColorRGBA start, ColorRGBA end) {
// Create a particle emitter for the explosion // Create a particle emitter for the explosion
ParticleEmitter explosionEmitter = new ParticleEmitter("Explosion", ParticleMesh.Type.Triangle, 100); ParticleEmitter explosionEmitter = new ParticleEmitter("Explosion", ParticleMesh.Type.Triangle, 100);
Material explosionMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); Material explosionMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");

View File

@@ -7,7 +7,6 @@
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import pp.mdga.client.InitControl;
public class ShellControl extends ActionControl { public class ShellControl extends ActionControl {
private final Vector3f shootPos; private final Vector3f shootPos;
@@ -18,7 +17,7 @@ public class ShellControl extends ActionControl {
private ParticleEmitter emitter; private ParticleEmitter emitter;
private AssetManager assetManager; private AssetManager assetManager;
public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager){ public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager) {
super(runnable); super(runnable);
this.shootPos = shootPos; this.shootPos = shootPos;
this.endPos = endPos; this.endPos = endPos;
@@ -32,7 +31,7 @@ protected void initSpatial() {
spatial.addControl(new MoveControl( spatial.addControl(new MoveControl(
shootPos, shootPos,
endPos, endPos,
()->{ () -> {
emitter.killAllParticles(); emitter.killAllParticles();
emitter.setParticlesPerSec(0); emitter.setParticlesPerSec(0);
emitter.removeFromParent(); emitter.removeFromParent();
@@ -80,7 +79,7 @@ protected void controlUpdate(float tpf) {
Vector3f direction = spatial.getLocalTranslation().subtract(oldPos).normalize(); Vector3f direction = spatial.getLocalTranslation().subtract(oldPos).normalize();
if (direction.lengthSquared() > 0) { if (direction.lengthSquared() > 0) {
spatial.getLocalRotation().lookAt(direction, Vector3f.UNIT_X); spatial.getLocalRotation().lookAt(direction, Vector3f.UNIT_X);
spatial.rotate(FastMath.HALF_PI,0,0); spatial.rotate(FastMath.HALF_PI, 0, 0);
} }
oldPos = spatial.getLocalTranslation().clone(); oldPos = spatial.getLocalTranslation().clone();

View File

@@ -43,11 +43,11 @@ public Smoke(MdgaApp app, Node rootNode, Vector3f location) {
* Configures the fire and smoke emitters with appearance, behavior, and lifespan. * Configures the fire and smoke emitters with appearance, behavior, and lifespan.
*/ */
private void initializeEmitter() { private void initializeEmitter() {
fire = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,50); fire = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle, 50);
fire.setMaterial(mat); fire.setMaterial(mat);
fire.setStartColor(ColorRGBA.DarkGray); fire.setStartColor(ColorRGBA.DarkGray);
fire.setEndColor(ColorRGBA.DarkGray); fire.setEndColor(ColorRGBA.DarkGray);
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f)); fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f, 0.2f, 4f));
fire.getParticleInfluencer().setVelocityVariation(0.4f); fire.getParticleInfluencer().setVelocityVariation(0.4f);
fire.setStartSize(0.7f); fire.setStartSize(0.7f);
fire.setEndSize(3.8f); fire.setEndSize(3.8f);
@@ -58,13 +58,13 @@ private void initializeEmitter() {
fire.setLocalTranslation(location); fire.setLocalTranslation(location);
smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,40); smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle, 40);
smoke.setMaterial(mat); smoke.setMaterial(mat);
smoke.setImagesX(2); smoke.setImagesX(2);
smoke.setImagesY(2); smoke.setImagesY(2);
smoke.setStartColor(ColorRGBA.DarkGray); smoke.setStartColor(ColorRGBA.DarkGray);
smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1)); smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,2f)); smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 2f));
smoke.getParticleInfluencer().setVelocityVariation(0.5f); smoke.getParticleInfluencer().setVelocityVariation(0.5f);
smoke.setStartSize(0.5f); smoke.setStartSize(0.5f);
smoke.setEndSize(1.5f); smoke.setEndSize(1.5f);
@@ -103,7 +103,8 @@ protected void controlUpdate(float tpf) {
} }
@Override @Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {} protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
}); });
rootNode.attachChild(smoke); rootNode.attachChild(smoke);
@@ -121,7 +122,8 @@ protected void controlUpdate(float tpf) {
} }
@Override @Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {} protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
}); });
} }
} }

View File

@@ -5,4 +5,5 @@
/** /**
* Record for holding Asset information * Record for holding Asset information
*/ */
record AssetOnMap(Asset asset, int x, int y, float rot) {} record AssetOnMap(Asset asset, int x, int y, float rot) {
}

View File

@@ -2,7 +2,6 @@
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.material.RenderState; import com.jme3.material.RenderState;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
@@ -72,7 +71,7 @@ public class BoardHandler {
* @throws RuntimeException if the app is null * @throws RuntimeException if the app is null
*/ */
public BoardHandler(MdgaApp app, Node rootNode, FilterPostProcessor fpp) { public BoardHandler(MdgaApp app, Node rootNode, FilterPostProcessor fpp) {
if(app == null) throw new RuntimeException("app is null"); if (app == null) throw new RuntimeException("app is null");
this.app = app; this.app = app;
this.fpp = fpp; this.fpp = fpp;
@@ -99,7 +98,7 @@ public void init() {
/** /**
* Shuts down the board handler by detaching all board-related nodes and clearing selected pieces. * Shuts down the board handler by detaching all board-related nodes and clearing selected pieces.
*/ */
public void shutdown(){ public void shutdown() {
clearSelectable(); clearSelectable();
isInitialised = false; isInitialised = false;
rootNode.detachChild(rootNodeBoard); rootNode.detachChild(rootNodeBoard);
@@ -129,7 +128,7 @@ private void initMap() {
waitingPiecesMap = new HashMap<>(); waitingPiecesMap = new HashMap<>();
pieceColor = new HashMap<>(); pieceColor = new HashMap<>();
diceControl = new DiceControl(app.getAssetManager()); diceControl = new DiceControl(app.getAssetManager());
diceControl.create(new Vector3f(0,0,0), 0.7f, true); diceControl.create(new Vector3f(0, 0, 0), 0.7f, true);
waitingNodes = new HashMap<>(); waitingNodes = new HashMap<>();
waitingNodes.put(Color.AIRFORCE, new HashMap<>()); waitingNodes.put(Color.AIRFORCE, new HashMap<>());
waitingNodes.put(Color.ARMY, new HashMap<>()); waitingNodes.put(Color.ARMY, new HashMap<>());
@@ -262,7 +261,7 @@ private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T
* @param pieceControl The control managing the piece to be moved. * @param pieceControl The control managing the piece to be moved.
* @param nodeControl The control managing the target node to which the piece will move. * @param nodeControl The control managing the target node to which the piece will move.
*/ */
private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl){ private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl) {
pieceControl.setLocation(nodeControl.getLocation()); pieceControl.setLocation(nodeControl.getLocation());
} }
@@ -274,7 +273,7 @@ private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl)
* @param assetOnMap The asset representing the home node in the 3D environment. * @param assetOnMap The asset representing the home node in the 3D environment.
* @throws RuntimeException if more than 4 home nodes are added for a single color. * @throws RuntimeException if more than 4 home nodes are added for a single color.
*/ */
private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){ private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap) {
List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp))); List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp)));
if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color); if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
} }
@@ -290,7 +289,7 @@ private float getRotationMove(Vector3f prev, Vector3f next) {
Vector3f direction = next.subtract(prev).normalizeLocal(); Vector3f direction = next.subtract(prev).normalizeLocal();
//I had to reverse dir.y, because then it worked. //I had to reverse dir.y, because then it worked.
float newRot = (float) Math.toDegrees(Math.atan2(direction.x, -direction.y)); float newRot = (float) Math.toDegrees(Math.atan2(direction.x, -direction.y));
if(newRot < 0) newRot += 360; if (newRot < 0) newRot += 360;
return newRot; return newRot;
} }
@@ -302,7 +301,7 @@ private float getRotationMove(Vector3f prev, Vector3f next) {
* @param curIndex The current index of the piece. * @param curIndex The current index of the piece.
* @param moveIndex The target index to move the piece to. * @param moveIndex The target index to move the piece to.
*/ */
private void movePieceRek(UUID uuid, int curIndex, int moveIndex){ private void movePieceRek(UUID uuid, int curIndex, int moveIndex) {
if (curIndex == moveIndex) return; if (curIndex == moveIndex) return;
int nextIndex = (curIndex + 1) % infield.size(); int nextIndex = (curIndex + 1) % infield.size();
@@ -311,7 +310,7 @@ private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
NodeControl nodeCur = infield.get(curIndex); NodeControl nodeCur = infield.get(curIndex);
NodeControl nodeMove = infield.get(nextIndex); NodeControl nodeMove = infield.get(nextIndex);
pieceControl.setRotation(getRotationMove(nodeCur.getLocation(),nodeMove.getLocation())); pieceControl.setRotation(getRotationMove(nodeCur.getLocation(), nodeMove.getLocation()));
movePieceToNode(pieceControl, nodeMove); movePieceToNode(pieceControl, nodeMove);
@@ -329,7 +328,7 @@ private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
* @param <E> The type of the key in the map. * @param <E> The type of the key in the map.
* @return The updated list associated with the specified key. * @return The updated list associated with the specified key.
*/ */
private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){ private <T, E> List<T> addItemToMapList(Map<E, List<T>> map, E key, T item) {
List<T> list = map.getOrDefault(key, new ArrayList<>()); List<T> list = map.getOrDefault(key, new ArrayList<>());
list.add(item); list.add(item);
map.put(key, list); map.put(key, list);
@@ -345,7 +344,7 @@ private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
* @param <T> The type of items in the list. * @param <T> The type of items in the list.
* @param <E> The type of the key in the map. * @param <E> The type of the key in the map.
*/ */
private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){ private <T, E> void removeItemFromMapList(Map<E, List<T>> map, E key, T item) {
List<T> list = map.getOrDefault(key, new ArrayList<>()); List<T> list = map.getOrDefault(key, new ArrayList<>());
list.remove(item); list.remove(item);
map.put(key, list); map.put(key, list);
@@ -357,7 +356,7 @@ private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
* @param color The color associated with the waiting nodes. * @param color The color associated with the waiting nodes.
* @return The mean position of the waiting nodes as a {@code Vector3f}. * @return The mean position of the waiting nodes as a {@code Vector3f}.
*/ */
private Vector3f getWaitingPos(Color color){ private Vector3f getWaitingPos(Color color) {
return getMeanPosition(waitingNodesMap.get(color).stream().map(NodeControl::getLocation).toList()); return getMeanPosition(waitingNodesMap.get(color).stream().map(NodeControl::getLocation).toList());
} }
@@ -388,13 +387,15 @@ public void addPlayer(Color color, List<UUID> uuid) {
List<AssetOnMap> playerAssets = colorAssetsMap.get(color); List<AssetOnMap> playerAssets = colorAssetsMap.get(color);
if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined"); if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined");
if (uuid.size() != playerAssets.size()) throw new RuntimeException("UUID array and playerAssets are not the same size"); if (uuid.size() != playerAssets.size())
throw new RuntimeException("UUID array and playerAssets are not the same size");
List<NodeControl> waitNodes = waitingNodesMap.get(color); List<NodeControl> waitNodes = waitingNodesMap.get(color);
if (waitNodes.size() != playerAssets.size()) throw new RuntimeException("waitNodes size does not match playerAssets size"); if (waitNodes.size() != playerAssets.size())
throw new RuntimeException("waitNodes size does not match playerAssets size");
for (int i = 0; i < playerAssets.size(); i++){ for (int i = 0; i < playerAssets.size(); i++) {
AssetOnMap assetOnMap = playerAssets.get(i); AssetOnMap assetOnMap = playerAssets.get(i);
UUID pieceUuid = uuid.get(i); UUID pieceUuid = uuid.get(i);
@@ -423,14 +424,14 @@ public void addPlayer(Color color, List<UUID> uuid) {
* @param index the index of the home node to move the piece to * @param index the index of the home node to move the piece to
* @throws RuntimeException if the UUID is not mapped to a color or if the home nodes are not properly defined * @throws RuntimeException if the UUID is not mapped to a color or if the home nodes are not properly defined
*/ */
private void moveHomePiece(UUID uuid, int index){ private void moveHomePiece(UUID uuid, int index) {
Color color = pieceColor.get(uuid); Color color = pieceColor.get(uuid);
if(color == null) throw new RuntimeException("uuid is not mapped to a color"); if (color == null) throw new RuntimeException("uuid is not mapped to a color");
List<NodeControl> homeNodes = homeNodesMap.get(color); List<NodeControl> homeNodes = homeNodesMap.get(color);
if(homeNodesMap.size() != 4) throw new RuntimeException("HomeNodes for" + color + " are not properly defined"); if (homeNodesMap.size() != 4) throw new RuntimeException("HomeNodes for" + color + " are not properly defined");
PieceControl pieceControl = pieces.get(uuid); PieceControl pieceControl = pieces.get(uuid);
NodeControl nodeControl = homeNodes.get(index); NodeControl nodeControl = homeNodes.get(index);
@@ -438,7 +439,7 @@ private void moveHomePiece(UUID uuid, int index){
//rotate piece in direction of homeNodes //rotate piece in direction of homeNodes
NodeControl firstHomeNode = homeNodes.get(0); NodeControl firstHomeNode = homeNodes.get(0);
NodeControl lastHomeNode = homeNodes.get(homeNodes.size()-1); NodeControl lastHomeNode = homeNodes.get(homeNodes.size() - 1);
pieceControl.setRotation(getRotationMove(firstHomeNode.getLocation(), lastHomeNode.getLocation())); pieceControl.setRotation(getRotationMove(firstHomeNode.getLocation(), lastHomeNode.getLocation()));
app.getModelSynchronize().animationEnd(); app.getModelSynchronize().animationEnd();
@@ -453,7 +454,7 @@ private void moveHomePiece(UUID uuid, int index){
* @throws RuntimeException if the UUID is not mapped to a color or the piece control is not found * @throws RuntimeException if the UUID is not mapped to a color or the piece control is not found
* @throws IllegalArgumentException if the node index is invalid * @throws IllegalArgumentException if the node index is invalid
*/ */
private void movePieceStart(UUID uuid, int nodeIndex){ private void movePieceStart(UUID uuid, int nodeIndex) {
// Farbe des Pieces abrufen // Farbe des Pieces abrufen
Color color = pieceColor.get(uuid); Color color = pieceColor.get(uuid);
@@ -484,7 +485,7 @@ private void movePieceStart(UUID uuid, int nodeIndex){
* @param curIndex the current index of the piece * @param curIndex the current index of the piece
* @param moveIndex the target index of the move * @param moveIndex the target index of the move
*/ */
private void movePiece(UUID uuid, int curIndex, int moveIndex){ private void movePiece(UUID uuid, int curIndex, int moveIndex) {
movePieceRek(uuid, curIndex, moveIndex); movePieceRek(uuid, curIndex, moveIndex);
app.getModelSynchronize().animationEnd(); app.getModelSynchronize().animationEnd();
@@ -497,7 +498,7 @@ private void movePiece(UUID uuid, int curIndex, int moveIndex){
* @param uuid the UUID of the piece to throw * @param uuid the UUID of the piece to throw
* @throws RuntimeException if the UUID is not mapped to a color or if no available waiting nodes are found * @throws RuntimeException if the UUID is not mapped to a color or if no available waiting nodes are found
*/ */
private void throwPiece(UUID uuid){ private void throwPiece(UUID uuid) {
// Farbe des Pieces abrufen // Farbe des Pieces abrufen
Color color = pieceColor.get(uuid); Color color = pieceColor.get(uuid);
@@ -531,7 +532,7 @@ private void throwPiece(UUID uuid){
* *
* @param uuid the UUID of the piece to shield * @param uuid the UUID of the piece to shield
*/ */
public void shieldPiece(UUID uuid){ public void shieldPiece(UUID uuid) {
pieces.get(uuid).activateShield(); pieces.get(uuid).activateShield();
} }
@@ -540,7 +541,7 @@ public void shieldPiece(UUID uuid){
* *
* @param uuid the UUID of the piece to unshield * @param uuid the UUID of the piece to unshield
*/ */
public void unshieldPiece(UUID uuid){ public void unshieldPiece(UUID uuid) {
pieces.get(uuid).deactivateShield(); pieces.get(uuid).deactivateShield();
} }
@@ -549,7 +550,7 @@ public void unshieldPiece(UUID uuid){
* *
* @param uuid the UUID of the piece to suppress the shield * @param uuid the UUID of the piece to suppress the shield
*/ */
public void suppressShield(UUID uuid){ public void suppressShield(UUID uuid) {
pieces.get(uuid).suppressShield(); pieces.get(uuid).suppressShield();
} }
@@ -564,7 +565,7 @@ public void suppressShield(UUID uuid){
* @param loc2 the original location of the second piece * @param loc2 the original location of the second piece
* @param rot2 the original rotation of the second piece * @param rot2 the original rotation of the second piece
*/ */
private void swapPieces(PieceControl p1, PieceControl p2, Vector3f loc1, float rot1, Vector3f loc2, float rot2){ private void swapPieces(PieceControl p1, PieceControl p2, Vector3f loc1, float rot1, Vector3f loc2, float rot2) {
p1.setLocation(loc2); p1.setLocation(loc2);
p2.setLocation(loc1); p2.setLocation(loc1);
@@ -583,7 +584,8 @@ private void swapPieces(PieceControl p1, PieceControl p2, Vector3f loc1, float r
* @throws RuntimeException if the sizes of the input lists do not match * @throws RuntimeException if the sizes of the input lists do not match
*/ */
public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) { public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) {
if(pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size()) throw new RuntimeException("arrays are not the same size"); if (pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size())
throw new RuntimeException("arrays are not the same size");
selectableEnemyPieces.clear(); selectableEnemyPieces.clear();
selectableOwnPieces.clear(); selectableOwnPieces.clear();
@@ -598,8 +600,7 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
if (homeMoves.get(i)) { if (homeMoves.get(i)) {
Color color = pieceColor.get(uuid); Color color = pieceColor.get(uuid);
nodeControl = homeNodesMap.get(color).get(moveIndexe.get(i)); nodeControl = homeNodesMap.get(color).get(moveIndexe.get(i));
} } else {
else {
nodeControl = infield.get(moveIndexe.get(i)); nodeControl = infield.get(moveIndexe.get(i));
} }
nodeControl.highlight(); nodeControl.highlight();
@@ -618,21 +619,21 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
* @param ownPieces the list of UUIDs representing the player's pieces * @param ownPieces the list of UUIDs representing the player's pieces
* @param enemyPieces the list of UUIDs representing the enemy's pieces * @param enemyPieces the list of UUIDs representing the enemy's pieces
*/ */
public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces){ public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces) {
selectableEnemyPieces.clear(); selectableEnemyPieces.clear();
selectableOwnPieces.clear(); selectableOwnPieces.clear();
selectedOwnPiece = null; selectedOwnPiece = null;
selectedEnemyPiece = null; selectedEnemyPiece = null;
for(UUID uuid : ownPieces) { for (UUID uuid : ownPieces) {
PieceControl p = pieces.get(uuid); PieceControl p = pieces.get(uuid);
p.highlight(false); p.highlight(false);
p.setHoverable(true); p.setHoverable(true);
p.setSelectable(true); p.setSelectable(true);
selectableOwnPieces.add(p); selectableOwnPieces.add(p);
} }
for(UUID uuid : enemyPieces) { for (UUID uuid : enemyPieces) {
PieceControl p = pieces.get(uuid); PieceControl p = pieces.get(uuid);
p.highlight(true); p.highlight(true);
p.setHoverable(true); p.setHoverable(true);
@@ -646,13 +647,13 @@ public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces){
* *
* @param pieces the list of UUIDs representing the pieces to be shielded * @param pieces the list of UUIDs representing the pieces to be shielded
*/ */
public void outlineShield(List<UUID> pieces){ public void outlineShield(List<UUID> pieces) {
selectableOwnPieces.clear(); selectableOwnPieces.clear();
selectableEnemyPieces.clear(); selectableEnemyPieces.clear();
selectedOwnPiece = null; selectedOwnPiece = null;
selectedEnemyPiece = null; selectedEnemyPiece = null;
for (UUID uuid : pieces){ for (UUID uuid : pieces) {
PieceControl p = this.pieces.get(uuid); PieceControl p = this.pieces.get(uuid);
p.highlight(false); p.highlight(false);
p.setHoverable(true); p.setHoverable(true);
@@ -668,69 +669,65 @@ public void outlineShield(List<UUID> pieces){
*/ */
public void pieceSelect(PieceControl pieceSelected) { public void pieceSelect(PieceControl pieceSelected) {
boolean isSelected = pieceSelected.isSelected(); boolean isSelected = pieceSelected.isSelected();
if(selectableOwnPieces.contains(pieceSelected)){ if (selectableOwnPieces.contains(pieceSelected)) {
for(PieceControl p : selectableOwnPieces) { for (PieceControl p : selectableOwnPieces) {
p.unSelect(); p.unSelect();
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect(); if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
} }
if (!isSelected) { if (!isSelected) {
pieceSelected.select(); pieceSelected.select();
if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).select(); if (selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).select();
selectedOwnPiece = pieceSelected; selectedOwnPiece = pieceSelected;
} } else {
else {
pieceSelected.unSelect(); pieceSelected.unSelect();
if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect(); if (selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect();
selectedOwnPiece = null; selectedOwnPiece = null;
} }
} } else if (selectableEnemyPieces.contains(pieceSelected)) {
else if(selectableEnemyPieces.contains(pieceSelected)) { for (PieceControl p : selectableEnemyPieces) {
for(PieceControl p : selectableEnemyPieces) {
p.unSelect(); p.unSelect();
} }
if (!isSelected) { if (!isSelected) {
pieceSelected.select(); pieceSelected.select();
selectedEnemyPiece = pieceSelected; selectedEnemyPiece = pieceSelected;
} } else {
else {
pieceSelected.unSelect(); pieceSelected.unSelect();
selectedEnemyPiece = null; selectedEnemyPiece = null;
} }
} } else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
app.getModelSynchronize().select(getKeyByValue(pieces, selectedOwnPiece), getKeyByValue(pieces, selectedEnemyPiece)); app.getModelSynchronize().select(getKeyByValue(pieces, selectedOwnPiece), getKeyByValue(pieces, selectedEnemyPiece));
} }
public void pieceHoverOn(PieceControl hoverPiece){ public void pieceHoverOn(PieceControl hoverPiece) {
hoverPiece.hover(); hoverPiece.hover();
if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hover(); if (selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hover();
} }
public void pieceHoverOff(PieceControl hoverPiece){ public void pieceHoverOff(PieceControl hoverPiece) {
hoverPiece.hoverOff(); hoverPiece.hoverOff();
if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff(); if (selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff();
} }
/** /**
* Clears all highlighted, selectable, and selected pieces and nodes. * Clears all highlighted, selectable, and selected pieces and nodes.
*/ */
public void clearSelectable(){ public void clearSelectable() {
for(PieceControl p : selectableEnemyPieces) { for (PieceControl p : selectableEnemyPieces) {
p.unSelect(); p.unSelect();
p.unHighlight(); p.unHighlight();
p.setSelectable(false); p.setSelectable(false);
p.setHoverable(false); p.setHoverable(false);
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect(); if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unHighlight(); if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unHighlight();
} }
for(PieceControl p : selectableOwnPieces) { for (PieceControl p : selectableOwnPieces) {
p.unSelect(); p.unSelect();
p.unHighlight(); p.unHighlight();
p.setSelectable(false); p.setSelectable(false);
p.setHoverable(false); p.setHoverable(false);
} }
for(NodeControl n : outlineNodes){ for (NodeControl n : outlineNodes) {
n.deOutline(); n.deOutline();
} }
outlineNodes.clear(); outlineNodes.clear();
@@ -746,16 +743,16 @@ public void clearSelectable(){
* *
* @param color the color of the player whose dice should be displayed * @param color the color of the player whose dice should be displayed
*/ */
public void showDice(Color color){ public void showDice(Color color) {
rootNodeBoard.attachChild(diceControl.getSpatial()); rootNodeBoard.attachChild(diceControl.getSpatial());
diceControl.setPos(getWaitingPos(color).add(new Vector3f(0,0,4))); diceControl.setPos(getWaitingPos(color).add(new Vector3f(0, 0, 4)));
diceControl.spin(); diceControl.spin();
} }
/** /**
* Hides the dice from the view. * Hides the dice from the view.
*/ */
public void hideDice(){ public void hideDice() {
diceControl.hide(); diceControl.hide();
} }
@@ -775,12 +772,12 @@ private <K, V> K getKeyByValue(Map<K, V> map, V value) {
* @param curIndex the current index of the piece * @param curIndex the current index of the piece
* @param moveIndex the target index to animate the piece to * @param moveIndex the target index to animate the piece to
*/ */
public void movePieceAnim(UUID uuid, int curIndex, int moveIndex){ public void movePieceAnim(UUID uuid, int curIndex, int moveIndex) {
pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getSpatial().addControl(new MoveControl(
infield.get(curIndex).getLocation(), infield.get(curIndex).getLocation(),
infield.get(moveIndex).getLocation(), infield.get(moveIndex).getLocation(),
()->movePiece(uuid,curIndex,moveIndex))); () -> movePiece(uuid, curIndex, moveIndex)));
} }
/** /**
@@ -789,11 +786,11 @@ public void movePieceAnim(UUID uuid, int curIndex, int moveIndex){
* @param uuid the UUID of the piece to animate * @param uuid the UUID of the piece to animate
* @param homeIndex the index of the home node to move the piece to * @param homeIndex the index of the home node to move the piece to
*/ */
public void movePieceHomeAnim(UUID uuid, int homeIndex){ public void movePieceHomeAnim(UUID uuid, int homeIndex) {
pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getSpatial().addControl(new MoveControl(
pieces.get(uuid).getLocation(), pieces.get(uuid).getLocation(),
homeNodesMap.get(pieceColor.get(uuid)).get(homeIndex).getLocation(), homeNodesMap.get(pieceColor.get(uuid)).get(homeIndex).getLocation(),
()->moveHomePiece(uuid,homeIndex))); () -> moveHomePiece(uuid, homeIndex)));
} }
/** /**
@@ -802,11 +799,11 @@ public void movePieceHomeAnim(UUID uuid, int homeIndex){
* @param uuid the UUID of the piece to animate * @param uuid the UUID of the piece to animate
* @param moveIndex the target index to animate the piece to * @param moveIndex the target index to animate the piece to
*/ */
public void movePieceStartAnim(UUID uuid, int moveIndex){ public void movePieceStartAnim(UUID uuid, int moveIndex) {
pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getSpatial().addControl(new MoveControl(
pieces.get(uuid).getLocation(), pieces.get(uuid).getLocation(),
infield.get(moveIndex).getLocation(), infield.get(moveIndex).getLocation(),
()->movePieceStart(uuid, moveIndex) () -> movePieceStart(uuid, moveIndex)
)); ));
} }
@@ -815,15 +812,15 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
* *
* @param uuid the UUID of the piece to animate * @param uuid the UUID of the piece to animate
*/ */
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(), pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(),
()->throwPiece(uuid)) () -> throwPiece(uuid))
); );
} }
public void throwPiece(UUID uuid, Color throwColor){ public void throwPiece(UUID uuid, Color throwColor) {
switch(throwColor){ switch (throwColor) {
case ARMY -> throwShell(uuid); case ARMY -> throwShell(uuid);
case NAVY -> throwMissile(uuid); case NAVY -> throwMissile(uuid);
case CYBER -> throwMatrix(uuid); case CYBER -> throwMatrix(uuid);
@@ -840,14 +837,14 @@ public void throwPiece(UUID uuid, Color throwColor){
private void throwBomb(UUID uuid) { private void throwBomb(UUID uuid) {
Vector3f targetPoint = pieces.get(uuid).getLocation(); Vector3f targetPoint = pieces.get(uuid).getLocation();
JetAnimation anim = new JetAnimation(app, rootNode, targetPoint, 40, 6, ()->throwPieceAnim(uuid)); JetAnimation anim = new JetAnimation(app, rootNode, targetPoint, 40, 6, () -> throwPieceAnim(uuid));
anim.start(); anim.start();
} }
private void throwMatrix(UUID uuid) { private void throwMatrix(UUID uuid) {
app.getAcousticHandler().playSound(MdgaSound.MATRIX); app.getAcousticHandler().playSound(MdgaSound.MATRIX);
Spatial piece = pieces.get(uuid).getSpatial(); Spatial piece = pieces.get(uuid).getSpatial();
piece.addControl(new MatrixAnimation(app, radarPos,()-> { piece.addControl(new MatrixAnimation(app, radarPos, () -> {
throwPieceAnim(uuid); throwPieceAnim(uuid);
})); }));
} }
@@ -855,12 +852,12 @@ private void throwMatrix(UUID uuid) {
private void throwMissile(UUID uuid) { private void throwMissile(UUID uuid) {
Vector3f targetPoint = pieces.get(uuid).getLocation(); Vector3f targetPoint = pieces.get(uuid).getLocation();
MissileAnimation anim = new MissileAnimation(app, rootNode, targetPoint, 2f, ()->throwPieceAnim(uuid)); MissileAnimation anim = new MissileAnimation(app, rootNode, targetPoint, 2f, () -> throwPieceAnim(uuid));
anim.start(); anim.start();
} }
private void throwShell(UUID uuid) { private void throwShell(UUID uuid) {
pieces.get(uuid).getSpatial().addControl(new ShellAnimation(tankTop, app, ()-> throwPieceAnim(uuid))); pieces.get(uuid).getSpatial().addControl(new ShellAnimation(tankTop, app, () -> throwPieceAnim(uuid)));
} }
/** /**
@@ -869,7 +866,7 @@ private void throwShell(UUID uuid) {
* @param piece1 the UUID of the first piece * @param piece1 the UUID of the first piece
* @param piece2 the UUID of the second piece * @param piece2 the UUID of the second piece
*/ */
public void swapPieceAnim(UUID piece1, UUID piece2){ public void swapPieceAnim(UUID piece1, UUID piece2) {
PieceControl piece1Control = pieces.get(piece1); PieceControl piece1Control = pieces.get(piece1);
PieceControl piece2Control = pieces.get(piece2); PieceControl piece2Control = pieces.get(piece2);
@@ -881,12 +878,13 @@ public void swapPieceAnim(UUID piece1, UUID piece2){
piece1Control.getSpatial().addControl(new MoveControl( piece1Control.getSpatial().addControl(new MoveControl(
piece1Control.getLocation().clone(), piece1Control.getLocation().clone(),
piece2Control.getLocation().clone(), piece2Control.getLocation().clone(),
()->{} () -> {
}
)); ));
piece2Control.getSpatial().addControl(new MoveControl( piece2Control.getSpatial().addControl(new MoveControl(
piece2Control.getLocation().clone(), piece2Control.getLocation().clone(),
piece1Control.getLocation().clone(), piece1Control.getLocation().clone(),
()->swapPieces(piece1Control,piece2Control,loc1,rot1,loc2,rot2) () -> swapPieces(piece1Control, piece2Control, loc1, rot1, loc2, rot2)
)); ));
} }

View File

@@ -73,7 +73,7 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
// ssaoFilter = new SSAOFilter(); // ssaoFilter = new SSAOFilter();
fxaaFilter = new FXAAFilter(); 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);
} }
@@ -94,7 +94,7 @@ public void init(Color ownColor) {
init = true; init = true;
initRot = true; initRot = true;
this.ownColor = ownColor; this.ownColor = ownColor;
app.getInputSynchronize().setRotation(getInitAngleByColor(ownColor)*2); app.getInputSynchronize().setRotation(getInitAngleByColor(ownColor) * 2);
} }
/** /**
@@ -124,7 +124,7 @@ public void shutdown() {
* @param rotation The rotation input, determining camera orientation. * @param rotation The rotation input, determining camera orientation.
*/ */
public void update(float scroll, float rotation) { public void update(float scroll, float rotation) {
if(!init) return; if (!init) return;
float scrollValue = Math.max(0, Math.min(scroll, 100)); float scrollValue = Math.max(0, Math.min(scroll, 100));
float rotationValue = rotation % 360; float rotationValue = rotation % 360;
@@ -162,8 +162,8 @@ public void update(float scroll, float rotation) {
* @param color The color used to determine the camera angle. * @param color The color used to determine the camera angle.
* @return The camera angle in degrees. * @return The camera angle in degrees.
*/ */
private float getAngleByColor(Color color){ private float getAngleByColor(Color color) {
return switch (color){ return switch (color) {
case ARMY -> 0; case ARMY -> 0;
case AIRFORCE -> 90; case AIRFORCE -> 90;
case NAVY -> 270; case NAVY -> 270;
@@ -178,7 +178,7 @@ private float getAngleByColor(Color color){
* @param color The color used to determine the camera angle. * @param color The color used to determine the camera angle.
* @return The initial camera angle in degrees. * @return The initial camera angle in degrees.
*/ */
private float getInitAngleByColor(Color color){ private float getInitAngleByColor(Color color) {
return (getAngleByColor(color) + 180) % 360; return (getAngleByColor(color) + 180) % 360;
} }

View File

@@ -65,11 +65,9 @@ public static List<AssetOnMap> loadMap(String mapName) {
Asset asset = getLoadedAsset(assetName); Asset asset = getLoadedAsset(assetName);
assetsOnMap.add(new AssetOnMap(asset, x, y, rot)); assetsOnMap.add(new AssetOnMap(asset, x, y, rot));
} }
} } catch (IOException e) {
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} } catch (IllegalArgumentException e) {
catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -3,9 +3,6 @@
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
/** /**
@@ -40,38 +37,38 @@ public NodeControl(MdgaApp app, FilterPostProcessor fpp) {
* *
* @return The {@link Vector3f} representing the node's location. * @return The {@link Vector3f} representing the node's location.
*/ */
public Vector3f getLocation(){ public Vector3f getLocation() {
return this.getSpatial().getLocalTranslation(); return this.getSpatial().getLocalTranslation();
} }
public void highlight(){ public void highlight() {
highlight = true; highlight = true;
super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH); super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
} }
public void unHighlight(){ public void unHighlight() {
highlight = false; highlight = false;
deOutline(); deOutline();
} }
public void select(){ public void select() {
select = true; select = true;
super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH); super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
} }
public void unSelect(){ public void unSelect() {
select = false; select = false;
if(highlight) highlight(); if (highlight) highlight();
else deOutline(); else deOutline();
} }
public void hover(){ public void hover() {
super.outline(OUTLINE_HOVER_COLOR, OUTLINE_HOVER_WIDTH); super.outline(OUTLINE_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
} }
public void hoverOff(){ public void hoverOff() {
if(select) select(); if (select) select();
else if(highlight) highlight(); else if (highlight) highlight();
else deOutline(); else deOutline();
} }
} }

View File

@@ -3,8 +3,8 @@
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.InitControl; import pp.mdga.client.InitControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.outline.SelectObjectOutliner; import pp.mdga.client.outline.SelectObjectOutliner;
/** /**
@@ -13,7 +13,9 @@
* object, allowing it to be highlighted or deselected. * object, allowing it to be highlighted or deselected.
*/ */
public class OutlineControl extends InitControl { public class OutlineControl extends InitControl {
/** The {@link SelectObjectOutliner} responsible for managing the outline effect. */ /**
* The {@link SelectObjectOutliner} responsible for managing the outline effect.
*/
private final SelectObjectOutliner outlineOwn; private final SelectObjectOutliner outlineOwn;
private static final int THICKNESS_DEFAULT = 6; private static final int THICKNESS_DEFAULT = 6;
private MdgaApp app; private MdgaApp app;
@@ -24,7 +26,7 @@ public class OutlineControl extends InitControl {
* @param app The main application managing the outline control. * @param app The main application managing the outline control.
* @param fpp The {@code FilterPostProcessor} used for post-processing effects. * @param fpp The {@code FilterPostProcessor} used for post-processing effects.
*/ */
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){ public OutlineControl(MdgaApp app, FilterPostProcessor fpp) {
this.app = app; this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app); outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
} }
@@ -36,7 +38,7 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
* @param fpp The {@code FilterPostProcessor} used for post-processing effects. * @param fpp The {@code FilterPostProcessor} used for post-processing effects.
* @param cam The camera used for rendering the outlined objects. * @param cam The camera used for rendering the outlined objects.
*/ */
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam) {
this.app = app; this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app); outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
} }
@@ -49,7 +51,7 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
* @param cam The camera used for rendering the outlined objects. * @param cam The camera used for rendering the outlined objects.
* @param thickness The thickness of the outline. * @param thickness The thickness of the outline.
*/ */
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness) {
this.app = app; this.app = app;
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app); outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
} }
@@ -59,7 +61,7 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thic
* *
* @param color The {@link ColorRGBA} representing the color of the outline. * @param color The {@link ColorRGBA} representing the color of the outline.
*/ */
public void outline(ColorRGBA color){ public void outline(ColorRGBA color) {
outlineOwn.select(spatial, color); outlineOwn.select(spatial, color);
} }
@@ -69,7 +71,7 @@ public void outline(ColorRGBA color){
* @param color The {@link ColorRGBA} representing the color of the outline. * @param color The {@link ColorRGBA} representing the color of the outline.
* @param width The width of the outline. * @param width The width of the outline.
*/ */
public void outline(ColorRGBA color, int width){ public void outline(ColorRGBA color, int width) {
deOutline(); deOutline();
outlineOwn.select(spatial, color, width); outlineOwn.select(spatial, color, width);
} }
@@ -77,7 +79,7 @@ public void outline(ColorRGBA color, int width){
/** /**
* Removes the outline effect from the spatial object. * Removes the outline effect from the spatial object.
*/ */
public void deOutline(){ public void deOutline() {
outlineOwn.deselect(spatial); outlineOwn.deselect(spatial);
} }

View File

@@ -58,7 +58,7 @@ public class PieceControl extends OutlineControl {
* @param app The {@link MdgaApp} instance to use for the application context. * @param app The {@link MdgaApp} instance to use for the application context.
* @param fpp The {@link FilterPostProcessor} to apply post-processing effects. * @param fpp The {@link FilterPostProcessor} to apply post-processing effects.
*/ */
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp){ public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp) {
super(app, fpp); super(app, fpp);
this.parentNode = new Node(); this.parentNode = new Node();
this.initRotation = initRotation; this.initRotation = initRotation;
@@ -79,7 +79,7 @@ public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app,
* @return The rotation of the piece in degrees. * @return The rotation of the piece in degrees.
*/ */
public float getRotation() { public float getRotation() {
return (float) Math.toDegrees(spatial.getLocalRotation().toAngleAxis(new Vector3f(0,0,1))); return (float) Math.toDegrees(spatial.getLocalRotation().toAngleAxis(new Vector3f(0, 0, 1)));
} }
/** /**
@@ -87,11 +87,11 @@ public float getRotation() {
* *
* @param rot The rotation in degrees to set. * @param rot The rotation in degrees to set.
*/ */
public void setRotation(float rot){ public void setRotation(float rot) {
if(rot < 0) rot =- 360; if (rot < 0) rot = -360;
Quaternion quaternion = new Quaternion(); Quaternion quaternion = new Quaternion();
quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0,0,1)); quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0, 0, 1));
spatial.setLocalRotation(quaternion); spatial.setLocalRotation(quaternion);
} }
@@ -100,7 +100,7 @@ public void setRotation(float rot){
* *
* @return The location of the piece as a {@link Vector3f}. * @return The location of the piece as a {@link Vector3f}.
*/ */
public Vector3f getLocation(){ public Vector3f getLocation() {
return spatial.getLocalTranslation(); return spatial.getLocalTranslation();
} }
@@ -111,9 +111,9 @@ public Vector3f getLocation(){
*/ */
@Override @Override
protected void controlUpdate(float delta) { protected void controlUpdate(float delta) {
if(shieldRing != null){ if (shieldRing != null) {
shieldRing.rotate(0, 0, delta * SHIELD_SPEED); shieldRing.rotate(0, 0, delta * SHIELD_SPEED);
shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0,0,SHIELD_Z))); shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0, 0, SHIELD_Z)));
} }
} }
@@ -122,7 +122,7 @@ protected void controlUpdate(float delta) {
* *
* @param loc The location to set as a {@link Vector3f}. * @param loc The location to set as a {@link Vector3f}.
*/ */
public void setLocation(Vector3f loc){ public void setLocation(Vector3f loc) {
this.spatial.setLocalTranslation(loc); this.spatial.setLocalTranslation(loc);
} }
@@ -131,7 +131,7 @@ public void setLocation(Vector3f loc){
* This also moves the spatial to a new parent node for organizational purposes. * This also moves the spatial to a new parent node for organizational purposes.
*/ */
@Override @Override
public void initSpatial(){ public void initSpatial() {
setRotation(this.initRotation); setRotation(this.initRotation);
Node oldParent = spatial.getParent(); Node oldParent = spatial.getParent();
@@ -149,14 +149,14 @@ public void rotateInit() {
* Activates the shield around the piece. * Activates the shield around the piece.
* This adds a visual shield effect in the form of a rotating ring. * This adds a visual shield effect in the form of a rotating ring.
*/ */
public void activateShield(){ public void activateShield() {
if(shieldRing != null){ if (shieldRing != null) {
deactivateShield(); deactivateShield();
} }
shieldRing = assetManager.loadModel(Asset.shieldRing.getModelPath()); shieldRing = assetManager.loadModel(Asset.shieldRing.getModelPath());
shieldRing.scale(1f); shieldRing.scale(1f);
shieldRing.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(0)); shieldRing.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(0));
shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0,0,SHIELD_Z))); shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0, 0, SHIELD_Z)));
shieldRing.setQueueBucket(RenderQueue.Bucket.Transparent); // Render in the transparent bucket shieldRing.setQueueBucket(RenderQueue.Bucket.Transparent); // Render in the transparent bucket
@@ -170,7 +170,7 @@ public void activateShield(){
* Deactivates the shield by removing the shield ring from the scene. * Deactivates the shield by removing the shield ring from the scene.
*/ */
public void deactivateShield(){ public void deactivateShield() {
parentNode.detachChild(shieldRing); parentNode.detachChild(shieldRing);
shieldRing = null; shieldRing = null;
} }
@@ -178,16 +178,16 @@ public void deactivateShield(){
/** /**
* Suppresses the shield, changing its color to a suppressed state. * Suppresses the shield, changing its color to a suppressed state.
*/ */
public void suppressShield(){ public void suppressShield() {
assert(shieldRing != null) : "PieceControl: shieldRing is not set"; assert (shieldRing != null) : "PieceControl: shieldRing is not set";
shieldMat.setColor("Color", SHIELD_SUPPRESSED_COLOR); shieldMat.setColor("Color", SHIELD_SUPPRESSED_COLOR);
} }
public void setMaterial(Material mat){ public void setMaterial(Material mat) {
spatial.setMaterial(mat); spatial.setMaterial(mat);
} }
public Material getMaterial(){ public Material getMaterial() {
return ((Geometry) getSpatial()).getMaterial(); return ((Geometry) getSpatial()).getMaterial();
} }
@@ -205,7 +205,7 @@ public void highlight(boolean enemy) {
/** /**
* Removes the highlight effect from the piece. * Removes the highlight effect from the piece.
*/ */
public void unHighlight(){ public void unHighlight() {
highlight = false; highlight = false;
deOutline(); deOutline();
} }
@@ -213,19 +213,19 @@ public void unHighlight(){
/** /**
* Applies a hover effect on the piece if it is hoverable. * Applies a hover effect on the piece if it is hoverable.
*/ */
public void hover(){ public void hover() {
if(!hoverable) return; if (!hoverable) return;
super.outline(enemy ? OUTLINE_ENEMY_HOVER_COLOR : OUTLINE_OWN_HOVER_COLOR, OUTLINE_HOVER_WIDTH); super.outline(enemy ? OUTLINE_ENEMY_HOVER_COLOR : OUTLINE_OWN_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
} }
/** /**
* Removes the hover effect from the piece. * Removes the hover effect from the piece.
*/ */
public void hoverOff(){ public void hoverOff() {
if(!hoverable) return; if (!hoverable) return;
if(select) select(); if (select) select();
else if(highlight) highlight(enemy); else if (highlight) highlight(enemy);
else deOutline(); else deOutline();
} }
@@ -233,9 +233,9 @@ public void hoverOff(){
* Deselects the piece and removes the selection outline. If the piece was highlighted, * Deselects the piece and removes the selection outline. If the piece was highlighted,
* it will be re-highlighted. Otherwise, the outline is removed. * it will be re-highlighted. Otherwise, the outline is removed.
*/ */
public void unSelect(){ public void unSelect() {
select = false; select = false;
if(highlight) highlight(enemy); if (highlight) highlight(enemy);
else deOutline(); else deOutline();
} }
@@ -243,8 +243,8 @@ public void unSelect(){
* Selects the piece and applies the selection outline. If the piece is an enemy, it will * Selects the piece and applies the selection outline. If the piece is an enemy, it will
* be outlined with the enemy selection color; otherwise, the own selection color will be used. * be outlined with the enemy selection color; otherwise, the own selection color will be used.
*/ */
public void select(){ public void select() {
if(!selectable) return; if (!selectable) return;
select = true; select = true;
super.outline(enemy ? OUTLINE_ENEMY_SELECT_COLOR : OUTLINE_OWN_SELECT_COLOR, OUTLINE_SELECT_WIDTH); super.outline(enemy ? OUTLINE_ENEMY_SELECT_COLOR : OUTLINE_OWN_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
} }
@@ -254,7 +254,7 @@ public void select(){
* *
* @param selectable True if the piece can be selected, false otherwise. * @param selectable True if the piece can be selected, false otherwise.
*/ */
public void setSelectable(boolean selectable){ public void setSelectable(boolean selectable) {
this.selectable = selectable; this.selectable = selectable;
} }
@@ -263,7 +263,9 @@ public void setSelectable(boolean selectable){
* *
* @return True if the piece is selected, false otherwise. * @return True if the piece is selected, false otherwise.
*/ */
public boolean isSelected() { return select; } public boolean isSelected() {
return select;
}
/** /**
* Checks if the piece is selectable. * Checks if the piece is selectable.

View File

@@ -37,9 +37,9 @@ protected void controlUpdate(float tpf) {
// Apply the interpolated rotation to the spatial // Apply the interpolated rotation to the spatial
spatial.setLocalRotation(interpolatedRotation); spatial.setLocalRotation(interpolatedRotation);
if(t >= 1){ if (t >= 1) {
rotating = false; rotating = false;
if(actionAfter != null) actionAfter.run(); if (actionAfter != null) actionAfter.run();
} }
} }
@@ -62,7 +62,7 @@ public void rotate(Vector3f enemyPos, Runnable actionAfter) {
this.actionAfter = actionAfter; // Store the action to execute after rotation this.actionAfter = actionAfter; // Store the action to execute after rotation
} }
private float getEnemyAngle(Vector3f enemyPos){ private float getEnemyAngle(Vector3f enemyPos) {
// Direction to the enemy in the XY plane // Direction to the enemy in the XY plane
Vector3f direction = enemyPos.subtract(spatial.getLocalTranslation()); Vector3f direction = enemyPos.subtract(spatial.getLocalTranslation());
direction.z = 0; // Project to XY plane direction.z = 0; // Project to XY plane

View File

@@ -3,7 +3,6 @@
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 com.jme3.ui.Picture;
/** /**
* Represents a specific implementation of a clickable button positioned on the left side. * Represents a specific implementation of a clickable button positioned on the left side.

View File

@@ -77,7 +77,8 @@ public enum Pos {
* @param name the label or name displayed on the button * @param name the label or name displayed on the button
*/ */
public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, String name) { public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, String name) {
super(app, node, () -> {}, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0)); super(app, node, () -> {
}, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
this.node3d = node3d; this.node3d = node3d;

View File

@@ -38,7 +38,8 @@ public class LabelButton extends ClickButton {
* @param isButton whether this component acts as a button or a simple label * @param isButton whether this component acts as a button or a simple label
*/ */
public LabelButton(MdgaApp app, Node node, String label, Vector2f size, Vector2f pos, boolean isButton) { public LabelButton(MdgaApp app, Node node, String label, Vector2f size, Vector2f pos, boolean isButton) {
super(app, node, () -> {}, label, size, pos); super(app, node, () -> {
}, label, size, pos);
this.isButton = isButton; this.isButton = isButton;

View File

@@ -1,17 +1,13 @@
package pp.mdga.client.button; package pp.mdga.client.button;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion; import com.jme3.math.Quaternion;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.component.QuadBackgroundComponent;
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;

View File

@@ -2,8 +2,6 @@
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.simsilica.lemur.HAlignment;
import com.simsilica.lemur.VAlignment;
import com.simsilica.lemur.component.IconComponent; import com.simsilica.lemur.component.IconComponent;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;

View File

@@ -91,7 +91,7 @@ protected void onHide() {
* This method is called continuously while the dialog is active. * This method is called continuously while the dialog is active.
*/ */
public void update() { public void update() {
if(!active) { if (!active) {
return; return;
} }

View File

@@ -88,7 +88,7 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5
int j = 0; int j = 0;
for (LabelButton b : row) { for (LabelButton b : row) {
if(j > 0) { if (j > 0) {
b.setColor(colorText, colorButton); b.setColor(colorText, colorButton);
} }

View File

@@ -1,7 +1,6 @@
package pp.mdga.client.dialog; package pp.mdga.client.dialog;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.simsilica.lemur.Container;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
/** /**

View File

@@ -3,11 +3,9 @@
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.ButtonRight; import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.LabelButton; import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.MenuButton; import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView;
import pp.mdga.game.Color; import pp.mdga.game.Color;
/** /**
@@ -39,7 +37,7 @@ public InterruptDialog(MdgaApp app, Node node) {
@Override @Override
protected void onShow() { protected void onShow() {
if(app.getGameLogic().isHost()) { if (app.getGameLogic().isHost()) {
forceButton.show(); forceButton.show();
} }

View File

@@ -4,7 +4,6 @@
import com.jme3.scene.Node; import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.NetworkSupport; import pp.mdga.client.NetworkSupport;
import pp.mdga.client.acoustic.AcousticHandler;
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.InputButton; import pp.mdga.client.button.InputButton;

View File

@@ -3,9 +3,7 @@
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.InputButton;
import pp.mdga.client.button.MenuButton; import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MainView;
import pp.mdga.client.view.MdgaView; import pp.mdga.client.view.MdgaView;
/** /**

View File

@@ -1,18 +1,13 @@
package pp.mdga.client.dialog; package pp.mdga.client.dialog;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.InputButton; import pp.mdga.client.button.InputButton;
import pp.mdga.client.button.MenuButton; import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MainView; import pp.mdga.client.view.MainView;
import java.util.Random; import java.util.Random;
import java.util.random.RandomGenerator;
/** /**
* The {@code StartDialog} class represents the initial dialog in the application, * The {@code StartDialog} class represents the initial dialog in the application,
@@ -75,8 +70,7 @@ protected void onShow() {
* Called when the dialog is hidden. Hides the name input field and all buttons. * Called when the dialog is hidden. Hides the name input field and all buttons.
*/ */
@Override @Override
protected void onHide () protected void onHide() {
{
nameInput.hide(); nameInput.hide();
hostButton.hide(); hostButton.hide();

View File

@@ -3,7 +3,6 @@
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;
@@ -122,7 +121,7 @@ protected void onHide() {
* Updates the dialog's state. This method can be used for periodic updates while the dialog is active. * Updates the dialog's state. This method can be used for periodic updates while the dialog is active.
*/ */
public void update() { public void update() {
if(!active) { if (!active) {
return; return;
} }
} }
@@ -136,7 +135,7 @@ public void update() {
* @param isFullscreen {@code true} if fullscreen mode is enabled, {@code false} otherwise. * @param isFullscreen {@code true} if fullscreen mode is enabled, {@code false} otherwise.
*/ */
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) { 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)) { if (width != prefs.getInt("width", 1280) || height != prefs.getInt("height", 720) || isFullscreen != prefs.getBoolean("fullscreen", false)) {
restartButton.show(); restartButton.show();
} }

View File

@@ -14,7 +14,7 @@
* The {@code ActionTextHandler} class manages the display of animated and stylized text messages in the game's UI. * The {@code ActionTextHandler} class manages the display of animated and stylized text messages in the game's UI.
* It supports dynamic text creation with spacing, color, and effects, such as dice rolls, player actions, and rankings. * It supports dynamic text creation with spacing, color, and effects, such as dice rolls, player actions, and rankings.
*/ */
class ActionTextHandler { class ActionTextHandler {
private Node root; private Node root;
private BitmapFont font; private BitmapFont font;
private AppSettings appSettings; private AppSettings appSettings;
@@ -29,7 +29,7 @@ class ActionTextHandler {
* @param assetManager The asset manager used to load fonts and other assets. * @param assetManager The asset manager used to load fonts and other assets.
* @param appSettings The application settings for positioning and sizing. * @param appSettings The application settings for positioning and sizing.
*/ */
ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){ ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings) {
root = new Node("actionTextRoot"); root = new Node("actionTextRoot");
guiNode.attachChild(root); guiNode.attachChild(root);
@@ -50,12 +50,12 @@ class ActionTextHandler {
* @throws RuntimeException if the lengths of {@code textArr} and {@code colorArr} do not match. * @throws RuntimeException if the lengths of {@code textArr} and {@code colorArr} do not match.
*/ */
private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) { private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length"); if (textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length");
Node textNode = new Node("TextWithSpacing"); Node textNode = new Node("TextWithSpacing");
Node center = new Node(); Node center = new Node();
float xOffset = 0; float xOffset = 0;
for(int i = 0; i < textArr.length; i++){ for (int i = 0; i < textArr.length; i++) {
String text = textArr[i]; String text = textArr[i];
ColorRGBA color = colorArr[i]; ColorRGBA color = colorArr[i];
for (char c : text.toCharArray()) { for (char c : text.toCharArray()) {
@@ -63,14 +63,14 @@ private Node createTextWithSpacing(String[] textArr, float spacing, float size,
letter.setColor(color); letter.setColor(color);
letter.setSize(size); letter.setSize(size);
letter.setText(Character.toString(c)); letter.setText(Character.toString(c));
letter.setLocalTranslation(xOffset, letter.getHeight()/2, 0); letter.setLocalTranslation(xOffset, letter.getHeight() / 2, 0);
center.attachChild(letter); center.attachChild(letter);
xOffset += letter.getLineWidth() + spacing; xOffset += letter.getLineWidth() + spacing;
} }
} }
center.setLocalTranslation(new Vector3f(-xOffset/2,0,0)); center.setLocalTranslation(new Vector3f(-xOffset / 2, 0, 0));
textNode.attachChild(center); textNode.attachChild(center);
return textNode; return textNode;
} }
@@ -96,8 +96,8 @@ private Node createTextWithSpacing(String text, float spacing, float size, Color
* @param pos The origin position of the rectangle. * @param pos The origin position of the rectangle.
* @return A {@code Vector3f} representing the center position. * @return A {@code Vector3f} representing the center position.
*/ */
private Vector3f center(float width, float height, Vector3f pos){ private Vector3f center(float width, float height, Vector3f pos) {
return new Vector3f(pos.x+width/2, pos.y+height/2,0); return new Vector3f(pos.x + width / 2, pos.y + height / 2, 0);
} }
/** /**
@@ -110,7 +110,7 @@ private Vector3f center(float width, float height, Vector3f pos){
* @param top The vertical offset from the top of the screen. * @param top The vertical offset from the top of the screen.
* @return A {@code Node} containing the styled text positioned at the top. * @return A {@code Node} containing the styled text positioned at the top.
*/ */
private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){ private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top) {
return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top); return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top);
} }
@@ -124,9 +124,9 @@ private Node createTopText(String name, float spacing, float size, ColorRGBA col
* @param top The vertical offset from the top of the screen. * @param top The vertical offset from the top of the screen.
* @return A {@code Node} containing the styled text positioned at the top. * @return A {@code Node} containing the styled text positioned at the top.
*/ */
private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){ private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top) {
Node text = createTextWithSpacing(name, spacing, size, color); Node text = createTextWithSpacing(name, spacing, size, color);
text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0); text.setLocalTranslation(0, (appSettings.getHeight() / 2f) * 0.8f - top, 0);
root.attachChild(text); root.attachChild(text);
return text; return text;
} }
@@ -139,7 +139,7 @@ private Node createTopText(String[] name, float spacing, float size, ColorRGBA c
* @param pos The origin position of the rectangle. * @param pos The origin position of the rectangle.
* @return A {@code Vector3f} representing the center position. * @return A {@code Vector3f} representing the center position.
*/ */
private Vector3f centerText(float width, float height, Vector3f pos){ private Vector3f centerText(float width, float height, Vector3f pos) {
return center(-width, height, pos); return center(-width, height, pos);
} }
@@ -149,8 +149,8 @@ private Vector3f centerText(float width, float height, Vector3f pos){
* @param name The name of the active player. * @param name The name of the active player.
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void activePlayer(String name, Color color){ void activePlayer(String name, Color color) {
createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); createTopText(new String[]{name, " ist dran"}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
} }
/** /**
@@ -158,8 +158,8 @@ void activePlayer(String name, Color color){
* *
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void ownActive(Color color){ void ownActive(Color color) {
createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); createTopText(new String[]{"Du", " bist dran"}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
} }
/** /**
@@ -169,8 +169,8 @@ void ownActive(Color color){
* @param name The name of the player. * @param name The name of the player.
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void diceNum(int diceNum, String name, Color color){ void diceNum(int diceNum, String name, Color color) {
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0); createTopText(new String[]{name, " würfelt:"}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0);
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 100); createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 100);
@@ -184,10 +184,10 @@ void diceNum(int diceNum, String name, Color color){
* @param name The name of the player. * @param name The name of the player.
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void diceNumMult(int diceNum,int mult, String name, Color color){ void diceNumMult(int diceNum, int mult, String name, Color color) {
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0); createTopText(new String[]{name, " würfelt:"}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0);
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100); createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum * mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White, ColorRGBA.Red}, 100);
} }
/** /**
@@ -195,7 +195,7 @@ void diceNumMult(int diceNum,int mult, String name, Color color){
* *
* @param diceNum The number rolled on the dice. * @param diceNum The number rolled on the dice.
*/ */
void ownDice(int diceNum){ void ownDice(int diceNum) {
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0); createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
} }
@@ -205,8 +205,8 @@ void ownDice(int diceNum){
* @param diceNum The number rolled on the dice. * @param diceNum The number rolled on the dice.
* @param mult The multiplier applied to the dice result. * @param mult The multiplier applied to the dice result.
*/ */
void ownDiceMult(int diceNum, int mult){ void ownDiceMult(int diceNum, int mult) {
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0); createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum * mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White, ColorRGBA.Red}, 0);
} }
/** /**
@@ -215,8 +215,8 @@ void ownDiceMult(int diceNum, int mult){
* @param name The name of the player who received the bonus card. * @param name The name of the player who received the bonus card.
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void drawCard(String name, Color color){ void drawCard(String name, Color color) {
createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); createTopText(new String[]{name, " erhält eine Bonuskarte"}, 7, 70, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
} }
/** /**
@@ -224,8 +224,8 @@ void drawCard(String name, Color color){
* *
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void drawCardOwn(Color color){ void drawCardOwn(Color color) {
createTopText(new String[]{"Du"," erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); createTopText(new String[]{"Du", " erhälst eine Bonuskarte"}, 5, 70, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
} }
/** /**
@@ -234,8 +234,8 @@ void drawCardOwn(Color color){
* @param name The name of the player who finished. * @param name The name of the player who finished.
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void finishText(String name, Color color){ void finishText(String name, Color color) {
createTopText(new String[]{name," ist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); createTopText(new String[]{name, " ist fertig!"}, 7, 70, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
} }
/** /**
@@ -243,8 +243,8 @@ void finishText(String name, Color color){
* *
* @param color The color representing the player's team. * @param color The color representing the player's team.
*/ */
void finishTextOwn(Color color){ void finishTextOwn(Color color) {
createTopText(new String[]{"Du", " bist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl()); createTopText(new String[]{"Du", " bist fertig!"}, 7, 70, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
} }
/** /**
@@ -254,8 +254,8 @@ void finishTextOwn(Color color){
* @return The corresponding {@code ColorRGBA}. * @return The corresponding {@code ColorRGBA}.
* @throws RuntimeException if the color is invalid. * @throws RuntimeException if the color is invalid.
*/ */
private ColorRGBA playerColorToColorRGBA(Color color){ private ColorRGBA playerColorToColorRGBA(Color color) {
return switch (color){ return switch (color) {
case ARMY -> ColorRGBA.Green; case ARMY -> ColorRGBA.Green;
case NAVY -> ColorRGBA.Blue; case NAVY -> ColorRGBA.Blue;
case CYBER -> ColorRGBA.Orange; case CYBER -> ColorRGBA.Orange;
@@ -267,7 +267,7 @@ private ColorRGBA playerColorToColorRGBA(Color color){
/** /**
* Hides all text messages displayed by the handler and resets the ranking counter. * Hides all text messages displayed by the handler and resets the ranking counter.
*/ */
void hide(){ void hide() {
ranking = 0; ranking = 0;
root.detachAllChildren(); root.detachAllChildren();
} }
@@ -279,8 +279,8 @@ void hide(){
* @param color The color representing the player's team. * @param color The color representing the player's team.
* @param eye The dice roll result. * @param eye The dice roll result.
*/ */
void rollRankingResult(String name, Color color, int eye){ void rollRankingResult(String name, Color color, int eye) {
createTopText(new String[]{name,": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking); createTopText(new String[]{name, ": " + eye}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, paddingRanked * ranking);
ranking++; ranking++;
} }
@@ -290,15 +290,15 @@ void rollRankingResult(String name, Color color, int eye){
* @param color The color representing the player's team. * @param color The color representing the player's team.
* @param eye The dice roll result. * @param eye The dice roll result.
*/ */
void rollRankingResultOwn(Color color, int eye){ void rollRankingResultOwn(Color color, int eye) {
createTopText(new String[]{"Du",": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking); createTopText(new String[]{"Du", ": " + eye}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, paddingRanked * ranking);
ranking++; ranking++;
} }
/** /**
* Displays a message prompting the player to roll the dice. * Displays a message prompting the player to roll the dice.
*/ */
void diceNow(){ void diceNow() {
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0); createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
} }
} }

View File

@@ -7,19 +7,12 @@
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Cylinder;
import com.jme3.scene.shape.Sphere; import com.jme3.scene.shape.Sphere;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.OutlineControl; import pp.mdga.client.board.OutlineControl;
import java.awt.*;
public class CardControl extends OutlineControl { public class CardControl extends OutlineControl {
private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.Yellow; private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.Yellow;
@@ -42,20 +35,20 @@ public class CardControl extends OutlineControl {
private Node root; private Node root;
private BitmapText num; private BitmapText num;
public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, Node root){ public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, Node root) {
super(app, fpp, cam, OUTLINE_THICKNESS); super(app, fpp, cam, OUTLINE_THICKNESS);
this.root = root; this.root = root;
Node rootNum = createNum(); Node rootNum = createNum();
rootNum.setLocalTranslation(new Vector3f(0.35f,0.8f,0)); rootNum.setLocalTranslation(new Vector3f(0.35f, 0.8f, 0));
root.attachChild(rootNum); root.attachChild(rootNum);
} }
private Node createNum(){ private Node createNum() {
Node rootNum = new Node("root Num"); Node rootNum = new Node("root Num");
Geometry circle = new Geometry("circle", new Sphere(20,20,1)); Geometry circle = new Geometry("circle", new Sphere(20, 20, 1));
circle.setLocalTranslation(new Vector3f(0.03f,0.01f,1)); circle.setLocalTranslation(new Vector3f(0.03f, 0.01f, 1));
circle.setLocalScale(0.2f); circle.setLocalScale(0.2f);
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);
@@ -72,7 +65,7 @@ private Node createNum(){
return rootNum; return rootNum;
} }
public void setNumCard(int num){ public void setNumCard(int num) {
this.num.setText(String.valueOf(num)); this.num.setText(String.valueOf(num));
} }
@@ -81,14 +74,14 @@ public Node getRoot() {
} }
@Override @Override
public void initSpatial(){ public void initSpatial() {
} }
public void outline(){ public void outline() {
super.outline(OUTLINE_COLOR); super.outline(OUTLINE_COLOR);
} }
private final static Vector3f HIGHLIGHT_Y = new Vector3f(0,0.4f,0); private final static Vector3f HIGHLIGHT_Y = new Vector3f(0, 0.4f, 0);
public void setHighlight() { public void setHighlight() {
this.highlight = true; this.highlight = true;
@@ -100,39 +93,39 @@ public void highlight() {
super.outline(HIGHLIGHT_COLOR, HIGHLIGHT_WIDTH); super.outline(HIGHLIGHT_COLOR, HIGHLIGHT_WIDTH);
} }
public void unHighlight(){ public void unHighlight() {
highlight = false; highlight = false;
root.setLocalTranslation(root.getLocalTranslation().subtract(HIGHLIGHT_Y)); root.setLocalTranslation(root.getLocalTranslation().subtract(HIGHLIGHT_Y));
deOutline(); deOutline();
} }
public void hover(){ public void hover() {
if(!hoverable) return; if (!hoverable) return;
super.outline(HOVER_COLOR, HOVER_WIDTH); super.outline(HOVER_COLOR, HOVER_WIDTH);
} }
public void hoverOff(){ public void hoverOff() {
if(!hoverable) return; if (!hoverable) return;
if(select) select(); if (select) select();
else if(highlight) highlight(); else if (highlight) highlight();
else deOutline(); else deOutline();
} }
public void select(){ public void select() {
if(!selectable) return; if (!selectable) return;
select = true; select = true;
super.outline(SELECT_COLOR, SELECT_WIDTH); super.outline(SELECT_COLOR, SELECT_WIDTH);
} }
public void unSelect(){ public void unSelect() {
if(!selectable) return; if (!selectable) return;
select = false; select = false;
if(highlight) highlight(); if (highlight) highlight();
else deOutline(); else deOutline();
} }
public void setSelectable(boolean selectable){ public void setSelectable(boolean selectable) {
this.selectable = selectable; this.selectable = selectable;
} }

View File

@@ -19,7 +19,8 @@
import com.jme3.texture.Image; import com.jme3.texture.Image;
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
import java.util.*; import java.util.ArrayList;
import java.util.List;
public class CardLayer extends AbstractAppState { public class CardLayer extends AbstractAppState {
@@ -115,7 +116,7 @@ public void update(float tpf) {
} }
public void addSpatial(Spatial card) { public void addSpatial(Spatial card) {
if(root == null) cardBuffer.add(card); if (root == null) cardBuffer.add(card);
else root.attachChild(card); else root.attachChild(card);
} }

View File

@@ -66,7 +66,7 @@ public void rollDice(int rollNum, Runnable actionAfter) {
} }
public void showDice() { public void showDice() {
if(show) return; if (show) return;
show = true; show = true;
cardLayer.addSpatial(diceControl.getSpatial()); cardLayer.addSpatial(diceControl.getSpatial());
diceControl.spin(); diceControl.spin();
@@ -90,11 +90,11 @@ public void addCard(BonusCard card) {
updateCard(); updateCard();
} }
public void removeCard(BonusCard card){ public void removeCard(BonusCard card) {
if(bonusCardControlMap.containsKey(card)){ if (bonusCardControlMap.containsKey(card)) {
bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1); bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1);
if(bonusCardIntegerMap.get(card) <= 0){ if (bonusCardIntegerMap.get(card) <= 0) {
bonusCardIntegerMap.remove(card); bonusCardIntegerMap.remove(card);
cardOrder.remove(card); cardOrder.remove(card);
} }
@@ -113,14 +113,14 @@ public void clearSelectableCards() {
cardSelect = null; cardSelect = null;
} }
private void updateCard(){ private void updateCard() {
for(BonusCard card : bonusCardControlMap.keySet()){ for (BonusCard card : bonusCardControlMap.keySet()) {
CardControl control = bonusCardControlMap.get(card); CardControl control = bonusCardControlMap.get(card);
cardLayer.deleteSpatial(control.getRoot()); cardLayer.deleteSpatial(control.getRoot());
} }
bonusCardControlMap.clear(); bonusCardControlMap.clear();
for(int i = 0; i < cardOrder.size(); i++){ for (int i = 0; i < cardOrder.size(); i++) {
BonusCard card = cardOrder.get(i); BonusCard card = cardOrder.get(i);
CardControl control = createCard(bonusToAsset(card), nextPos(i)); CardControl control = createCard(bonusToAsset(card), nextPos(i));
control.setNumCard(bonusCardIntegerMap.get(card)); control.setNumCard(bonusCardIntegerMap.get(card));
@@ -159,19 +159,19 @@ public Camera getCardLayerCamera() {
return cardLayerCamera; return cardLayerCamera;
} }
public void shield(){ public void shield() {
SymbolControl control = createSymbol(Asset.shieldSymbol); SymbolControl control = createSymbol(Asset.shieldSymbol);
cardLayer.addSpatial(control.getSpatial()); cardLayer.addSpatial(control.getSpatial());
control.shield(); control.shield();
} }
public void swap(){ public void swap() {
SymbolControl control = createSymbol(Asset.swapSymbol); SymbolControl control = createSymbol(Asset.swapSymbol);
cardLayer.addSpatial(control.getSpatial()); cardLayer.addSpatial(control.getSpatial());
control.swap(); control.swap();
} }
public void turbo(){ public void turbo() {
SymbolControl control = createSymbol(Asset.turboSymbol); SymbolControl control = createSymbol(Asset.turboSymbol);
cardLayer.addSpatial(control.getSpatial()); cardLayer.addSpatial(control.getSpatial());
control.turbo(); control.turbo();
@@ -218,7 +218,7 @@ public void test() {
addCard(BonusCard.SWAP); addCard(BonusCard.SWAP);
} }
private CardControl createCard(Asset card, Vector3f pos){ private CardControl createCard(Asset card, Vector3f pos) {
Node rootCard = new Node("Root Card"); Node rootCard = new Node("Root Card");
Spatial spatial = app.getAssetManager().loadModel(card.getModelPath()); Spatial spatial = app.getAssetManager().loadModel(card.getModelPath());
rootCard.attachChild(spatial); rootCard.attachChild(spatial);
@@ -227,26 +227,26 @@ private CardControl createCard(Asset card, Vector3f pos){
spatial.setMaterial(mat); spatial.setMaterial(mat);
spatial.setLocalScale(1f); spatial.setLocalScale(1f);
rootCard.setLocalTranslation(pos); rootCard.setLocalTranslation(pos);
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); spatial.rotate((float) Math.toRadians(90), (float) Math.toRadians(180), (float) Math.toRadians(180));
spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam(), rootCard); CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam(), rootCard);
spatial.addControl(control); spatial.addControl(control);
return control; return control;
} }
private SymbolControl createSymbol(Asset asset){ private SymbolControl createSymbol(Asset asset) {
Spatial spatial = app.getAssetManager().loadModel(asset.getModelPath()); Spatial spatial = app.getAssetManager().loadModel(asset.getModelPath());
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", app.getAssetManager().loadTexture(asset.getDiffPath())); mat.setTexture("ColorMap", app.getAssetManager().loadTexture(asset.getDiffPath()));
spatial.setMaterial(mat); spatial.setMaterial(mat);
spatial.setLocalScale(1f); spatial.setLocalScale(1f);
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); spatial.rotate((float) Math.toRadians(90), (float) Math.toRadians(180), (float) Math.toRadians(180));
SymbolControl control = new SymbolControl(); SymbolControl control = new SymbolControl();
spatial.addControl(control); spatial.addControl(control);
return control; return control;
} }
public CardLayer getCardLayer(){ public CardLayer getCardLayer() {
return cardLayer; return cardLayer;
} }
} }

View File

@@ -13,8 +13,6 @@
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import java.util.Random;
import static com.jme3.material.Materials.LIGHTING; import static com.jme3.material.Materials.LIGHTING;
import static com.jme3.material.Materials.UNSHADED; import static com.jme3.material.Materials.UNSHADED;
@@ -33,7 +31,7 @@ public class DiceControl extends AbstractControl {
private final AssetManager assetManager; private final AssetManager assetManager;
private Runnable actionAfter; private Runnable actionAfter;
public DiceControl(AssetManager assetManager){ public DiceControl(AssetManager assetManager) {
this.assetManager = assetManager; this.assetManager = assetManager;
} }
@@ -42,7 +40,7 @@ public DiceControl(AssetManager assetManager){
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
float clampedTpf = Math.min(tpf, 0.05f); // Max 50 ms per frame float clampedTpf = Math.min(tpf, 0.05f); // Max 50 ms per frame
if (isRolling) { if (isRolling) {
if(!slerp) { if (!slerp) {
// Apply rotational velocity to the dice // Apply rotational velocity to the dice
spinWithAngularVelocity(clampedTpf); spinWithAngularVelocity(clampedTpf);
@@ -55,8 +53,7 @@ protected void controlUpdate(float tpf) {
if (angularVelocity.lengthSquared() <= 3f || MdgaApp.DEBUG_MULTIPLIER == 0) { if (angularVelocity.lengthSquared() <= 3f || MdgaApp.DEBUG_MULTIPLIER == 0) {
slerp = true; slerp = true;
} }
} } else {
else {
timeElapsed += clampedTpf * rollDuration; timeElapsed += clampedTpf * rollDuration;
@@ -72,12 +69,12 @@ protected void controlUpdate(float tpf) {
actionAfter.run(); actionAfter.run();
} }
} }
} else if(spin){ } else if (spin) {
spinWithAngularVelocity(clampedTpf); spinWithAngularVelocity(clampedTpf);
} }
} }
private void spinWithAngularVelocity(float tpf){ private void spinWithAngularVelocity(float tpf) {
Quaternion currentRotation = spatial.getLocalRotation(); Quaternion currentRotation = spatial.getLocalRotation();
Quaternion deltaRotation = new Quaternion(); Quaternion deltaRotation = new Quaternion();
deltaRotation.fromAngles( deltaRotation.fromAngles(
@@ -100,9 +97,9 @@ public void rollDice(int diceNum, Runnable actionAfter) {
timeElapsed = 0; timeElapsed = 0;
this.actionAfter = actionAfter; this.actionAfter = actionAfter;
angularVelocity.set( angularVelocity.set(
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX), FastMath.nextRandomInt(ANGULAR_MIN, ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX), FastMath.nextRandomInt(ANGULAR_MIN, ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX) FastMath.nextRandomInt(ANGULAR_MIN, ANGULAR_MAX)
); );
targetRotation = getRotationForDiceNum(diceNum); targetRotation = getRotationForDiceNum(diceNum);
@@ -136,38 +133,37 @@ public void randomRotation() {
spatial.setLocalRotation(randomRotation); spatial.setLocalRotation(randomRotation);
} }
public void spin(){ public void spin() {
angularVelocity.set(ANGULAR_SPIN,ANGULAR_SPIN,ANGULAR_SPIN); angularVelocity.set(ANGULAR_SPIN, ANGULAR_SPIN, ANGULAR_SPIN);
spin = true; spin = true;
} }
public void hide(){ public void hide() {
spatial.removeFromParent(); spatial.removeFromParent();
spin = false; spin = false;
isRolling = false; isRolling = false;
slerp = false; slerp = false;
} }
public void create(Vector3f pos, float scale, boolean shadow){ public void create(Vector3f pos, float scale, boolean shadow) {
Spatial spatial = assetManager.loadModel(Asset.dice.getModelPath()); Spatial spatial = assetManager.loadModel(Asset.dice.getModelPath());
Material mat; Material mat;
if(shadow){ if (shadow) {
mat = new Material(assetManager, LIGHTING); mat = new Material(assetManager, LIGHTING);
mat.setTexture("DiffuseMap", assetManager.loadTexture(Asset.dice.getDiffPath())); mat.setTexture("DiffuseMap", assetManager.loadTexture(Asset.dice.getDiffPath()));
spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
} } else {
else{
mat = new Material(assetManager, UNSHADED); mat = new Material(assetManager, UNSHADED);
mat.setTexture("ColorMap", assetManager.loadTexture(Asset.dice.getDiffPath())); mat.setTexture("ColorMap", assetManager.loadTexture(Asset.dice.getDiffPath()));
} }
spatial.setMaterial(mat); spatial.setMaterial(mat);
spatial.setLocalScale(scale); spatial.setLocalScale(scale);
spatial.setLocalTranslation(pos); spatial.setLocalTranslation(pos);
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); spatial.rotate((float) Math.toRadians(90), (float) Math.toRadians(180), (float) Math.toRadians(180));
spatial.addControl(this); spatial.addControl(this);
} }
public void setPos(Vector3f pos){ public void setPos(Vector3f pos) {
spatial.setLocalTranslation(pos); spatial.setLocalTranslation(pos);
} }

View File

@@ -6,8 +6,8 @@
import com.jme3.texture.Image; import com.jme3.texture.Image;
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.game.Color;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import java.util.List; import java.util.List;
@@ -47,8 +47,8 @@ public void shutdown() {
} }
public void rollDice(int rollNum, int mult) { public void rollDice(int rollNum, int mult) {
cardLayerHandler.rollDice(rollNum, ()->{ cardLayerHandler.rollDice(rollNum, () -> {
if(mult == -1) actionTextHandler.ownDice(rollNum); if (mult == -1) actionTextHandler.ownDice(rollNum);
else actionTextHandler.ownDiceMult(rollNum, mult); else actionTextHandler.ownDiceMult(rollNum, mult);
hideDice(); hideDice();
app.getModelSynchronize().animationEnd(); app.getModelSynchronize().animationEnd();
@@ -58,7 +58,7 @@ public void rollDice(int rollNum, int mult) {
public void showRolledDiceMult(int rollNum, int mult, Color color) { public void showRolledDiceMult(int rollNum, int mult, Color color) {
String name = playerNameHandler.getName(color); String name = playerNameHandler.getName(color);
if(mult == -1) actionTextHandler.diceNum(rollNum, name, color); if (mult == -1) actionTextHandler.diceNum(rollNum, name, color);
else actionTextHandler.diceNumMult(rollNum, mult, name, color); else actionTextHandler.diceNumMult(rollNum, mult, name, color);
} }
@@ -82,7 +82,7 @@ public void addCardOwn(BonusCard card) {
actionTextHandler.drawCardOwn(ownColor); actionTextHandler.drawCardOwn(ownColor);
} }
public void playCardOwn(BonusCard card){ public void playCardOwn(BonusCard card) {
getEffectByCard(card); getEffectByCard(card);
cardLayerHandler.removeCard(card); cardLayerHandler.removeCard(card);
playerNameHandler.removeCard(ownColor); playerNameHandler.removeCard(ownColor);
@@ -93,8 +93,8 @@ public void playCardEnemy(Color color, BonusCard card) {
playerNameHandler.removeCard(color); playerNameHandler.removeCard(color);
} }
private void getEffectByCard(BonusCard bonus){ private void getEffectByCard(BonusCard bonus) {
switch(bonus){ switch (bonus) {
case SWAP -> swap(); case SWAP -> swap();
case TURBO -> turbo(); case TURBO -> turbo();
case SHIELD -> shield(); case SHIELD -> shield();
@@ -118,7 +118,7 @@ public Camera getCardLayerCamera() {
return cardLayerHandler.getCardLayerCamera(); return cardLayerHandler.getCardLayerCamera();
} }
public Node getCardLayerRootNode(){ public Node getCardLayerRootNode() {
return cardLayerHandler.getCardLayer().getRootNode(); return cardLayerHandler.getCardLayer().getRootNode();
} }
@@ -133,19 +133,19 @@ public void setActivePlayer(Color color) {
else actionTextHandler.activePlayer(playerNameHandler.getName(color), color); else actionTextHandler.activePlayer(playerNameHandler.getName(color), color);
} }
public void shield(){ public void shield() {
cardLayerHandler.shield(); cardLayerHandler.shield();
} }
public void swap(){ public void swap() {
cardLayerHandler.swap(); cardLayerHandler.swap();
} }
public void turbo(){ public void turbo() {
cardLayerHandler.turbo(); cardLayerHandler.turbo();
} }
public void hideText(){ public void hideText() {
actionTextHandler.hide(); actionTextHandler.hide();
} }
@@ -156,17 +156,15 @@ public void drawCard(Color color) {
playerNameHandler.addCard(color); playerNameHandler.addCard(color);
} }
public void finish(Color color){ public void finish(Color color) {
if(ownColor == color) actionTextHandler.finishTextOwn(color); if (ownColor == color) actionTextHandler.finishTextOwn(color);
else actionTextHandler.finishText(playerNameHandler.getName(color), color); else actionTextHandler.finishText(playerNameHandler.getName(color), color);
} }
public void rollRankingResult(Color color, int eye){ public void rollRankingResult(Color color, int eye) {
if(ownColor == color) actionTextHandler.rollRankingResultOwn(color, eye); if (ownColor == color) actionTextHandler.rollRankingResultOwn(color, eye);
else actionTextHandler.rollRankingResult(playerNameHandler.getName(color), color, eye); else actionTextHandler.rollRankingResult(playerNameHandler.getName(color), color, eye);
} }
} }

View File

@@ -4,19 +4,16 @@
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;
@@ -40,7 +37,7 @@ public class PlayerNameHandler {
private final Node guiNode; private final Node guiNode;
public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){ public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings) {
this.guiNode = guiNode; this.guiNode = guiNode;
playerFont = assetManager.loadFont("Fonts/Gunplay.fnt"); playerFont = assetManager.loadFont("Fonts/Gunplay.fnt");
@@ -60,35 +57,35 @@ public void hide() {
guiNode.detachChild(playerNameNode); guiNode.detachChild(playerNameNode);
} }
private void drawPlayers(){ private void drawPlayers() {
playerNameNode.detachAllChildren(); playerNameNode.detachAllChildren();
for(int i = 0; i < playerOrder.size(); i++) { for (int i = 0; i < playerOrder.size(); i++) {
Color color = playerOrder.get(i); Color color = playerOrder.get(i);
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(createColor(color)); nameParent.attachChild(createColor(color));
BitmapText name = createName(colorNameMap.get(color), i == 0, color == ownColor); BitmapText name = createName(colorNameMap.get(color), i == 0, color == ownColor);
nameParent.attachChild(name); nameParent.attachChild(name);
if(colorCardMap.getOrDefault(color, 0) > 0){ if (colorCardMap.getOrDefault(color, 0) > 0) {
Picture pic = createHandCard(name.getLineWidth()); Picture pic = createHandCard(name.getLineWidth());
nameParent.attachChild(pic); nameParent.attachChild(pic);
nameParent.attachChild(createCardNum(colorCardMap.get(color), pic.getWidth(), pic.getLocalTranslation().getX())); 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 ) { private Spatial createCardNum(int num, float lastWidth, float lastX) {
BitmapText hudText = new BitmapText(playerFont); BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45 //renderedSize = 45
hudText.setSize(TEXT_SIZE); hudText.setSize(TEXT_SIZE);
hudText.setColor(NORMAL_COLOR); hudText.setColor(NORMAL_COLOR);
hudText.setText(String.valueOf(num)); hudText.setText(String.valueOf(num));
hudText.setLocalTranslation(lastX + lastWidth + 20,hudText.getHeight()/2, 0); hudText.setLocalTranslation(lastX + lastWidth + 20, hudText.getHeight() / 2, 0);
return hudText; return hudText;
} }
@@ -97,17 +94,17 @@ private Picture createHandCard(float width) {
pic.setImage(assetManager, "./Images/handcard.png", true); pic.setImage(assetManager, "./Images/handcard.png", true);
pic.setWidth(IMAGE_SIZE); pic.setWidth(IMAGE_SIZE);
pic.setHeight(IMAGE_SIZE); pic.setHeight(IMAGE_SIZE);
pic.setPosition(-pic.getWidth()/2 + width + PADDING_LEFT * 2 ,-pic.getHeight()/2); pic.setPosition(-pic.getWidth() / 2 + width + PADDING_LEFT * 2, -pic.getHeight() / 2);
return pic; 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) {
case ARMY -> root+"HEER_IMAGE.png"; case ARMY -> root + "HEER_IMAGE.png";
case NAVY -> root+"MARINE_IMAGE.png"; case NAVY -> root + "MARINE_IMAGE.png";
case CYBER -> root+"CIR_IMAGE.png"; case CYBER -> root + "CIR_IMAGE.png";
case AIRFORCE -> root+"LW_IMAGE.png"; case AIRFORCE -> root + "LW_IMAGE.png";
default -> throw new RuntimeException("None is not valid"); default -> throw new RuntimeException("None is not valid");
}; };
} }
@@ -117,31 +114,30 @@ private Spatial createColor(Color color) {
pic.setImage(assetManager, imagePath(color), true); pic.setImage(assetManager, imagePath(color), true);
pic.setWidth(IMAGE_SIZE); pic.setWidth(IMAGE_SIZE);
pic.setHeight(IMAGE_SIZE); pic.setHeight(IMAGE_SIZE);
pic.setPosition(-pic.getWidth()/2,-pic.getHeight()/2); pic.setPosition(-pic.getWidth() / 2, -pic.getHeight() / 2);
return pic; return pic;
} }
private BitmapText createName(String name, boolean first, boolean own) {
private BitmapText 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);
hudText.setColor(first ? ACTIVE_COLOR : own ? OWN_COLOR : NORMAL_COLOR); hudText.setColor(first ? ACTIVE_COLOR : own ? OWN_COLOR : NORMAL_COLOR);
hudText.setText(own ? name + " (Du)" : name); hudText.setText(own ? name + " (Du)" : name);
hudText.setLocalTranslation(PADDING_LEFT,hudText.getHeight()/2, 0); hudText.setLocalTranslation(PADDING_LEFT, hudText.getHeight() / 2, 0);
return hudText; return hudText;
} }
public void addPlayer(Color color, String name, boolean own){ public void addPlayer(Color color, String name, boolean own) {
if(own) ownColor = color; if (own) ownColor = color;
colorNameMap.put(color, name); colorNameMap.put(color, name);
playerOrder.add(color); playerOrder.add(color);
drawPlayers(); drawPlayers();
} }
public void setActivePlayer(Color color) { public void setActivePlayer(Color color) {
if(playerOrder.get(0) == color) return; if (playerOrder.get(0) == color) return;
Color oldFirst = playerOrder.remove(0); Color oldFirst = playerOrder.remove(0);
playerOrder.remove(color); playerOrder.remove(color);
playerOrder.add(0, color); playerOrder.add(0, color);
@@ -150,20 +146,20 @@ public void setActivePlayer(Color color) {
drawPlayers(); drawPlayers();
} }
public String getName(Color color){ public String getName(Color color) {
if(!colorNameMap.containsKey(color)) throw new RuntimeException("color is not in colorNameMap"); if (!colorNameMap.containsKey(color)) throw new RuntimeException("color is not in colorNameMap");
return colorNameMap.get(color); return colorNameMap.get(color);
} }
public void addCard(Color color){ public void addCard(Color color) {
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) + 1); colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) + 1);
drawPlayers(); drawPlayers();
} }
public void removeCard(Color color){ public void removeCard(Color color) {
if(colorCardMap.containsKey(color)){ if (colorCardMap.containsKey(color)) {
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) - 1); colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) - 1);
if(colorCardMap.get(color) <= 0) colorCardMap.remove(color); if (colorCardMap.get(color) <= 0) colorCardMap.remove(color);
} }
drawPlayers(); drawPlayers();
} }

View File

@@ -3,7 +3,6 @@
import com.jme3.asset.AssetManager; import com.jme3.asset.AssetManager;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.FXAAFilter;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
@@ -19,7 +18,7 @@ public class SelectObjectOutliner {
private final int width; private final int width;
private boolean selected; private boolean selected;
private ViewPort outlineViewport = null; private ViewPort outlineViewport = null;
// private OutlineFilter outlineFilter = null; // private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null; private OutlineProFilter outlineFilter = null;
private final MdgaApp app; private final MdgaApp app;
@@ -34,21 +33,21 @@ public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager re
} }
public void deselect(Spatial model) { public void deselect(Spatial model) {
if(selected){ if (selected) {
selected = false; selected = false;
hideOutlineFilterEffect(model); hideOutlineFilterEffect(model);
} }
} }
public void select(Spatial model, ColorRGBA color) { public void select(Spatial model, ColorRGBA color) {
if(!selected){ if (!selected) {
selected = true; selected = true;
showOutlineFilterEffect(model, width, color); showOutlineFilterEffect(model, width, color);
} }
} }
public void select(Spatial model, ColorRGBA color, int width) { public void select(Spatial model, ColorRGBA color, int width) {
if(!selected){ if (!selected) {
selected = true; selected = true;
showOutlineFilterEffect(model, width, color); showOutlineFilterEffect(model, width, color);
} }

View File

@@ -283,11 +283,10 @@ public void send(int id, ServerMessage message) {
return; return;
} }
final HostedConnection connection = myServer.getConnection(id); final HostedConnection connection = myServer.getConnection(id);
if (connection != null){ if (connection != null) {
System.out.println("server sends to: " + id + " " + message.getClass().getName()); System.out.println("server sends to: " + id + " " + message.getClass().getName());
connection.send(message); connection.send(message);
} } else LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
else LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
} }
/** /**

View File

@@ -1,32 +1,29 @@
package pp.mdga.client.server; package pp.mdga.client.server;
import com.jme3.network.serializing.Serializer;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.UUID; import java.util.UUID;
import com.jme3.network.serializing.Serializer; public class UUIDSerializer extends Serializer {
public class UUIDSerializer extends Serializer
{
@Override @Override
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
{
byte[] uuid = new byte[36]; byte[] uuid = new byte[36];
data.get(uuid); data.get(uuid);
if(uuid.equals(new UUID(1, 1))) { if (uuid.equals(new UUID(1, 1))) {
return null; return null;
} else { } else {
return (T) UUID.fromString(new String(uuid)); return (T) UUID.fromString(new String(uuid));
} }
} }
@Override @Override
public void writeObject(ByteBuffer buffer, Object object) throws IOException public void writeObject(ByteBuffer buffer, Object object) throws IOException {
{
UUID uuid = (UUID) object; UUID uuid = (UUID) object;
if(uuid != null) { if (uuid != null) {
buffer.put(uuid.toString().getBytes()); buffer.put(uuid.toString().getBytes());
} else { } else {
buffer.put(new UUID(1, 1).toString().getBytes()); buffer.put(new UUID(1, 1).toString().getBytes());

View File

@@ -103,7 +103,7 @@ public void onLeave() {
backButton.hide(); backButton.hide();
continueButton.hide(); continueButton.hide();
if(null != background) { if (null != background) {
guiNode.detachChild(background); guiNode.detachChild(background);
} }
@@ -118,7 +118,7 @@ public void onLeave() {
@Override @Override
protected void onEnterOverlay(Overlay overlay) { protected void onEnterOverlay(Overlay overlay) {
if(rootNode.hasChild(podest)) { if (rootNode.hasChild(podest)) {
rootNode.detachChild(podest); rootNode.detachChild(podest);
} }
} }
@@ -157,7 +157,7 @@ private void statistics() {
private void enterSub(SubState state) { private void enterSub(SubState state) {
this.state = state; this.state = state;
if(rootNode.hasChild(podest)) { if (rootNode.hasChild(podest)) {
rootNode.detachChild(podest); rootNode.detachChild(podest);
} }
@@ -205,7 +205,7 @@ 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.hide();
button.show(); button.show();
} }

View File

@@ -2,10 +2,10 @@
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
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.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.dialog.InterruptDialog;
@@ -84,14 +84,14 @@ public void onUpdate(float tpf) {
@Override @Override
protected void onEnterOverlay(Overlay overlay) { protected void onEnterOverlay(Overlay overlay) {
if(overlay == Overlay.SETTINGS) { if (overlay == Overlay.SETTINGS) {
leaveButton.show(); leaveButton.show();
} }
} }
@Override @Override
protected void onLeaveOverlay(Overlay overlay) { protected void onLeaveOverlay(Overlay overlay) {
if(overlay == Overlay.SETTINGS) { if (overlay == Overlay.SETTINGS) {
leaveButton.hide(); leaveButton.hide();
} }
} }

View File

@@ -5,21 +5,15 @@
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound; import pp.mdga.client.acoustic.MdgaSound;
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.LobbyButton; import pp.mdga.client.button.LobbyButton;
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;
public class LobbyView extends MdgaView { public class LobbyView extends MdgaView {
private Geometry background; private Geometry background;
@@ -64,7 +58,7 @@ public void onEnter() {
leaveButton.show(); leaveButton.show();
readyButton.show(); readyButton.show();
if(app.getGameLogic().isHost()) { if (app.getGameLogic().isHost()) {
startButton.show(); startButton.show();
} }
@@ -150,23 +144,22 @@ protected void onEnterOverlay(Overlay overlay) {
} }
@Override @Override
protected void onLeaveOverlay(Overlay overlay) protected void onLeaveOverlay(Overlay overlay) {
{
} }
public void setTaken(Color color, boolean isTaken, boolean isSelf, String name) { public void setTaken(Color color, boolean isTaken, boolean isSelf, String name) {
LobbyButton.Taken taken; LobbyButton.Taken taken;
if(isTaken) { if (isTaken) {
if(isSelf) { if (isSelf) {
own = color; own = color;
taken = LobbyButton.Taken.SELF; taken = LobbyButton.Taken.SELF;
} else { } else {
taken = LobbyButton.Taken.OTHER; taken = LobbyButton.Taken.OTHER;
} }
} else { } else {
if(isSelf) { if (isSelf) {
own = null; own = null;
} }
@@ -204,10 +197,10 @@ public void setReady(Color color, boolean isReady) {
this.isReady = isReady; this.isReady = isReady;
} }
if(!isReady) { if (!isReady) {
app.getAcousticHandler().playSound(MdgaSound.NOT_READY); app.getAcousticHandler().playSound(MdgaSound.NOT_READY);
} else { } else {
if(button.getTaken() != LobbyButton.Taken.SELF) { if (button.getTaken() != LobbyButton.Taken.SELF) {
app.getAcousticHandler().playSound(MdgaSound.OTHER_READY); app.getAcousticHandler().playSound(MdgaSound.OTHER_READY);
} }
} }
@@ -231,7 +224,7 @@ private void toggleTsk(Color color) {
break; break;
} }
if(isReady) { if (isReady) {
setReady(own, false); setReady(own, false);
} }
@@ -249,12 +242,12 @@ private void toggleTsk(Color color) {
} }
public void ready() { public void ready() {
if(own == null) { if (own == null) {
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return; return;
} }
if(!isReady) { if (!isReady) {
app.getAcousticHandler().playSound(MdgaSound.SELF_READY); app.getAcousticHandler().playSound(MdgaSound.SELF_READY);
} }

View File

@@ -98,7 +98,7 @@ private void tryHost() {
try { try {
port = Integer.parseInt(text); port = Integer.parseInt(text);
if(port >= 1 && port <= 65535) { if (port >= 1 && port <= 65535) {
app.getModelSynchronize().setName(startDialog.getName()); app.getModelSynchronize().setName(startDialog.getName());
hostDialog.hostServer(); hostDialog.hostServer();
try { try {
@@ -159,7 +159,7 @@ private boolean isValidIpAddress(String ip) {
private void enterSub(SubState state) { private void enterSub(SubState state) {
this.state = state; this.state = state;
if(null != background) { if (null != background) {
rootNode.detachChild(background); rootNode.detachChild(background);
} }
@@ -198,7 +198,7 @@ public void forward(boolean host) {
tryJoin(); tryJoin();
break; break;
case MAIN: case MAIN:
if(host) { if (host) {
enterSub(SubState.HOST); enterSub(SubState.HOST);
//TODO playSound //TODO playSound
} else { } else {

View File

@@ -11,7 +11,9 @@
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;
import pp.mdga.client.button.*; import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.SettingsButton;
import pp.mdga.client.dialog.AudioSettingsDialog; import pp.mdga.client.dialog.AudioSettingsDialog;
import pp.mdga.client.dialog.SettingsDialog; import pp.mdga.client.dialog.SettingsDialog;
import pp.mdga.client.dialog.VideoSettingsDialog; import pp.mdga.client.dialog.VideoSettingsDialog;
@@ -196,9 +198,9 @@ public void pressForward() {
} }
if (this instanceof GameView gameView) { if (this instanceof GameView gameView) {
if(gameView.needConfirm) { if (gameView.needConfirm) {
app.getModelSynchronize().confirm(); app.getModelSynchronize().confirm();
} else if(gameView.needNoPower) { } else if (gameView.needNoPower) {
app.getModelSynchronize().confirm(); app.getModelSynchronize().confirm();
} else { } else {
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
@@ -213,7 +215,7 @@ public void pressForward() {
public void showInfo(String error, boolean isError) { public void showInfo(String error, boolean isError) {
infoTimer.reset(); infoTimer.reset();
if(null != infoLabel) { if (null != infoLabel) {
infoLabel.hide(); infoLabel.hide();
} }
@@ -221,7 +223,7 @@ public void showInfo(String error, boolean isError) {
ColorRGBA color; ColorRGBA color;
if(isError) { if (isError) {
color = ColorRGBA.Red.clone(); color = ColorRGBA.Red.clone();
} else { } else {
color = ColorRGBA.Green.clone(); color = ColorRGBA.Green.clone();

View File

@@ -42,8 +42,8 @@ public void exit() {
* *
* @param state the state to be set * @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();
} }
state.enter(); state.enter();
@@ -55,7 +55,7 @@ public void setState(CeremonyStates state){
* *
* @return the PodiumState * @return the PodiumState
*/ */
public PodiumState getPodiumState(){ public PodiumState getPodiumState() {
return podiumState; return podiumState;
} }
@@ -64,7 +64,7 @@ public PodiumState getPodiumState(){
* *
* @return the StatisticsState * @return the StatisticsState
*/ */
public StatisticsState getStatisticsState(){ public StatisticsState getStatisticsState() {
return statisticsState; return statisticsState;
} }
@@ -73,16 +73,15 @@ public StatisticsState getStatisticsState(){
* *
* @return the current State * @return the current State
*/ */
public CeremonyStates getState(){ public CeremonyStates getState() {
return currentState; return currentState;
} }
/** /**
* this method is used to parse the selectNext from the clientGameLogic * this method is used to parse the selectNext from the clientGameLogic
*
*/ */
@Override @Override
public void selectNext(){ public void selectNext() {
currentState.selectNext(); currentState.selectNext();
} }
} }

View File

@@ -4,7 +4,6 @@
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.CeremonyNotification;
import java.lang.System.Logger.Level; import java.lang.System.Logger.Level;
@@ -15,7 +14,7 @@ public abstract class ClientState implements Observer, ServerInterpreter {
protected ClientGameLogic logic; protected ClientGameLogic logic;
protected ClientState(ClientState parent, ClientGameLogic logic){ protected ClientState(ClientState parent, ClientGameLogic logic) {
this.parent = parent; this.parent = parent;
this.logic = logic; this.logic = logic;
} }
@@ -24,14 +23,14 @@ protected ClientState(ClientState parent, ClientGameLogic logic){
public abstract void exit(); public abstract void exit();
public ClientState getParent(){ public ClientState getParent() {
return parent; return parent;
} }
public void update() {/* do nothing */} public void update() {/* do nothing */}
@Override @Override
public String toString(){ public String toString() {
return getClass().getSimpleName(); return getClass().getSimpleName();
} }
@@ -101,7 +100,7 @@ public void received(ChoosePieceStateMessage msg) {
} }
@Override @Override
public void received(DrawCardMessage msg){ public void received(DrawCardMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString()); LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
} }
@@ -161,7 +160,9 @@ public void received(ServerStartGameMessage 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.toString());
}
@Override @Override
public void received(StartPieceMessage msg) { public void received(StartPieceMessage msg) {
@@ -238,23 +239,23 @@ public void deselectTSK(Color color) {
LOGGER.log(Level.DEBUG, "Deselecting TSK not allowed."); LOGGER.log(Level.DEBUG, "Deselecting TSK not allowed.");
} }
public void selectUnready(){ public void selectUnready() {
LOGGER.log(Level.DEBUG, "Selecting unready not allowed."); LOGGER.log(Level.DEBUG, "Selecting unready not allowed.");
} }
public void selectStart(){ public void selectStart() {
LOGGER.log(Level.DEBUG, "Starting not allowed"); LOGGER.log(Level.DEBUG, "Starting not allowed");
} }
public void selectAnimationEnd(){ public void selectAnimationEnd() {
LOGGER.log(Level.DEBUG, "Animation end not allowed"); LOGGER.log(Level.DEBUG, "Animation end not allowed");
} }
public void selectNext(){ public void selectNext() {
LOGGER.log(Level.DEBUG, "Next not allowed"); LOGGER.log(Level.DEBUG, "Next not allowed");
} }
public void selectResume(){ public void selectResume() {
LOGGER.log(Level.DEBUG, "Resume not allowed"); LOGGER.log(Level.DEBUG, "Resume not allowed");
} }
} }

View File

@@ -29,7 +29,7 @@ public DialogsState(ClientState parent, ClientGameLogic logic) {
* exits this state * exits this state
*/ */
@Override @Override
public void exit(){ public void exit() {
currentState.exit(); currentState.exit();
} }
@@ -37,7 +37,7 @@ public void exit(){
* Enters the new state machine * Enters the new state machine
*/ */
@Override @Override
public void enter(){ public void enter() {
setState(startDialogState); setState(startDialogState);
} }
@@ -46,8 +46,8 @@ public void enter(){
* *
* @param newState the state to be set * @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();
} }
newState.enter(); newState.enter();
@@ -85,7 +85,7 @@ public StartDialogState getStartDialog() {
* This method is used to call the selectLeave method of the current state * 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();
} }
@@ -95,7 +95,7 @@ public void selectLeave(){
* @param name the name to be set * @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);
} }
@@ -105,7 +105,7 @@ public void setName(String name){
* @param color the color to be set * @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);
} }
@@ -115,7 +115,7 @@ public void selectTSK(Color color){
* @param color the color to be deselected * @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);
} }
@@ -123,7 +123,7 @@ public void deselectTSK(Color color){
* This method is used to call the selectReady method of the current state * 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();
} }
@@ -131,7 +131,7 @@ public void selectReady(){
* This method is used to call the selectUnready method of the current state * 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();
} }
@@ -139,7 +139,7 @@ public void selectUnready(){
* This method is used to call the selectStart method of the current state * 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();
} }
@@ -149,7 +149,7 @@ public void selectStart(){
* @param string the string to be set * @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);
} }
@@ -159,7 +159,7 @@ public void selectJoin(String string){
* @param name the name to be set * @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);
} }
@@ -169,7 +169,7 @@ public void selectHost(String name){
* @param msg the LobbyPlayerJoin message received * @param msg the LobbyPlayerJoin message received
*/ */
@Override @Override
public void received(LobbyPlayerJoinedMessage msg){ public void received(LobbyPlayerJoinedMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@@ -179,7 +179,7 @@ public void received(LobbyPlayerJoinedMessage msg){
* @param msg the LobbyPlayerLeave message received * @param msg the LobbyPlayerLeave message received
*/ */
@Override @Override
public void received(LobbyPlayerLeaveMessage msg){ public void received(LobbyPlayerLeaveMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@@ -189,7 +189,7 @@ public void received(LobbyPlayerLeaveMessage msg){
* @param msg the UpdateTSKMessage message received * @param msg the UpdateTSKMessage message received
*/ */
@Override @Override
public void received(UpdateTSKMessage msg){ public void received(UpdateTSKMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@@ -199,7 +199,7 @@ public void received(UpdateTSKMessage msg){
* @param msg the UpdateReady message received * @param msg the UpdateReady message received
*/ */
@Override @Override
public void received(UpdateReadyMessage msg){ public void received(UpdateReadyMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@@ -209,7 +209,7 @@ public void received(UpdateReadyMessage msg){
* @param msg the ServerStartGame message received * @param msg the ServerStartGame message received
*/ */
@Override @Override
public void received(ServerStartGameMessage msg){ public void received(ServerStartGameMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@@ -219,7 +219,7 @@ public void received(ServerStartGameMessage msg){
* @param msg the LobbyAccept message received * @param msg the LobbyAccept message received
*/ */
@Override @Override
public void received(LobbyAcceptMessage msg){ public void received(LobbyAcceptMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@@ -229,7 +229,7 @@ public void received(LobbyAcceptMessage msg){
* @param msg the LobbyDeny message received * @param msg the LobbyDeny message received
*/ */
@Override @Override
public void received(LobbyDenyMessage msg){ public void received(LobbyDenyMessage msg) {
currentState.received(msg); currentState.received(msg);
} }

View File

@@ -4,16 +4,9 @@
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.card.HiddenCard; import pp.mdga.game.card.HiddenCard;
import pp.mdga.game.card.ShieldCard;
import pp.mdga.game.card.SwapCard;
import pp.mdga.game.card.TurboCard;
import pp.mdga.message.client.LeaveGameMessage; import pp.mdga.message.client.LeaveGameMessage;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.AcquireCardNotification; import pp.mdga.notification.*;
import pp.mdga.notification.CeremonyNotification;
import pp.mdga.notification.DrawCardNotification;
import pp.mdga.notification.InterruptNotification;
import pp.mdga.notification.StartDialogNotification;
public class GameState extends ClientState { public class GameState extends ClientState {
@@ -59,8 +52,8 @@ public void exit() {
* *
* @param newState the state to be set * @param newState the state to be set
*/ */
public void setState(GameStates newState){ public void setState(GameStates newState) {
if(this.state != null){ if (this.state != null) {
this.state.exit(); this.state.exit();
} }
System.out.println("CLIENT STATE old: " + this.state + " new: " + newState); System.out.println("CLIENT STATE old: " + this.state + " new: " + newState);
@@ -72,7 +65,7 @@ public void setState(GameStates newState){
* This method is used to call the selectAnimationEnd method of the current state * 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();
} }
@@ -80,7 +73,7 @@ public void selectAnimationEnd(){
* This method is used to call the selectDice method of the current state * 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();
} }
@@ -90,7 +83,7 @@ public void selectDice(){
* @param piece the piece to be selected * @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);
} }
@@ -100,7 +93,7 @@ public void selectPiece(Piece piece){
* @param card the card to be selected * @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);
} }
@@ -110,13 +103,13 @@ public void selectCard(BonusCard card){
* @param msg the message to be received * @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 @Override
public void selectLeave(){ public void selectLeave() {
logic.send(new LeaveGameMessage()); logic.send(new LeaveGameMessage());
logic.addNotification(new StartDialogNotification()); logic.addNotification(new StartDialogNotification());
logic.setState(logic.getDialogs()); logic.setState(logic.getDialogs());
@@ -128,7 +121,7 @@ public void selectLeave(){
* @param msg the message to be received * @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);
} }
@@ -138,7 +131,7 @@ public void received(DieMessage msg){
* @param msg the message to be received * @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);
} }
@@ -148,7 +141,7 @@ public void received(RankingRollAgainMessage msg){
* @param msg the message to be received * @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);
} }
@@ -158,7 +151,7 @@ public void received(RankingResponseMessage msg){
* @param msg the message to be received * @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);
} }
@@ -168,7 +161,7 @@ public void received(SelectPieceMessage msg){
* @param msg the message to be received * @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);
} }
@@ -178,7 +171,7 @@ public void received(WaitPieceMessage msg){
* @param msg the message to be received * @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);
} }
@@ -188,7 +181,7 @@ public void received(StartPieceMessage msg){
* @param msg the message to be received * @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);
} }
@@ -198,7 +191,7 @@ public void received(NoTurnMessage msg){
* @param msg the message to be received * @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);
} }
@@ -208,7 +201,7 @@ public void received(MoveMessage msg){
* @param msg the message to be received * @param msg the message to be received
*/ */
@Override @Override
public void received(CeremonyMessage msg){ public void received(CeremonyMessage msg) {
CeremonyNotification notification = new CeremonyNotification(); CeremonyNotification notification = new CeremonyNotification();
notification.setColors(msg.getColors()); notification.setColors(msg.getColors());
notification.setNames(msg.getNames()); notification.setNames(msg.getNames());
@@ -228,7 +221,7 @@ public void received(CeremonyMessage msg){
* @param msg the message to be received * @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);
} }
@@ -238,7 +231,7 @@ public void received(EndOfTurnMessage msg){
* @param msg the message to be received * @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);
} }
@@ -248,7 +241,7 @@ public void received(SpectatorMessage msg){
* @param msg the message to be received * @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);
} }
@@ -258,7 +251,7 @@ public void received(DiceAgainMessage msg){
* @param msg the message to be received * @param msg the message to be received
*/ */
@Override @Override
public void received(PossibleCardsMessage msg){ public void received(PossibleCardsMessage msg) {
state.received(msg); state.received(msg);
} }
@@ -268,7 +261,7 @@ public void received(PossibleCardsMessage msg){
* @param msg the message to be received * @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);
} }
@@ -278,7 +271,7 @@ public void received(PlayCardMessage msg){
* @param msg the message to be received * @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);
} }
@@ -288,27 +281,26 @@ public void received(DiceNowMessage msg){
* @param msg the message to be received * @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);
} }
@Override @Override
public void received(PossiblePieceMessage msg){ public void received(PossiblePieceMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(ChoosePieceStateMessage msg){ public void received(ChoosePieceStateMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(DrawCardMessage msg){ public void received(DrawCardMessage msg) {
logic.getGame().getActivePlayer().addHandCard(msg.getCard()); logic.getGame().getActivePlayer().addHandCard(msg.getCard());
if (msg.getCard() instanceof HiddenCard) { if (msg.getCard() instanceof HiddenCard) {
logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN)); logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN));
} } else {
else{
logic.addNotification(new AcquireCardNotification(msg.getCard().getCard())); logic.addNotification(new AcquireCardNotification(msg.getCard().getCard()));
} }
@@ -319,7 +311,7 @@ public void received(DrawCardMessage msg){
* *
* @return the current state * @return the current state
*/ */
public GameStates getState(){ public GameStates getState() {
return state; return state;
} }

View File

@@ -2,7 +2,6 @@
import pp.mdga.message.client.ForceContinueGameMessage; import pp.mdga.message.client.ForceContinueGameMessage;
import pp.mdga.message.server.ResumeGameMessage; import pp.mdga.message.server.ResumeGameMessage;
import pp.mdga.notification.ResumeNotification;
public class InterruptState extends ClientState { public class InterruptState extends ClientState {
@@ -56,8 +55,8 @@ public ClientState getPreviousState() {
* The host resumes the game * The host resumes the game
*/ */
@Override @Override
public void selectResume(){ public void selectResume() {
if(logic.isHost()){ if (logic.isHost()) {
logic.send(new ForceContinueGameMessage()); logic.send(new ForceContinueGameMessage());
} }
} }

View File

@@ -45,28 +45,28 @@ public void exit() {
/** /**
* Changes the current state * Changes the current state
*/ */
public SettingStates getState(){ public SettingStates getState() {
return currentState; return currentState;
} }
/** /**
* Returns the main settings state * Returns the main settings state
*/ */
public MainSettingsState getMainSettingsState(){ public MainSettingsState getMainSettingsState() {
return mainSettingsState; return mainSettingsState;
} }
/** /**
* Returns the audio settings state * Returns the audio settings state
*/ */
public AudioSettingsState getAudioSettingsState(){ public AudioSettingsState getAudioSettingsState() {
return audioSettingsState; return audioSettingsState;
} }
/** /**
* Returns the video settings state * Returns the video settings state
*/ */
public VideoSettingsState getVideoSettingsState(){ public VideoSettingsState getVideoSettingsState() {
return videoSettingsState; return videoSettingsState;
} }
} }

View File

@@ -24,7 +24,7 @@ public void exit() {
} }
@Override @Override
public void selectNext(){ public void selectNext() {
parent.setState(parent.getStatisticsState()); parent.setState(parent.getStatisticsState());
} }
} }

View File

@@ -19,7 +19,7 @@ public void exit() {
} }
@Override @Override
public void selectNext(){ public void selectNext() {
logic.setState(logic.getDialogs()); logic.setState(logic.getDialogs());
} }
} }

View File

@@ -5,7 +5,7 @@
public abstract class DialogStates extends ClientState { public abstract class DialogStates extends ClientState {
public DialogStates(ClientState parent, ClientGameLogic logic){ public DialogStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
} }

View File

@@ -72,8 +72,8 @@ public void selectStart() {
@Override @Override
public void received(ServerStartGameMessage msg) { public void received(ServerStartGameMessage msg) {
for (Player player: msg.getPlayers()) { for (Player player : msg.getPlayers()) {
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) { for (Map.Entry<Integer, Player> entry : this.logic.getGame().getPlayers().entrySet()) {
if (entry.getValue().getColor() == player.getColor()) { if (entry.getValue().getColor() == player.getColor()) {
this.logic.getGame().getPlayers().put(entry.getKey(), player); this.logic.getGame().getPlayers().put(entry.getKey(), player);
} }

View File

@@ -15,6 +15,7 @@ public class NetworkDialogState extends DialogStates {
/** /**
* Constructor for the NetworkDialogState * Constructor for the NetworkDialogState
*
* @param parent the parent state * @param parent the parent state
* @param logic the logic * @param logic the logic
*/ */

View File

@@ -10,6 +10,7 @@ public class StartDialogState extends DialogStates {
/** /**
* Constructor for the StartDialogState * Constructor for the StartDialogState
*
* @param parent the parent state * @param parent the parent state
* @param logic the logic * @param logic the logic
*/ */

View File

@@ -26,7 +26,7 @@ public void exit() {
} }
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
logic.send(new AnimationEndMessage()); logic.send(new AnimationEndMessage());
parent.setState(parent.getWaiting()); parent.setState(parent.getWaiting());
} }

View File

@@ -7,7 +7,6 @@
import pp.mdga.client.gamestate.determinestartplayerstate.Intro; 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.*; import pp.mdga.message.server.*;
public class DetermineStartPlayerState extends GameStates { public class DetermineStartPlayerState extends GameStates {
@@ -32,11 +31,11 @@ public WaitRankingState getWaitRanking() {
return waitRankingState; return waitRankingState;
} }
public DetermineStartPlayerStates getState(){ public DetermineStartPlayerStates getState() {
return state; return state;
} }
public Intro getIntro(){ public Intro getIntro() {
return intro; return intro;
} }
@@ -56,7 +55,7 @@ public void exit() {
public void setState(DetermineStartPlayerStates state) { public void setState(DetermineStartPlayerStates state) {
System.out.println("CLIENT STATE old: " + this.state + " new: " + state); System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
if(this.state != null){ if (this.state != null) {
this.state.exit(); this.state.exit();
} }
this.state = state; this.state = state;
@@ -69,32 +68,32 @@ public void selectDice() {
} }
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
state.selectAnimationEnd(); state.selectAnimationEnd();
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(RankingRollAgainMessage msg){ public void received(RankingRollAgainMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(RankingResponseMessage msg){ public void received(RankingResponseMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(ActivePlayerMessage msg){ public void received(ActivePlayerMessage msg) {
state.received(msg); state.received(msg);
} }
} }

View File

@@ -2,19 +2,12 @@
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.game.Board; import pp.mdga.game.*;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Node;
import pp.mdga.game.Piece;
import pp.mdga.game.PieceState;
import pp.mdga.game.ShieldState;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.ShieldActiveNotification; import pp.mdga.notification.ShieldActiveNotification;
import pp.mdga.notification.ShieldSuppressedNotification; import pp.mdga.notification.ShieldSuppressedNotification;
import pp.mdga.notification.SwapPieceNotification; import pp.mdga.notification.SwapPieceNotification;
import pp.mdga.notification.ThrowPieceNotification;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public abstract class GameStates extends ClientState { public abstract class GameStates extends ClientState {
@@ -68,13 +61,13 @@ private void swapPieces(Piece messageOwn, Piece messageEnemy) {
} }
private void checkShieldAfterSwap(Node node, Piece piece){ private void checkShieldAfterSwap(Node node, Piece piece) {
if (node.isStart()){ if (node.isStart()) {
if (piece.isShielded()){ if (piece.isShielded()) {
piece.setShield(ShieldState.SUPPRESSED); piece.setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid())); logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
} }
} else if (piece.isSuppressed()){ } else if (piece.isSuppressed()) {
piece.setShield(ShieldState.ACTIVE); piece.setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(piece.getUuid())); logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
} }

View File

@@ -35,7 +35,7 @@ public void received(CeremonyMessage msg) {
} }
@Override @Override
public void received(DrawCardMessage msg){ public void received(DrawCardMessage msg) {
logic.getGame().getActivePlayer().addHandCard(msg.getCard()); logic.getGame().getActivePlayer().addHandCard(msg.getCard());
if (msg.getCard() instanceof HiddenCard) { if (msg.getCard() instanceof HiddenCard) {
logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN)); logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN));
@@ -87,14 +87,14 @@ public void received(MoveMessage msg) {
if (occ != null) { if (occ != null) {
//TODO: MoveThrowNotification //TODO: MoveThrowNotification
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor())); logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
if (occ.isSuppressed()){ if (occ.isSuppressed()) {
logic.addNotification(new RemoveShieldNotification(occ.getUuid())); logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
occ.setShield(ShieldState.NONE); occ.setShield(ShieldState.NONE);
} }
//set occ to waiting //set occ to waiting
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ); logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
} }
if(msg.getPiece().getState().equals(PieceState.WAITING)){ if (msg.getPiece().getState().equals(PieceState.WAITING)) {
logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true)); logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece); logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
piece.setState(PieceState.ACTIVE); piece.setState(PieceState.ACTIVE);

View File

@@ -3,23 +3,12 @@
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.*;
import pp.mdga.client.gamestate.turnstate.MovePieceState;
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gamestate.turnstate.RollDiceState;
import pp.mdga.client.gamestate.turnstate.TurnStates;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.ShieldState; import pp.mdga.game.ShieldState;
import pp.mdga.game.card.HiddenCard;
import pp.mdga.game.card.ShieldCard;
import pp.mdga.game.card.SwapCard;
import pp.mdga.game.card.TurboCard;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.RemoveShieldNotification; import pp.mdga.notification.RemoveShieldNotification;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.DrawCardNotification;
public class TurnState extends GameStates { public class TurnState extends GameStates {
@@ -42,7 +31,7 @@ public TurnState(ClientState parent, ClientGameLogic logic) {
public void enter() { public void enter() {
logic = logic; logic = logic;
for (Piece piece : logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPieces()) { for (Piece piece : logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPieces()) {
if (piece.isShielded() || piece.isSuppressed()){ if (piece.isShielded() || piece.isSuppressed()) {
piece.setShield(ShieldState.NONE); piece.setShield(ShieldState.NONE);
logic.addNotification(new RemoveShieldNotification(piece.getUuid())); logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
} }
@@ -56,9 +45,9 @@ public void exit() {
state = null; state = null;
} }
public void setState(TurnStates state){ public void setState(TurnStates state) {
System.out.println("CLIENT STATE old: " + this.state + " new: " + state); System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
if(this.state != null){ if (this.state != null) {
this.state.exit(); this.state.exit();
} }
state.enter(); state.enter();
@@ -66,97 +55,97 @@ public void setState(TurnStates state){
} }
@Override @Override
public void selectDice(){ public void selectDice() {
state.selectDice(); state.selectDice();
} }
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece) {
state.selectPiece(piece); state.selectPiece(piece);
} }
@Override @Override
public void selectCard(BonusCard card){ public void selectCard(BonusCard card) {
state.selectCard(card); state.selectCard(card);
} }
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
state.selectAnimationEnd(); state.selectAnimationEnd();
} }
@Override @Override
public void received(SelectPieceMessage msg){ public void received(SelectPieceMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(WaitPieceMessage msg){ public void received(WaitPieceMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(StartPieceMessage msg){ public void received(StartPieceMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(NoTurnMessage msg){ public void received(NoTurnMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(CeremonyMessage msg){ public void received(CeremonyMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(EndOfTurnMessage msg){ public void received(EndOfTurnMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(SpectatorMessage msg){ public void received(SpectatorMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(DiceAgainMessage msg){ public void received(DiceAgainMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(PossibleCardsMessage msg){ public void received(PossibleCardsMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(PossiblePieceMessage msg){ public void received(PossiblePieceMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(ChoosePieceStateMessage msg){ public void received(ChoosePieceStateMessage msg) {
state.received(msg); state.received(msg);
} }
@@ -180,11 +169,11 @@ public RollDiceState getRollDice() {
return rollDiceState; return rollDiceState;
} }
public GameState getParent(){ public GameState getParent() {
return parent; return parent;
} }
public TurnStates getState(){ public TurnStates getState() {
return state; return state;
} }

View File

@@ -38,10 +38,9 @@ public void received(CeremonyMessage msg) {
@Override @Override
public void received(DieMessage msg) { public void received(DieMessage msg) {
logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
if(logic.getGame().getTurboFlag()){ if (logic.getGame().getTurboFlag()) {
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye(), logic.getGame().getDiceModifier())); logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye(), logic.getGame().getDiceModifier()));
} } else {
else {
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye())); logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye()));
} }
@@ -65,11 +64,11 @@ public void received(PlayCardMessage msg) {
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());
if(msg.getColor() == logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getColor()) { if (msg.getColor() == logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getColor()) {
parent.setState(parent.getTurn()); parent.setState(parent.getTurn());
} else { } else {
for (Piece piece : logic.getGame().getActivePlayer().getPieces()){ for (Piece piece : logic.getGame().getActivePlayer().getPieces()) {
if (piece.isShielded() || piece.isSuppressed()){ if (piece.isShielded() || piece.isSuppressed()) {
logic.addNotification(new RemoveShieldNotification(piece.getUuid())); logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
piece.setShield(ShieldState.NONE); piece.setShield(ShieldState.NONE);
} }
@@ -81,7 +80,7 @@ public void received(ActivePlayerMessage msg) {
public void received(MoveMessage msg) { public void received(MoveMessage msg) {
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
if (msg.isHomeMove()) { if (msg.isHomeMove()) {
if(piece.getState().equals(PieceState.HOME)){ if (piece.getState().equals(PieceState.HOME)) {
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece); int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
Node pieceNode = logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex]; Node pieceNode = logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex];
@@ -91,18 +90,16 @@ public void received(MoveMessage msg) {
Node oldNode = logic.getGame().getActivePlayer().getHomeNodes()[homeIndex]; Node oldNode = logic.getGame().getActivePlayer().getHomeNodes()[homeIndex];
//gets the targetNode //gets the targetNode
Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[msg.getTargetIndex()]; Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[msg.getTargetIndex()];
if (msg.getTargetIndex() ==logic.getGame().getActivePlayer().getHighestHomeIdx()) { if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
piece.setState(PieceState.HOMEFINISHED); piece.setState(PieceState.HOMEFINISHED);
} } else {
else{
piece.setState(PieceState.HOME); piece.setState(PieceState.HOME);
} }
oldNode.clearOccupant(); oldNode.clearOccupant();
targetNode.setOccupant(piece); targetNode.setOccupant(piece);
} } else {
else{
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx]; Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx];
@@ -110,31 +107,29 @@ public void received(MoveMessage msg) {
//gets the targetNode //gets the targetNode
Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[msg.getTargetIndex()]; Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[msg.getTargetIndex()];
if (msg.getTargetIndex() ==logic.getGame().getActivePlayer().getHighestHomeIdx()) { if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
piece.setState(PieceState.HOMEFINISHED); piece.setState(PieceState.HOMEFINISHED);
} } else {
else{
piece.setState(PieceState.HOME); piece.setState(PieceState.HOME);
} }
oldNode.clearOccupant(); oldNode.clearOccupant();
targetNode.setOccupant(piece); targetNode.setOccupant(piece);
} }
} } else {
else {
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant(); Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
if (occ != null) { if (occ != null) {
//TODO: MoveThrowNotification //TODO: MoveThrowNotification
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor())); logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
if (occ.isSuppressed()){ if (occ.isSuppressed()) {
logic.addNotification(new RemoveShieldNotification(occ.getUuid())); logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
occ.setShield(ShieldState.NONE); occ.setShield(ShieldState.NONE);
} }
//set occ to waiting //set occ to waiting
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ); logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
} }
if(oldIndex == -1){ if (oldIndex == -1) {
logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true)); logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece); logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
piece.setState(PieceState.ACTIVE); piece.setState(PieceState.ACTIVE);
@@ -145,12 +140,12 @@ public void received(MoveMessage msg) {
} }
//set new node //set new node
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece); logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isStart()){ if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isStart()) {
if (piece.isShielded()){ if (piece.isShielded()) {
piece.setShield(ShieldState.SUPPRESSED); piece.setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid())); logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
} }
} else if (piece.isSuppressed()){ } else if (piece.isSuppressed()) {
piece.setShield(ShieldState.ACTIVE); piece.setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(piece.getUuid())); logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
} }

View File

@@ -13,7 +13,7 @@
import java.util.Map; import java.util.Map;
public class Intro extends DetermineStartPlayerStates{ public class Intro extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent; private final DetermineStartPlayerState parent;
@@ -35,7 +35,7 @@ public Intro(ClientState parent, ClientGameLogic logic) {
* *
* @return the parent state * @return the parent state
*/ */
public DetermineStartPlayerState getParent(){ public DetermineStartPlayerState getParent() {
return parent; return parent;
} }
@@ -44,13 +44,13 @@ public DetermineStartPlayerState getParent(){
*/ */
@Override @Override
public void enter() { public void enter() {
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){ for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) {
logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true)); 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]); logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
entry.getValue().getWaitingArea()[0] = null; entry.getValue().getWaitingArea()[0] = null;
animationCounter++; animationCounter++;
for (PowerCard card : entry.getValue().getHandCards()){ for (PowerCard card : entry.getValue().getHandCards()) {
if(entry.getKey() == logic.getOwnPlayerId()){ if (entry.getKey() == logic.getOwnPlayerId()) {
logic.addNotification(new AcquireCardNotification(card.getCard())); logic.addNotification(new AcquireCardNotification(card.getCard()));
} else { } else {
logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), card.getCard())); logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), card.getCard()));
@@ -71,13 +71,13 @@ public void exit() {
* This method is used when the view has completed the animation. * This method is used when the view has completed the animation.
*/ */
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
animationCounter--; animationCounter--;
if(animationCounter != 0){ if (animationCounter != 0) {
return; return;
} }
logic.send(new AnimationEndMessage()); logic.send(new AnimationEndMessage());
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){ if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()) {
parent.getParent().setState(parent.getParent().getTurn()); parent.getParent().setState(parent.getParent().getTurn());
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor())); logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
} else { } else {

View File

@@ -13,7 +13,7 @@ public class RollRankingDiceState extends DetermineStartPlayerStates {
private final System.Logger LOGGER = System.getLogger(this.getClass().getName()); private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
private final DetermineStartPlayerState parent; private final DetermineStartPlayerState parent;
private boolean isRolled =false; private boolean isRolled = false;
public RollRankingDiceState(ClientState parent, ClientGameLogic logic) { public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
@@ -29,20 +29,20 @@ public void enter() {
@Override @Override
public void exit() { public void exit() {
LOGGER.log(System.Logger.Level.INFO, "Exiting RollRankingDiceState"); LOGGER.log(System.Logger.Level.INFO, "Exiting RollRankingDiceState");
isRolled=false; isRolled = false;
} }
@Override @Override
public void selectDice(){ public void selectDice() {
if(!isRolled){ if (!isRolled) {
isRolled = true; isRolled = true;
logic.send(new RequestDieMessage()); logic.send(new RequestDieMessage());
} }
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
parent.setState(parent.getWaitRanking()); parent.setState(parent.getWaitRanking());
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true)); logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(), true));
} }
} }

View File

@@ -5,8 +5,9 @@
import pp.mdga.client.gamestate.DetermineStartPlayerState; import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.message.client.AnimationEndMessage; import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.*; import pp.mdga.message.server.ActivePlayerMessage;
import pp.mdga.notification.ActivePlayerNotification; import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.notification.RankingResponceNotification; import pp.mdga.notification.RankingResponceNotification;
import java.util.HashMap; import java.util.HashMap;
@@ -24,8 +25,8 @@ public WaitRankingState(ClientState parent, ClientGameLogic logic) {
this.parent = (DetermineStartPlayerState) parent; this.parent = (DetermineStartPlayerState) parent;
} }
private void changeToIntro(){ private void changeToIntro() {
if(!canChange){ if (!canChange) {
canChange = true; canChange = true;
return; return;
} }
@@ -44,12 +45,12 @@ public void exit() {
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
parent.setState(parent.getRollRankingDice()); parent.setState(parent.getRollRankingDice());
} }
@Override @Override
public void received(RankingResponseMessage msg){ public void received(RankingResponseMessage msg) {
Map<Color, Integer> rankingResults = new HashMap<>(); Map<Color, Integer> rankingResults = new HashMap<>();
for (var entry : msg.getRankingResults().entrySet()) { for (var entry : msg.getRankingResults().entrySet()) {
rankingResults.put(logic.getGame().getPlayerById(entry.getKey()).getColor(), entry.getValue()); rankingResults.put(logic.getGame().getPlayerById(entry.getKey()).getColor(), entry.getValue());
@@ -58,13 +59,13 @@ public void received(RankingResponseMessage msg){
} }
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
changeToIntro(); changeToIntro();
logic.send(new AnimationEndMessage()); logic.send(new AnimationEndMessage());
} }
@Override @Override
public void received(ActivePlayerMessage msg){ public void received(ActivePlayerMessage msg) {
logic.getGame().setActiveColor(msg.getColor()); logic.getGame().setActiveColor(msg.getColor());
changeToIntro(); changeToIntro();
} }

View File

@@ -30,12 +30,12 @@ public void enter() {
@Override @Override
public void exit() { public void exit() {
currentState.exit(); currentState.exit();
currentState= null; currentState = null;
} }
public void setState(ChoosePieceStates state){ public void setState(ChoosePieceStates state) {
System.out.println("CLIENT STATE old: " + this.currentState + " new: " + state); System.out.println("CLIENT STATE old: " + this.currentState + " new: " + state);
if(currentState != null){ if (currentState != null) {
currentState.exit(); currentState.exit();
} }
state.enter(); state.enter();
@@ -43,56 +43,56 @@ public void setState(ChoosePieceStates state){
} }
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece) {
currentState.selectPiece(piece); currentState.selectPiece(piece);
} }
@Override @Override
public void received(SelectPieceMessage msg){ public void received(SelectPieceMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@Override @Override
public void received(WaitPieceMessage msg){ public void received(WaitPieceMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@Override @Override
public void received(StartPieceMessage msg){ public void received(StartPieceMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@Override @Override
public void received(EndOfTurnMessage msg){ public void received(EndOfTurnMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
currentState.received(msg); currentState.received(msg);
} }
public NoPieceState getNoPiece(){ public NoPieceState getNoPiece() {
return noPieceState; return noPieceState;
} }
public SelectPieceState getSelectPiece(){ public SelectPieceState getSelectPiece() {
return selectPieceState; return selectPieceState;
} }
public StartPieceState getStartPiece(){ public StartPieceState getStartPiece() {
return startPieceState; return startPieceState;
} }
public WaitingPieceState getWaitingPiece(){ public WaitingPieceState getWaitingPiece() {
return waitingPieceState; return waitingPieceState;
} }
public ChoosePieceStates getState(){ public ChoosePieceStates getState() {
return currentState; return currentState;
} }
public TurnState getParent(){ public TurnState getParent() {
return parent; return parent;
} }
} }

View File

@@ -4,7 +4,10 @@
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.CeremonyMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.EndOfTurnMessage;
import pp.mdga.message.server.SpectatorMessage;
public class MovePieceState extends TurnStates { public class MovePieceState extends TurnStates {
@@ -26,27 +29,27 @@ public void exit() {
} }
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
logic.send(new AnimationEndMessage()); logic.send(new AnimationEndMessage());
} }
@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(EndOfTurnMessage msg){ public void received(EndOfTurnMessage msg) {
parent.getParent().setState(parent.getParent().getWaiting()); parent.getParent().setState(parent.getParent().getWaiting());
} }
@Override @Override
public void received(SpectatorMessage msg){ public void received(SpectatorMessage msg) {
parent.getParent().setState(parent.getParent().getSpectator()); parent.getParent().setState(parent.getParent().getSpectator());
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
parent.setState(parent.getRollDice()); parent.setState(parent.getRollDice());
} }

View File

@@ -4,8 +4,6 @@
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.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.card.ShieldCard;
import pp.mdga.game.card.SwapCard;
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;
@@ -24,7 +22,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
if(playCardMessage.getCard().getCard().equals(BonusCard.SWAP)) { if (playCardMessage.getCard().getCard().equals(BonusCard.SWAP)) {
extraAnimationCounter++; extraAnimationCounter++;
} }
@@ -43,8 +41,8 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
} }
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
if(extraAnimationCounter > 0) { if (extraAnimationCounter > 0) {
extraAnimationCounter--; extraAnimationCounter--;
return; return;
} }

View File

@@ -42,7 +42,7 @@ public void exit() {
public void setState(PowerCardStates state) { public void setState(PowerCardStates state) {
System.out.println("CLIENT STATE old: " + this.state + " new: " + state); System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
if(this.state != null){ if (this.state != null) {
this.state.exit(); this.state.exit();
} }
state.enter(); state.enter();
@@ -50,22 +50,22 @@ public void setState(PowerCardStates state) {
} }
@Override @Override
public void received(PossibleCardsMessage msg){ public void received(PossibleCardsMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
state.received(msg); state.received(msg);
} }
@Override @Override
public void received(PossiblePieceMessage msg){ public void received(PossiblePieceMessage msg) {
state.received(msg); state.received(msg);
} }

View File

@@ -39,43 +39,42 @@ public TurnState getParent() {
} }
@Override @Override
public void selectDice(){ public void selectDice() {
if (!isRolled){ if (!isRolled) {
isRolled = true; isRolled = true;
logic.send(new RequestDieMessage()); logic.send(new RequestDieMessage());
} }
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
if(logic.getGame().getTurboFlag()){ if (logic.getGame().getTurboFlag()) {
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(), logic.getGame().getDiceModifier())); logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(), logic.getGame().getDiceModifier()));
} } else {
else {
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye())); logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye()));
} }
} }
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd() {
logic.send(new AnimationEndMessage()); logic.send(new AnimationEndMessage());
} }
@Override @Override
public void received(ChoosePieceStateMessage msg){ public void received(ChoosePieceStateMessage msg) {
parent.setState(parent.getChoosePiece()); 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());
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
isRolled = false; isRolled = false;
logic.addNotification(new DiceNowNotification()); logic.addNotification(new DiceNowNotification());
} }

View File

@@ -4,11 +4,11 @@
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.EndOfTurnMessage;
import pp.mdga.message.server.SelectPieceMessage;
import pp.mdga.message.server.StartPieceMessage; import pp.mdga.message.server.StartPieceMessage;
import pp.mdga.notification.MovePieceNotification; import pp.mdga.message.server.WaitPieceMessage;
import pp.mdga.notification.SelectableMoveNotification; import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.WaitMoveNotification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -47,7 +47,7 @@ public void received(SelectPieceMessage msg) {
} }
@Override @Override
public void received(WaitPieceMessage msg){ public void received(WaitPieceMessage msg) {
LOGGER.log(System.Logger.Level.INFO, "Received WaitPieceMessage"); LOGGER.log(System.Logger.Level.INFO, "Received WaitPieceMessage");
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceID()); Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceID());
logic.addNotification(new SelectableMoveNotification(new ArrayList<>(List.of(msg.getPieceID())), new ArrayList<>(List.of(logic.getGame().getPlayerByColor(piece.getColor()).getStartNodeIndex())), new ArrayList<>(List.of(false)))); logic.addNotification(new SelectableMoveNotification(new ArrayList<>(List.of(msg.getPieceID())), new ArrayList<>(List.of(logic.getGame().getPlayerByColor(piece.getColor()).getStartNodeIndex())), new ArrayList<>(List.of(false))));
@@ -55,7 +55,7 @@ public void received(WaitPieceMessage msg){
} }
@Override @Override
public void received(StartPieceMessage msg){ public void received(StartPieceMessage msg) {
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()); Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
List<UUID> listPiece = new ArrayList<>(); List<UUID> listPiece = new ArrayList<>();
List<Integer> listIndex = new ArrayList<>(); List<Integer> listIndex = new ArrayList<>();
@@ -70,7 +70,7 @@ public void received(StartPieceMessage msg){
} }
@Override @Override
public void received(EndOfTurnMessage msg){ public void received(EndOfTurnMessage msg) {
logic.getGame().setTurboFlag(false); logic.getGame().setTurboFlag(false);
parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting()); parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
} }

View File

@@ -4,17 +4,11 @@
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.ShieldState;
import pp.mdga.game.PieceState; import pp.mdga.game.PieceState;
import pp.mdga.game.ShieldState;
import pp.mdga.message.client.RequestMoveMessage; import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
import pp.mdga.notification.HomeMoveNotification; import pp.mdga.notification.*;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.RemoveShieldNotification;
import pp.mdga.notification.ShieldActiveNotification;
import pp.mdga.notification.ShieldSuppressedNotification;
import pp.mdga.notification.ThrowPieceNotification;
import java.util.ArrayList; import java.util.ArrayList;
@@ -63,29 +57,25 @@ public void received(MoveMessage msg) {
System.out.println("Client: SelectState: activePiece in Home: infieldIndex" + infieldIndex); System.out.println("Client: SelectState: activePiece in Home: infieldIndex" + infieldIndex);
if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) { if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
piece.setState(PieceState.HOMEFINISHED); piece.setState(PieceState.HOMEFINISHED);
} } else {
else {
piece.setState(PieceState.HOME); piece.setState(PieceState.HOME);
} }
logic.getGame().getBoard().getInfield()[infieldIndex].clearOccupant(); logic.getGame().getBoard().getInfield()[infieldIndex].clearOccupant();
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece); logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
} } else {
else {
System.out.println("Client: SelectPieceState: receivedMoveMessage:reached else"); System.out.println("Client: SelectPieceState: receivedMoveMessage:reached else");
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
System.out.println("Client: electPieceState: homeindex" + logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece)); System.out.println("Client: electPieceState: homeindex" + logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece));
int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece); int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) { if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
piece.setState(PieceState.HOMEFINISHED); piece.setState(PieceState.HOMEFINISHED);
} } else {
else {
piece.setState(PieceState.HOME); piece.setState(PieceState.HOME);
} }
logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex].clearOccupant(); logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex].clearOccupant();
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece); logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
} }
} } else {
else {
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant(); Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
@@ -93,7 +83,7 @@ public void received(MoveMessage msg) {
if (occ != null) { if (occ != null) {
//TODO: MoveThrowNotification //TODO: MoveThrowNotification
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor())); logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
if (occ.isSuppressed()){ if (occ.isSuppressed()) {
logic.addNotification(new RemoveShieldNotification(occ.getUuid())); logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
occ.setShield(ShieldState.NONE); occ.setShield(ShieldState.NONE);
} }
@@ -111,8 +101,7 @@ public void received(MoveMessage msg) {
piece.setShield(ShieldState.SUPPRESSED); piece.setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid())); logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
} }
} } else if (piece.isSuppressed()) {
else if (piece.isSuppressed()) {
piece.setShield(ShieldState.ACTIVE); piece.setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(piece.getUuid())); logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
} }

View File

@@ -7,15 +7,8 @@
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.ShieldState; import pp.mdga.game.ShieldState;
import pp.mdga.message.client.RequestMoveMessage; import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
import pp.mdga.notification.MovePieceNotification; import pp.mdga.notification.*;
import pp.mdga.notification.RemoveShieldNotification;
import pp.mdga.notification.ShieldActiveNotification;
import pp.mdga.notification.ShieldSuppressedNotification;
import pp.mdga.notification.ThrowPieceNotification;
import java.util.ArrayList;
public class StartPieceState extends ChoosePieceStates { public class StartPieceState extends ChoosePieceStates {
@@ -45,14 +38,14 @@ public void setMoveablePiece(Piece moveablePiece) {
} }
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece) {
if(moveablePiece.equals(piece)){ if (moveablePiece.equals(piece)) {
logic.send(new RequestMoveMessage(piece)); logic.send(new RequestMoveMessage(piece));
} }
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece); int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
int targetIndex = msg.getTargetIndex(); int targetIndex = msg.getTargetIndex();
@@ -62,21 +55,21 @@ public void received(MoveMessage msg){
//get Occupant //get Occupant
Piece occ = targetNode.getOccupant(); Piece occ = targetNode.getOccupant();
if (occ != null){ if (occ != null) {
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ); logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
if (occ.isSuppressed()){ if (occ.isSuppressed()) {
logic.addNotification(new RemoveShieldNotification(occ.getUuid())); logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
occ.setShield(ShieldState.NONE); occ.setShield(ShieldState.NONE);
} }
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor())); logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
} }
if (targetNode.isStart()){ if (targetNode.isStart()) {
if (piece.isShielded()){ if (piece.isShielded()) {
piece.setShield(ShieldState.SUPPRESSED); piece.setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid())); logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
} }
} else if (piece.isSuppressed()){ } else if (piece.isSuppressed()) {
piece.setShield(ShieldState.ACTIVE); piece.setShield(ShieldState.ACTIVE);
logic.addNotification(new RemoveShieldNotification(piece.getUuid())); logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
logic.addNotification(new ShieldActiveNotification(piece.getUuid())); logic.addNotification(new ShieldActiveNotification(piece.getUuid()));

View File

@@ -7,15 +7,11 @@
import pp.mdga.game.PieceState; import pp.mdga.game.PieceState;
import pp.mdga.game.ShieldState; import pp.mdga.game.ShieldState;
import pp.mdga.message.client.RequestMoveMessage; import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
import pp.mdga.notification.MovePieceNotification; import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.RemoveShieldNotification; import pp.mdga.notification.RemoveShieldNotification;
import pp.mdga.notification.ThrowPieceNotification; import pp.mdga.notification.ThrowPieceNotification;
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;
@@ -36,17 +32,17 @@ public void exit() {
} }
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece) {
logic.send(new RequestMoveMessage(piece)); logic.send(new RequestMoveMessage(piece));
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()); Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant(); Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
if (occ != null){ if (occ != null) {
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ); logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
if (occ.isSuppressed()){ if (occ.isSuppressed()) {
logic.addNotification(new RemoveShieldNotification(occ.getUuid())); logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
occ.setShield(ShieldState.NONE); occ.setShield(ShieldState.NONE);
} }

View File

@@ -4,9 +4,8 @@
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.Piece;
import pp.mdga.game.Player; import pp.mdga.game.Player;
import pp.mdga.game.card.*; import pp.mdga.game.card.PowerCard;
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;
@@ -14,7 +13,6 @@
import pp.mdga.message.server.PossibleCardsMessage; import pp.mdga.message.server.PossibleCardsMessage;
import pp.mdga.message.server.PossiblePieceMessage; import pp.mdga.message.server.PossiblePieceMessage;
import pp.mdga.notification.SelectableCardsNotification; import pp.mdga.notification.SelectableCardsNotification;
import pp.mdga.notification.SelectableShieldNotification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -29,6 +27,7 @@ public class ChoosePowerCardState extends PowerCardStates {
/** /**
* Constructor * Constructor
*
* @param parent parent state * @param parent parent state
* @param logic game logic * @param logic game logic
*/ */
@@ -54,11 +53,12 @@ public void exit() {
/** /**
* Set the possible cards * Set the possible cards
*
* @param msg possible cards message * @param msg possible cards message
*/ */
@Override @Override
public void received(PossibleCardsMessage msg){ public void received(PossibleCardsMessage msg) {
possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards(); possibleCards = (ArrayList<PowerCard>) msg.getPossibleCards();
ArrayList<BonusCard> possibleBonusCards = new ArrayList<>(); ArrayList<BonusCard> possibleBonusCards = new ArrayList<>();
for (PowerCard card : possibleCards) { for (PowerCard card : possibleCards) {
if (!possibleBonusCards.contains(card.getCard())) { if (!possibleBonusCards.contains(card.getCard())) {
@@ -70,15 +70,16 @@ public void received(PossibleCardsMessage msg){
/** /**
* Select a card * Select a card
*
* @param card card to select * @param card card to select
*/ */
@Override @Override
public void selectCard(BonusCard card){ public void selectCard(BonusCard card) {
Player player = logic.getGame().getPlayers().get(logic.getOwnPlayerId()); Player player = logic.getGame().getPlayers().get(logic.getOwnPlayerId());
ArrayList<PowerCard> handCards = player.getHandCards(); ArrayList<PowerCard> handCards = player.getHandCards();
if(card != null){ if (card != null) {
PowerCard select = player.getPowerCardByType(card); PowerCard select = player.getPowerCardByType(card);
if(select == null){ if (select == null) {
select = select; select = select;
} }
logic.send(new SelectCardMessage(select)); logic.send(new SelectCardMessage(select));
@@ -89,11 +90,12 @@ public void selectCard(BonusCard card){
/** /**
* Receive a card * Receive a card
*
* @param msg card message * @param msg card message
*/ */
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg) {
if(msg.getCard().getCard().equals(BonusCard.TURBO)){ if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
logic.getGame().setDiceModifier(msg.getDiceModifier()); logic.getGame().setDiceModifier(msg.getDiceModifier());
parent.getParent().getPlayPowerCard().setPlayCard(msg); parent.getParent().getPlayPowerCard().setPlayCard(msg);
logic.getGame().setTurboFlag(true); logic.getGame().setTurboFlag(true);
@@ -103,20 +105,22 @@ public void received(PlayCardMessage msg){
/** /**
* Receive a die now message * Receive a die now message
*
* @param msg dice now message * @param msg dice now message
*/ */
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
parent.getParent().setState(parent.getParent().getRollDice()); parent.getParent().setState(parent.getParent().getRollDice());
} }
/** /**
* Receive a possible piece message and decide if the player can swap or shield * Receive a possible piece message and decide if the player can swap or shield
*
* @param msg possible piece message * @param msg possible piece message
*/ */
@Override @Override
public void received(PossiblePieceMessage msg){ public void received(PossiblePieceMessage msg) {
if (msg.getEnemyPossiblePieces().isEmpty()){ if (msg.getEnemyPossiblePieces().isEmpty()) {
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new))); parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
parent.setState(parent.getShield()); parent.setState(parent.getShield());
} else { } else {

View File

@@ -4,14 +4,12 @@
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.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.SelectableShieldNotification; import pp.mdga.notification.SelectableShieldNotification;
import java.lang.System.Logger.Level; import java.lang.System.Logger.Level;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
public class ShieldState extends PowerCardStates { public class ShieldState extends PowerCardStates {

View File

@@ -4,14 +4,12 @@
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.SelectCardMessage;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.SelectableSwapNotification; import pp.mdga.notification.SelectableSwapNotification;
import java.util.UUID;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID;
public class SwapState extends PowerCardStates { public class SwapState extends PowerCardStates {
@@ -59,17 +57,17 @@ public void setPossibleEnemyPieces(ArrayList<Piece> possibleEnemyPieces) {
} }
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece) {
if (possibleOwnPieces.contains(piece)){ if (possibleOwnPieces.contains(piece)) {
selectedOwnPiece = piece; selectedOwnPiece = piece;
} else if (possibleEnemyPieces.contains(piece)){ } else if (possibleEnemyPieces.contains(piece)) {
selectedEnemyPiece = piece; selectedEnemyPiece = piece;
} }
if (selectedOwnPiece != null && selectedEnemyPiece != null){ if (selectedOwnPiece != null && selectedEnemyPiece != null) {
ArrayList<Piece> temp = new ArrayList<>(); ArrayList<Piece> temp = new ArrayList<>();
temp.add(selectedOwnPiece); temp.add(selectedOwnPiece);
temp.add(selectedEnemyPiece); temp.add(selectedEnemyPiece);
System.out.println("Client : Swap: temp: "+temp.get(0)+temp.get(1)); System.out.println("Client : Swap: temp: " + temp.get(0) + temp.get(1));
logic.send(new SelectedPiecesMessage(temp)); logic.send(new SelectedPiecesMessage(temp));
selectedEnemyPiece = null; selectedEnemyPiece = null;
selectedOwnPiece = null; selectedOwnPiece = null;

View File

@@ -79,7 +79,7 @@ private StartNode createStartNode(int i) {
*/ */
public int getInfieldIndexOfPiece(Piece piece) { public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) { for (int i = 0; i < infield.length; i++) {
if(infield[i].isOccupied()) { if (infield[i].isOccupied()) {
if (infield[i].getOccupant().equals(piece)) { if (infield[i].getOccupant().equals(piece)) {
return i; return i;
} }

View File

@@ -53,8 +53,8 @@ public static Color getColorByIndex(int index) {
public Color next(Game game) { public Color next(Game game) {
ArrayList<Color> colorsInGame = new ArrayList<>(); ArrayList<Color> colorsInGame = new ArrayList<>();
for(Player p : game.getPlayers().values()) { for (Player p : game.getPlayers().values()) {
if(p.isFinished()) { if (p.isFinished()) {
continue; continue;
} }
colorsInGame.add(p.getColor()); colorsInGame.add(p.getColor());

View File

@@ -109,7 +109,7 @@ private void initializeDrawPile() {
*/ */
public PowerCard draw() { public PowerCard draw() {
if (!this.drawPile.isEmpty()) { if (!this.drawPile.isEmpty()) {
if (drawPile.size() == 1){ if (drawPile.size() == 1) {
Collections.shuffle(this.discardPile); Collections.shuffle(this.discardPile);
this.drawPile.addAll(this.discardPile); this.drawPile.addAll(this.discardPile);
discardPile.clear(); discardPile.clear();
@@ -221,7 +221,7 @@ public Player getPlayerByColor(Color color) {
* *
* @return the active player * @return the active player
*/ */
public Player getActivePlayer(){ public Player getActivePlayer() {
return getPlayerByColor(activeColor); return getPlayerByColor(activeColor);
} }

View File

@@ -46,7 +46,7 @@ public void setOccupant(Piece occupant) {
this.occupant = occupant; this.occupant = occupant;
} }
public boolean isBonus(){ public boolean isBonus() {
return false; return false;
} }

View File

@@ -2,7 +2,6 @@
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
/** /**

View File

@@ -147,7 +147,7 @@ public boolean isFinished() {
*/ */
public PowerCard getPowerCardByType(BonusCard bonusCard) { public PowerCard getPowerCardByType(BonusCard bonusCard) {
for (PowerCard card : this.handCards) { for (PowerCard card : this.handCards) {
if(card.getCard().equals(bonusCard)) { if (card.getCard().equals(bonusCard)) {
return card; return card;
} }
} }
@@ -155,9 +155,9 @@ public PowerCard getPowerCardByType(BonusCard bonusCard) {
// throw new RuntimeException("bonusCard is not in handCards"); // throw new RuntimeException("bonusCard is not in handCards");
} }
public Piece getWaitingPiece(){ public Piece getWaitingPiece() {
for (Piece piece : this.waitingArea) { for (Piece piece : this.waitingArea) {
if (piece != null){ if (piece != null) {
return piece; return piece;
} }
} }
@@ -170,9 +170,9 @@ public Piece getWaitingPiece(){
* *
* @return the boolean if the waiting area contains a piece * @return the boolean if the waiting area contains a piece
*/ */
public boolean hasPieceInWaitingArea(){ public boolean hasPieceInWaitingArea() {
for (Piece piece : this.waitingArea) { for (Piece piece : this.waitingArea) {
if (piece != null){ if (piece != null) {
return true; return true;
} }
} }
@@ -211,10 +211,10 @@ public boolean isHomeFinished(Piece piece) {
* *
* @return the index * @return the index
*/ */
public int getHighestHomeIdx(){ public int getHighestHomeIdx() {
for (int i =3; i>=0;i--){ for (int i = 3; i >= 0; i--) {
if(!homeNodes[i].isOccupied()) { if (!homeNodes[i].isOccupied()) {
System.out.println("Player: highestHomeIndex:"+i); System.out.println("Player: highestHomeIndex:" + i);
return i; return i;
} }

View File

@@ -15,6 +15,7 @@ public class ShieldCard extends PowerCard {
public ShieldCard() { public ShieldCard() {
this.card = BonusCard.SHIELD; this.card = BonusCard.SHIELD;
} }
/** /**
* This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object. * This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object.
* *

View File

@@ -33,7 +33,7 @@ public JoinedLobbyMessage() {
* *
* @return the name of the player that is joining the server * @return the name of the player that is joining the server
*/ */
public String getName(){ public String getName() {
return name; return name;
} }

View File

@@ -19,6 +19,7 @@ public class CeremonyMessage extends ServerMessage {
private ArrayList<Integer> sixes; private ArrayList<Integer> sixes;
private ArrayList<Integer> nodesMoved; private ArrayList<Integer> nodesMoved;
private ArrayList<Integer> bonusNodes; private ArrayList<Integer> bonusNodes;
/** /**
* Constructs a new Ceremony instance. * Constructs a new Ceremony instance.
*/ */

View File

@@ -8,6 +8,7 @@ public class ChoosePieceStateMessage extends ServerMessage {
public ChoosePieceStateMessage() { public ChoosePieceStateMessage() {
super(); super();
} }
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

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