Version 1.0 #40

Merged
j23f0779 merged 947 commits from development2 into main 2024-12-13 10:26:49 +01:00
459 changed files with 21667 additions and 1199 deletions
Showing only changes of commit 9cb7a156bb - Show all commits

View File

@@ -6,7 +6,7 @@
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="pp.mdga.client.board.Outline.*" />
<option name="PATTERN" value="pp.mdga.client.board.outline.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
@@ -14,4 +14,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>

View File

@@ -44,13 +44,13 @@ public enum Asset {
private final String modelPath;
private final String diffPath;
private final float size;
private static final String root = "Models/";
private static final String ROOT = "Models/";
/**
* Default constructor. Initializes modelPath and diffPath based on the enum name and sets default size to 1.0.
*/
Asset() {
String folderFileName = "./" + root + name() + "/" + name();
String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = folderFileName + ".j3o";
this.diffPath = folderFileName + "_diff.png";
this.size = 1f;
@@ -74,7 +74,7 @@ public enum Asset {
* @param modelPath Path to the 3D model file.
*/
Asset(String modelPath) {
String folderFileName = "./" + root + name() + "/" + name();
String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = modelPath;
this.diffPath = folderFileName + "_diff.png";;
this.size = 1f;
@@ -86,7 +86,7 @@ public enum Asset {
* @param size Scaling factor for the asset.
*/
Asset(float size) {
String folderFileName = "./" + root + name() + "/" + name();
String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = folderFileName + ".j3o";
this.diffPath = folderFileName + "_diff.png";
this.size = size;

View File

@@ -130,9 +130,7 @@ public void setJoin(String ip, int port) {
}
public void leave() {
LOGGER.log(Level.INFO, "leave");
app.getAcousticHandler().playSound(MdgaSound.LEAVE);
enter(MdgaState.MAIN);
app.getGameLogic().selectLeave();
}
public void enter(MdgaState state) {

View File

@@ -20,7 +20,7 @@ enum MusicAsset {
private final String path;
private final boolean loop;
private final float subVolume;
private static final String root = "Music/";
private static final String ROOT = "Music/";
/**
* Constructs a new MusicAsset object with the specified name and sub-volume.
@@ -30,7 +30,7 @@ enum MusicAsset {
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
*/
MusicAsset(String name, float subVolume) {
this.path = root + name;
this.path = ROOT + name;
this.loop = false;
this.subVolume = subVolume;
}
@@ -43,7 +43,7 @@ enum MusicAsset {
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
*/
MusicAsset(String name, boolean loop, float subVolume) {
this.path = root + name;
this.path = ROOT + name;
this.loop = loop;
this.subVolume = subVolume;
}

View File

@@ -1,79 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.MaterialDef;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.FrameBuffer;
public class OutlineFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/Outline.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
// System.out.println("OutlineFilter.preFrame()");
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
// material.setTexture("OutlineDepthTexture", outlinePreFilter.getDefaultPassDepthTexture());
// System.out.println("OutlineFilter.postFrame()");
}
@Override
protected Material getMaterial() {
return material;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public float getOutlineWidth() {
return outlineWidth;
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
}

View File

@@ -1,67 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
public class OutlinePreFilter extends Filter {
private Pass normalPass;
private RenderManager renderManager;
/**
* Creates a OutlinePreFilter
*/
public OutlinePreFilter() {
super("OutlinePreFilter");
}
@Override
protected boolean isRequiresDepthTexture() {
return true;
}
@Override
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, false);
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
}
@Override
protected Material getMaterial() {
return material;
}
public Texture getOutlineTexture() {
return normalPass.getRenderedTexture();
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "MatDefs/SelectObjectOutliner/OutlinePre.j3md");
}
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
}

View File

@@ -1,79 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.MaterialDef;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.FrameBuffer;
public class OutlineProFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineProFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/OutlinePro.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
// System.out.println("OutlineFilter.preFrame()");
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
// material.setTexture("OutlineDepthTexture", outlinePreFilter.getDefaultPassDepthTexture());
// System.out.println("OutlineFilter.postFrame()");
}
@Override
protected Material getMaterial() {
return material;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public float getOutlineWidth() {
return outlineWidth;
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
}

View File

@@ -1,88 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial;
import pp.mdga.client.MdgaApp;
public class SelectObjectOutliner {
private final FilterPostProcessor fpp;
private final RenderManager renderManager;
private final AssetManager assetManager;
private final Camera cam;
private final int width;
private boolean selected;
private ViewPort outlineViewport = null;
// private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null;
private final MdgaApp app;
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam, MdgaApp app) {
this.selected = false;
this.fpp = fpp;
this.renderManager = renderManager;
this.assetManager = assetManager;
this.cam = cam;
this.width = width;
this.app = app;
}
public void deselect(Spatial model) {
if(selected){
selected = false;
hideOutlineFilterEffect(model);
}
}
public void select(Spatial model, ColorRGBA color) {
if(!selected){
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
public void select(Spatial model, ColorRGBA color, int width) {
if(!selected){
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
private void hideOutlineFilterEffect(Spatial model) {
// app.enqueue(() -> {
outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter);
outlineViewport.detachScene(model);
outlineViewport.clearProcessors();
renderManager.removePreView(outlineViewport);
outlineViewport = null;
// return null;
// });
}
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
// app.enqueue(() -> {
outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
outlineFpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp);
outlineFilter = new OutlineProFilter(outlinePreFilter);
outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineWidth(width);
fpp.addFilter(outlineFilter);
// return null;
// });
}
}

View File

@@ -8,7 +8,7 @@
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.Outline.SelectObjectOutliner;
import pp.mdga.client.board.outline.SelectObjectOutliner;
public class OutlineControl extends AbstractControl {
private static final int THICKNESS_DEFAULT = 6;

View File

@@ -197,14 +197,14 @@ protected void setImageRelative(Picture picture) {
return;
}
final float LARGER = 10;
final float larger = 10;
picture.setWidth(instance.getPreferredSize().x + LARGER);
picture.setHeight(instance.getPreferredSize().y + LARGER);
picture.setWidth(instance.getPreferredSize().x + larger);
picture.setHeight(instance.getPreferredSize().y + larger);
picture.setLocalTranslation(
instance.getLocalTranslation().x - LARGER / 2,
(instance.getLocalTranslation().y - picture.getHeight()) + LARGER / 2,
instance.getLocalTranslation().x - larger / 2,
(instance.getLocalTranslation().y - picture.getHeight()) + larger / 2,
instance.getLocalTranslation().z + 0.01f
);
}

View File

@@ -28,5 +28,6 @@ public void hide() {
}
protected abstract void onShow();
protected abstract void onHide ();
protected abstract void onHide();
}

View File

@@ -65,6 +65,7 @@ public void update(float delta) {
try {
this.connectionFuture.get();
} catch (ExecutionException ignored) {
// todo: implement
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}

View File

@@ -4,7 +4,6 @@
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
@@ -15,16 +14,16 @@
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.shadow.DirectionalLightShadowFilter;
import com.jme3.shadow.DirectionalLightShadowRenderer;
import com.jme3.shadow.EdgeFilteringMode;
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import pp.mdga.client.Asset;
import java.util.*;
public class CardLayer extends AbstractAppState {
public static final int SHADOWMAP_SIZE = 1024 * 8;
private Node root;
private Application app;
private boolean init;
@@ -43,7 +42,7 @@ public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTextu
}
@Override
public void initialize(AppStateManager stateManager, Application app ) {
public void initialize(AppStateManager stateManager, Application app) {
this.app = app;
root = new Node("Under gui viewport Root");
@@ -57,11 +56,9 @@ public void initialize(AppStateManager stateManager, Application app ) {
DirectionalLight sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(.5f,-.5f,-1));
sun.setDirection(new Vector3f(.5f, -.5f, -1));
root.addLight(sun);
final int SHADOWMAP_SIZE=1024*8;
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
dlsf.setLight(sun);
dlsf.setEnabled(true);
@@ -71,25 +68,24 @@ public void initialize(AppStateManager stateManager, Application app ) {
view.addProcessor(fpp);
if(!init) init = true;
if (!init) init = true;
}
public void shutdown(){
public void shutdown() {
cardBuffer.clear();
root.detachAllChildren();
}
@Override
public void render(RenderManager rm) {
root.updateGeometricState();
}
@Override
public void update( float tpf ) {
public void update(float tpf) {
if (init && !cardBuffer.isEmpty()) {
for(Spatial spatial : cardBuffer){
for (Spatial spatial : cardBuffer) {
root.attachChild(spatial);
}
cardBuffer.clear();
@@ -97,19 +93,19 @@ public void update( float tpf ) {
root.updateLogicalState(tpf);
}
public void addSpatial(Spatial card){
public void addSpatial(Spatial card) {
cardBuffer.add(card);
}
public void deleteSpatial(Spatial spatial){
public void deleteSpatial(Spatial spatial) {
root.detachChild(spatial);
}
public Camera getOverlayCam(){
public Camera getOverlayCam() {
return overlayCam;
}
public Node getRootNode(){
public Node getRootNode() {
return root;
}
}

View File

@@ -16,14 +16,13 @@ public class SymbolControl extends AbstractControl {
private BonusCard state;
private float rotationSpeed = 0.8f;
private Quaternion initialRotation = null;
private float Y = 5;
private float y = 5;
@Override
protected void controlUpdate(float tpf) {
if(state == null) return;
switch (state){
if (state == null) return;
switch (state) {
case SHIELD -> shieldUpdate(tpf);
case SWAP -> swapUpdate(tpf);
case TURBO -> turboUpdate(tpf);
@@ -36,7 +35,7 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
}
private void shieldUpdate(float tpf){
private void shieldUpdate(float tpf) {
if (zoomingIn) {
progress += tpf * zoomSpeed;
if (progress > 1) progress = 1;
@@ -58,13 +57,13 @@ private void shieldUpdate(float tpf){
}
}
private void swapUpdate(float tpf){
private void swapUpdate(float tpf) {
if (initialRotation == null) {
initialRotation = spatial.getLocalRotation().clone();
}
progress += tpf*rotationSpeed;
if(progress < 0) return;
progress += tpf * rotationSpeed;
if (progress < 0) return;
float angle = lerp(0, 360, easeInOut(progress));
@@ -80,12 +79,13 @@ private void swapUpdate(float tpf){
spatial.removeFromParent();
}
}
private void turboUpdate(float tpf){
private void turboUpdate(float tpf) {
if (zoomingIn) {
progress += tpf * zoomSpeed;
if (progress > 1) progress = 1;
float y = lerp(-Y,0, easeOut(progress));
spatial.setLocalTranslation(0,y,0);
float y = lerp(-this.y, 0, easeOut(progress));
spatial.setLocalTranslation(0, y, 0);
if (progress >= 1) {
zoomingIn = false;
zoomingOut = true;
@@ -93,8 +93,8 @@ private void turboUpdate(float tpf){
}
} else if (zoomingOut) {
progress += tpf * zoomSpeed;
float y = lerp(0,Y, easeIn(progress));
spatial.setLocalTranslation(0,y,0);
float y = lerp(0, this.y, easeIn(progress));
spatial.setLocalTranslation(0, y, 0);
if (progress > 1) {
zoomingIn = false;
spatial.removeFromParent();
@@ -103,8 +103,8 @@ private void turboUpdate(float tpf){
}
}
public void shield(){
if(state != null) throw new RuntimeException("another state is avtive");
public void shield() {
if (state != null) throw new RuntimeException("another state is avtive");
state = BonusCard.SHIELD;
zoomingIn = true;
zoomingOut = false;
@@ -112,15 +112,15 @@ public void shield(){
spatial.setLocalScale(1f);
}
public void swap(){
if(state != null) throw new RuntimeException("another state is avtive");
public void swap() {
if (state != null) throw new RuntimeException("another state is avtive");
spatial.setLocalScale(3);
state = BonusCard.SWAP;
progress = -0.2f;
}
public void turbo(){
if(state != null) throw new RuntimeException("another state is avtive");
public void turbo() {
if (state != null) throw new RuntimeException("another state is avtive");
spatial.setLocalScale(2);
state = BonusCard.TURBO;
zoomingIn = true;
@@ -137,7 +137,7 @@ private static float easeOut(float t) {
}
private float easeInOut(float t) {
if(t>1) t=1;
if (t > 1) t = 1;
return (float) -(Math.cos(Math.PI * t) - 1) / 2;
}

View File

@@ -12,15 +12,16 @@ public class ZoomControl extends AbstractControl {
private float zoomSpeed = 1f;
private float zoomFactor = 1f;
public ZoomControl(){}
public ZoomControl() {
}
public ZoomControl(float speed) {
zoomSpeed = speed;
}
@Override
public void setSpatial(Spatial spatial){
if(this.spatial == null && spatial != null){
public void setSpatial(Spatial spatial) {
if (this.spatial == null && spatial != null) {
super.setSpatial(spatial);
initSpatial();
}
@@ -51,7 +52,7 @@ protected void controlUpdate(float tpf) {
}
}
private void end(){
private void end() {
spatial.removeFromParent();
spatial.removeControl(this);
}
@@ -65,14 +66,15 @@ private static float lerp(float start, float end, float t) {
return (1 - t) * start + t * end;
}
// private static float easeOut(float t) {
// private static float easeOut(float t) {
// return (float) Math.sqrt(1 - Math.pow(t - 1, 2));
// }
private float easeOut(float x) {
private float easeOut(float x) {
return x == 1 ? 1 : (float) (1 - Math.pow(2, -10 * x));
}
// private float easeIn(float t) {
// private float easeIn(float t) {
// return t * t * t * t;
// }
private float easeIn(float x) {

View File

@@ -14,6 +14,7 @@
import java.io.IOException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.net.InetAddress;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
@@ -52,6 +53,7 @@ public MdgaServer(int port) {
LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
logic = new ServerGameLogic(this, new Game());
}
/**
*
*/
@@ -67,13 +69,13 @@ public void run() {
private void startServer() {
try {
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
myServer = Network.createServer(port);
initializeSerializables();
myServer.start();
registerListeners();
LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS
}
catch (IOException e) {
} catch (IOException e) {
LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS
exit(1);
}
@@ -190,6 +192,7 @@ private void messageReceived(HostedConnection source, ClientMessage message) {
@Override
public void connectionAdded(Server server, HostedConnection hostedConnection) {
System.out.println("new connection " + hostedConnection); //NON-NLS
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
}
@@ -250,7 +253,7 @@ public void send(int id, ServerMessage message) {
*/
@Override
public void broadcast(ServerMessage message) {
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
for (Map.Entry<Integer, Player> entry : this.logic.getGame().getPlayers().entrySet()) {
this.send(entry.getKey(), message);
}
}

View File

@@ -102,25 +102,23 @@ private void tryHost() {
if(port >= 1 && port <= 65535) {
app.getModelSynchronize().setName(startDialog.getName());
hostDialog.setHostname(Inet4Address.getLocalHost().getHostAddress());
hostDialog.hostServer();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
// todo: implement
}
hostDialog.connectServerAsClient();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
// todo: implement
}
app.getModelSynchronize().setHost(port);
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return;
}
} catch (NumberFormatException e) {
//nothing
} catch (UnknownHostException e) {
throw new RuntimeException(e);
} catch (NumberFormatException ignored) {
}
hostDialog.resetPort();
@@ -130,7 +128,7 @@ private void tryHost() {
private void tryJoin() {
int port = 0;
String ip = joinDialog.getIpt();
String portText = hostDialog.getPort();
String portText = joinDialog.getPort();
try {
// Validate the port
@@ -138,19 +136,24 @@ private void tryJoin() {
if (port < 1 || port > 65535) {
throw new IllegalArgumentException("Invalid port");
}
joinDialog.setPortNumber(port);
// Validate the IP address
if (isValidIpAddress(ip)) {
app.getModelSynchronize().setName(startDialog.getName());
app.getModelSynchronize().setJoin(ip, port);
joinDialog.setHostname(ip);
joinDialog.connectToServer();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setJoin(ip, port);
return;
}
} catch (IllegalArgumentException e) {
// Invalid input, fall through to reset
}
hostDialog.resetPort();
joinDialog.resetPort();
joinDialog.resetIp();
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
}

View File

@@ -84,10 +84,14 @@ public void update(float tpf) {
}
protected abstract void onEnter();
protected abstract void onLeave();
protected void onUpdate(float tpf) {}
protected void onUpdate(float tpf) {
}
protected abstract void onEnterOverlay(Overlay overlay);
protected abstract void onLeaveOverlay(Overlay overlay);
protected Geometry createBackground(String texturePath) {
@@ -162,9 +166,9 @@ private void leaveAdvanced() {
}
public void pressEscape() {
if(settingsDepth == 0) {
if (settingsDepth == 0) {
enterSettings();
} else if(settingsDepth == 1) {
} else if (settingsDepth == 1) {
leaveSettings();
} else {
leaveAdvanced();
@@ -172,20 +176,20 @@ public void pressEscape() {
}
public void pressForward() {
if(this instanceof MainView mainView) {
if (this instanceof MainView mainView) {
mainView.forward(false);
app.getAcousticHandler().playSound(MdgaSound.BUTTON_PRESSED);
}
if(this instanceof LobbyView lobbyView) {
if (this instanceof LobbyView lobbyView) {
lobbyView.ready();
}
if(this instanceof GameView gameView) {
if (this instanceof GameView gameView) {
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
}
if(this instanceof CeremonyView ceremonyView) {
if (this instanceof CeremonyView ceremonyView) {
ceremonyView.forward();
}
}

View File

@@ -174,9 +174,9 @@ public LobbyState getLobbyState() {
}
/**
* This method will be used to return gameState attribute of ServerGameLogic class.
* This method will be used to return gamestate attribute of ServerGameLogic class.
*
* @return gameState as a GameState object.
* @return gamestate as a GameState object.
*/
public GameState getGameState() {
return this.gameState;
@@ -192,9 +192,9 @@ public InterruptState getInterruptState() {
}
/**
* This method will be used to return ceremonyState attribute of ServerGameLogic class.
* This method will be used to return ceremonystate attribute of ServerGameLogic class.
*
* @return ceremonyState as a CeremonyState object.
* @return ceremonystate as a CeremonyState object.
*/
public CeremonyState getCeremonyState() {
return this.ceremonyState;

View File

@@ -45,7 +45,7 @@ public void exit() {
/**
* This method will be called whenever the server received a JoinedLobbyMessage message.
* It will also get the client id of the player who send this messag
* It will also get the client id of the player who send this message
*
* @param msg as the message which was sent by the player as a JoinedLobbyMessage object.
* @param from as the client id of the player as an Integer.

View File

@@ -0,0 +1,31 @@
package pp.mdga.server.automaton.game.turn.rolldice;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.RollDiceState;
public class FirstRollState extends RollDiceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(FirstRollState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param rollDiceAutomaton as the automaton of the roll dice state as a RollDiceState object.
* @param logic the game logic
*/
public FirstRollState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
super(rollDiceAutomaton, logic);
}
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered FirstRollState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited FirstRollStatte state.");
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server.automaton.game.turn.rolldice;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.RollDiceState;
public class FirstRollStateState {
}