merge dev into test #28
@@ -6,7 +6,7 @@
|
|||||||
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
|
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
<option name="PATTERN" value="pp.mdga.client.board.Outline.*" />
|
<option name="PATTERN" value="pp.mdga.client.board.outline.*" />
|
||||||
<option name="ENABLED" value="true" />
|
<option name="ENABLED" value="true" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</extension>
|
</extension>
|
||||||
@@ -14,4 +14,4 @@
|
|||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ public enum Asset {
|
|||||||
private final String modelPath;
|
private final String modelPath;
|
||||||
private final String diffPath;
|
private final String diffPath;
|
||||||
private final float size;
|
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.
|
* Default constructor. Initializes modelPath and diffPath based on the enum name and sets default size to 1.0.
|
||||||
*/
|
*/
|
||||||
Asset() {
|
Asset() {
|
||||||
String folderFileName = "./" + root + name() + "/" + name();
|
String folderFileName = "./" + ROOT + name() + "/" + name();
|
||||||
this.modelPath = folderFileName + ".j3o";
|
this.modelPath = folderFileName + ".j3o";
|
||||||
this.diffPath = folderFileName + "_diff.png";
|
this.diffPath = folderFileName + "_diff.png";
|
||||||
this.size = 1f;
|
this.size = 1f;
|
||||||
@@ -74,7 +74,7 @@ public enum Asset {
|
|||||||
* @param modelPath Path to the 3D model file.
|
* @param modelPath Path to the 3D model file.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
@@ -86,7 +86,7 @@ public enum Asset {
|
|||||||
* @param size Scaling factor for the asset.
|
* @param size Scaling factor for the asset.
|
||||||
*/
|
*/
|
||||||
Asset(float size) {
|
Asset(float size) {
|
||||||
String folderFileName = "./" + root + name() + "/" + name();
|
String folderFileName = "./" + ROOT + name() + "/" + name();
|
||||||
this.modelPath = folderFileName + ".j3o";
|
this.modelPath = folderFileName + ".j3o";
|
||||||
this.diffPath = folderFileName + "_diff.png";
|
this.diffPath = folderFileName + "_diff.png";
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ enum MusicAsset {
|
|||||||
private final String path;
|
private final String path;
|
||||||
private final boolean loop;
|
private final boolean loop;
|
||||||
private final float subVolume;
|
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.
|
* 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).
|
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
|
||||||
*/
|
*/
|
||||||
MusicAsset(String name, float subVolume) {
|
MusicAsset(String name, float subVolume) {
|
||||||
this.path = root + name;
|
this.path = ROOT + name;
|
||||||
this.loop = false;
|
this.loop = false;
|
||||||
this.subVolume = subVolume;
|
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).
|
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
|
||||||
*/
|
*/
|
||||||
MusicAsset(String name, boolean loop, float subVolume) {
|
MusicAsset(String name, boolean loop, float subVolume) {
|
||||||
this.path = root + name;
|
this.path = ROOT + name;
|
||||||
this.loop = loop;
|
this.loop = loop;
|
||||||
this.subVolume = subVolume;
|
this.subVolume = subVolume;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -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;
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.board.Outline.SelectObjectOutliner;
|
import pp.mdga.client.board.outline.SelectObjectOutliner;
|
||||||
|
|
||||||
public class OutlineControl extends AbstractControl {
|
public class OutlineControl extends AbstractControl {
|
||||||
private static final int THICKNESS_DEFAULT = 6;
|
private static final int THICKNESS_DEFAULT = 6;
|
||||||
|
|||||||
@@ -197,14 +197,14 @@ protected void setImageRelative(Picture picture) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final float LARGER = 10;
|
final float larger = 10;
|
||||||
|
|
||||||
picture.setWidth(instance.getPreferredSize().x + LARGER);
|
picture.setWidth(instance.getPreferredSize().x + larger);
|
||||||
picture.setHeight(instance.getPreferredSize().y + LARGER);
|
picture.setHeight(instance.getPreferredSize().y + larger);
|
||||||
|
|
||||||
picture.setLocalTranslation(
|
picture.setLocalTranslation(
|
||||||
instance.getLocalTranslation().x - LARGER / 2,
|
instance.getLocalTranslation().x - larger / 2,
|
||||||
(instance.getLocalTranslation().y - picture.getHeight()) + LARGER / 2,
|
(instance.getLocalTranslation().y - picture.getHeight()) + larger / 2,
|
||||||
instance.getLocalTranslation().z + 0.01f
|
instance.getLocalTranslation().z + 0.01f
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,5 +28,6 @@ public void hide() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void onShow();
|
protected abstract void onShow();
|
||||||
protected abstract void onHide ();
|
|
||||||
|
protected abstract void onHide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public void update(float delta) {
|
|||||||
try {
|
try {
|
||||||
this.connectionFuture.get();
|
this.connectionFuture.get();
|
||||||
} catch (ExecutionException ignored) {
|
} catch (ExecutionException ignored) {
|
||||||
|
// todo: implement
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import com.jme3.app.state.AbstractAppState;
|
import com.jme3.app.state.AbstractAppState;
|
||||||
import com.jme3.app.state.AppStateManager;
|
import com.jme3.app.state.AppStateManager;
|
||||||
import com.jme3.light.DirectionalLight;
|
import com.jme3.light.DirectionalLight;
|
||||||
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.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
@@ -15,16 +14,16 @@
|
|||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.shadow.DirectionalLightShadowFilter;
|
import com.jme3.shadow.DirectionalLightShadowFilter;
|
||||||
import com.jme3.shadow.DirectionalLightShadowRenderer;
|
|
||||||
import com.jme3.shadow.EdgeFilteringMode;
|
import com.jme3.shadow.EdgeFilteringMode;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Texture2D;
|
import com.jme3.texture.Texture2D;
|
||||||
import pp.mdga.client.Asset;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CardLayer extends AbstractAppState {
|
public class CardLayer extends AbstractAppState {
|
||||||
|
|
||||||
|
public static final int SHADOWMAP_SIZE = 1024 * 8;
|
||||||
|
|
||||||
private Node root;
|
private Node root;
|
||||||
private Application app;
|
private Application app;
|
||||||
private boolean init;
|
private boolean init;
|
||||||
@@ -43,7 +42,7 @@ public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTextu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(AppStateManager stateManager, Application app ) {
|
public void initialize(AppStateManager stateManager, Application app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
root = new Node("Under gui viewport Root");
|
root = new Node("Under gui viewport Root");
|
||||||
|
|
||||||
@@ -57,11 +56,9 @@ public void initialize(AppStateManager stateManager, Application app ) {
|
|||||||
|
|
||||||
DirectionalLight sun = new DirectionalLight();
|
DirectionalLight sun = new DirectionalLight();
|
||||||
sun.setColor(ColorRGBA.White);
|
sun.setColor(ColorRGBA.White);
|
||||||
sun.setDirection(new Vector3f(.5f,-.5f,-1));
|
sun.setDirection(new Vector3f(.5f, -.5f, -1));
|
||||||
root.addLight(sun);
|
root.addLight(sun);
|
||||||
|
|
||||||
final int SHADOWMAP_SIZE=1024*8;
|
|
||||||
|
|
||||||
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
|
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
|
||||||
dlsf.setLight(sun);
|
dlsf.setLight(sun);
|
||||||
dlsf.setEnabled(true);
|
dlsf.setEnabled(true);
|
||||||
@@ -71,25 +68,24 @@ public void initialize(AppStateManager stateManager, Application app ) {
|
|||||||
|
|
||||||
view.addProcessor(fpp);
|
view.addProcessor(fpp);
|
||||||
|
|
||||||
if(!init) init = true;
|
if (!init) init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown(){
|
public void shutdown() {
|
||||||
cardBuffer.clear();
|
cardBuffer.clear();
|
||||||
root.detachAllChildren();
|
root.detachAllChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(RenderManager rm) {
|
public void render(RenderManager rm) {
|
||||||
root.updateGeometricState();
|
root.updateGeometricState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update( float tpf ) {
|
public void update(float tpf) {
|
||||||
if (init && !cardBuffer.isEmpty()) {
|
if (init && !cardBuffer.isEmpty()) {
|
||||||
for(Spatial spatial : cardBuffer){
|
for (Spatial spatial : cardBuffer) {
|
||||||
root.attachChild(spatial);
|
root.attachChild(spatial);
|
||||||
}
|
}
|
||||||
cardBuffer.clear();
|
cardBuffer.clear();
|
||||||
@@ -97,19 +93,19 @@ public void update( float tpf ) {
|
|||||||
root.updateLogicalState(tpf);
|
root.updateLogicalState(tpf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSpatial(Spatial card){
|
public void addSpatial(Spatial card) {
|
||||||
cardBuffer.add(card);
|
cardBuffer.add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSpatial(Spatial spatial){
|
public void deleteSpatial(Spatial spatial) {
|
||||||
root.detachChild(spatial);
|
root.detachChild(spatial);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Camera getOverlayCam(){
|
public Camera getOverlayCam() {
|
||||||
return overlayCam;
|
return overlayCam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node getRootNode(){
|
public Node getRootNode() {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,13 @@ public class SymbolControl extends AbstractControl {
|
|||||||
private BonusCard state;
|
private BonusCard state;
|
||||||
private float rotationSpeed = 0.8f;
|
private float rotationSpeed = 0.8f;
|
||||||
private Quaternion initialRotation = null;
|
private Quaternion initialRotation = null;
|
||||||
private float Y = 5;
|
private float y = 5;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void controlUpdate(float tpf) {
|
protected void controlUpdate(float tpf) {
|
||||||
if(state == null) return;
|
if (state == null) return;
|
||||||
switch (state){
|
switch (state) {
|
||||||
case SHIELD -> shieldUpdate(tpf);
|
case SHIELD -> shieldUpdate(tpf);
|
||||||
case SWAP -> swapUpdate(tpf);
|
case SWAP -> swapUpdate(tpf);
|
||||||
case TURBO -> turboUpdate(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) {
|
if (zoomingIn) {
|
||||||
progress += tpf * zoomSpeed;
|
progress += tpf * zoomSpeed;
|
||||||
if (progress > 1) progress = 1;
|
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) {
|
if (initialRotation == null) {
|
||||||
initialRotation = spatial.getLocalRotation().clone();
|
initialRotation = spatial.getLocalRotation().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
progress += tpf*rotationSpeed;
|
progress += tpf * rotationSpeed;
|
||||||
if(progress < 0) return;
|
if (progress < 0) return;
|
||||||
|
|
||||||
float angle = lerp(0, 360, easeInOut(progress));
|
float angle = lerp(0, 360, easeInOut(progress));
|
||||||
|
|
||||||
@@ -80,12 +79,13 @@ private void swapUpdate(float tpf){
|
|||||||
spatial.removeFromParent();
|
spatial.removeFromParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void turboUpdate(float tpf){
|
|
||||||
|
private void turboUpdate(float tpf) {
|
||||||
if (zoomingIn) {
|
if (zoomingIn) {
|
||||||
progress += tpf * zoomSpeed;
|
progress += tpf * zoomSpeed;
|
||||||
if (progress > 1) progress = 1;
|
if (progress > 1) progress = 1;
|
||||||
float y = lerp(-Y,0, easeOut(progress));
|
float y = lerp(-this.y, 0, easeOut(progress));
|
||||||
spatial.setLocalTranslation(0,y,0);
|
spatial.setLocalTranslation(0, y, 0);
|
||||||
if (progress >= 1) {
|
if (progress >= 1) {
|
||||||
zoomingIn = false;
|
zoomingIn = false;
|
||||||
zoomingOut = true;
|
zoomingOut = true;
|
||||||
@@ -93,8 +93,8 @@ private void turboUpdate(float tpf){
|
|||||||
}
|
}
|
||||||
} else if (zoomingOut) {
|
} else if (zoomingOut) {
|
||||||
progress += tpf * zoomSpeed;
|
progress += tpf * zoomSpeed;
|
||||||
float y = lerp(0,Y, easeIn(progress));
|
float y = lerp(0, this.y, easeIn(progress));
|
||||||
spatial.setLocalTranslation(0,y,0);
|
spatial.setLocalTranslation(0, y, 0);
|
||||||
if (progress > 1) {
|
if (progress > 1) {
|
||||||
zoomingIn = false;
|
zoomingIn = false;
|
||||||
spatial.removeFromParent();
|
spatial.removeFromParent();
|
||||||
@@ -103,8 +103,8 @@ private void turboUpdate(float tpf){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shield(){
|
public void shield() {
|
||||||
if(state != null) throw new RuntimeException("another state is avtive");
|
if (state != null) throw new RuntimeException("another state is avtive");
|
||||||
state = BonusCard.SHIELD;
|
state = BonusCard.SHIELD;
|
||||||
zoomingIn = true;
|
zoomingIn = true;
|
||||||
zoomingOut = false;
|
zoomingOut = false;
|
||||||
@@ -112,15 +112,15 @@ public void shield(){
|
|||||||
spatial.setLocalScale(1f);
|
spatial.setLocalScale(1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void swap(){
|
public void swap() {
|
||||||
if(state != null) throw new RuntimeException("another state is avtive");
|
if (state != null) throw new RuntimeException("another state is avtive");
|
||||||
spatial.setLocalScale(3);
|
spatial.setLocalScale(3);
|
||||||
state = BonusCard.SWAP;
|
state = BonusCard.SWAP;
|
||||||
progress = -0.2f;
|
progress = -0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turbo(){
|
public void turbo() {
|
||||||
if(state != null) throw new RuntimeException("another state is avtive");
|
if (state != null) throw new RuntimeException("another state is avtive");
|
||||||
spatial.setLocalScale(2);
|
spatial.setLocalScale(2);
|
||||||
state = BonusCard.TURBO;
|
state = BonusCard.TURBO;
|
||||||
zoomingIn = true;
|
zoomingIn = true;
|
||||||
@@ -137,7 +137,7 @@ private static float easeOut(float t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private float easeInOut(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;
|
return (float) -(Math.cos(Math.PI * t) - 1) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,16 @@ public class ZoomControl extends AbstractControl {
|
|||||||
private float zoomSpeed = 1f;
|
private float zoomSpeed = 1f;
|
||||||
private float zoomFactor = 1f;
|
private float zoomFactor = 1f;
|
||||||
|
|
||||||
public ZoomControl(){}
|
public ZoomControl() {
|
||||||
|
}
|
||||||
|
|
||||||
public ZoomControl(float speed) {
|
public ZoomControl(float speed) {
|
||||||
zoomSpeed = speed;
|
zoomSpeed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSpatial(Spatial spatial){
|
public void setSpatial(Spatial spatial) {
|
||||||
if(this.spatial == null && spatial != null){
|
if (this.spatial == null && spatial != null) {
|
||||||
super.setSpatial(spatial);
|
super.setSpatial(spatial);
|
||||||
initSpatial();
|
initSpatial();
|
||||||
}
|
}
|
||||||
@@ -51,7 +52,7 @@ protected void controlUpdate(float tpf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void end(){
|
private void end() {
|
||||||
spatial.removeFromParent();
|
spatial.removeFromParent();
|
||||||
spatial.removeControl(this);
|
spatial.removeControl(this);
|
||||||
}
|
}
|
||||||
@@ -65,14 +66,15 @@ private static float lerp(float start, float end, float t) {
|
|||||||
return (1 - t) * start + t * end;
|
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));
|
// 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));
|
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;
|
// return t * t * t * t;
|
||||||
// }
|
// }
|
||||||
private float easeIn(float x) {
|
private float easeIn(float x) {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public MdgaServer(int port) {
|
|||||||
LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
|
LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
|
||||||
logic = new ServerGameLogic(this, new Game());
|
logic = new ServerGameLogic(this, new Game());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -74,8 +75,7 @@ private void startServer() {
|
|||||||
myServer.start();
|
myServer.start();
|
||||||
registerListeners();
|
registerListeners();
|
||||||
LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS
|
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
|
LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,7 @@ public void send(int id, ServerMessage message) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void broadcast(ServerMessage message) {
|
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);
|
this.send(entry.getKey(), message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,11 +106,13 @@ private void tryHost() {
|
|||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
// todo: implement
|
||||||
}
|
}
|
||||||
hostDialog.connectServerAsClient();
|
hostDialog.connectServerAsClient();
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
// todo: implement
|
||||||
}
|
}
|
||||||
app.getModelSynchronize().setHost(port);
|
app.getModelSynchronize().setHost(port);
|
||||||
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
|
|||||||
@@ -84,10 +84,14 @@ public void update(float tpf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void onEnter();
|
protected abstract void onEnter();
|
||||||
|
|
||||||
protected abstract void onLeave();
|
protected abstract void onLeave();
|
||||||
protected void onUpdate(float tpf) {}
|
|
||||||
|
protected void onUpdate(float tpf) {
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void onEnterOverlay(Overlay overlay);
|
protected abstract void onEnterOverlay(Overlay overlay);
|
||||||
|
|
||||||
protected abstract void onLeaveOverlay(Overlay overlay);
|
protected abstract void onLeaveOverlay(Overlay overlay);
|
||||||
|
|
||||||
protected Geometry createBackground(String texturePath) {
|
protected Geometry createBackground(String texturePath) {
|
||||||
@@ -162,9 +166,9 @@ private void leaveAdvanced() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void pressEscape() {
|
public void pressEscape() {
|
||||||
if(settingsDepth == 0) {
|
if (settingsDepth == 0) {
|
||||||
enterSettings();
|
enterSettings();
|
||||||
} else if(settingsDepth == 1) {
|
} else if (settingsDepth == 1) {
|
||||||
leaveSettings();
|
leaveSettings();
|
||||||
} else {
|
} else {
|
||||||
leaveAdvanced();
|
leaveAdvanced();
|
||||||
@@ -172,20 +176,20 @@ public void pressEscape() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void pressForward() {
|
public void pressForward() {
|
||||||
if(this instanceof MainView mainView) {
|
if (this instanceof MainView mainView) {
|
||||||
mainView.forward(false);
|
mainView.forward(false);
|
||||||
app.getAcousticHandler().playSound(MdgaSound.BUTTON_PRESSED);
|
app.getAcousticHandler().playSound(MdgaSound.BUTTON_PRESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this instanceof LobbyView lobbyView) {
|
if (this instanceof LobbyView lobbyView) {
|
||||||
lobbyView.ready();
|
lobbyView.ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this instanceof GameView gameView) {
|
if (this instanceof GameView gameView) {
|
||||||
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this instanceof CeremonyView ceremonyView) {
|
if (this instanceof CeremonyView ceremonyView) {
|
||||||
ceremonyView.forward();
|
ceremonyView.forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.ceremonyState.CeremonyStates;
|
import pp.mdga.client.ceremonystate.CeremonyStates;
|
||||||
import pp.mdga.client.ceremonyState.PodiumState;
|
import pp.mdga.client.ceremonystate.PodiumState;
|
||||||
import pp.mdga.client.ceremonyState.StatisticsState;
|
import pp.mdga.client.ceremonystate.StatisticsState;
|
||||||
import pp.mdga.notification.CeremonyNotification;
|
|
||||||
|
|
||||||
public class CeremonyState extends ClientState {
|
public class CeremonyState extends ClientState {
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.dialogState.DialogStates;
|
import pp.mdga.client.dialogstate.DialogStates;
|
||||||
import pp.mdga.client.dialogState.LobbyState;
|
import pp.mdga.client.dialogstate.LobbyState;
|
||||||
import pp.mdga.client.dialogState.NetworkDialogState;
|
import pp.mdga.client.dialogstate.NetworkDialogState;
|
||||||
import pp.mdga.client.dialogState.StartDialogState;
|
import pp.mdga.client.dialogstate.StartDialogState;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.gameState.*;
|
import pp.mdga.client.gamestate.*;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.settingsState.AudioSettingsState;
|
import pp.mdga.client.settingsstate.AudioSettingsState;
|
||||||
import pp.mdga.client.settingsState.MainSettingsState;
|
import pp.mdga.client.settingsstate.MainSettingsState;
|
||||||
import pp.mdga.client.settingsState.SettingStates;
|
import pp.mdga.client.settingsstate.SettingStates;
|
||||||
import pp.mdga.client.settingsState.VideoSettingsState;
|
import pp.mdga.client.settingsstate.VideoSettingsState;
|
||||||
|
|
||||||
public class SettingsState extends ClientState {
|
public class SettingsState extends ClientState {
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package pp.mdga.client.ceremonyState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public abstract class CeremonyStates extends ClientState {
|
|
||||||
protected CeremonyStates(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package pp.mdga.client.ceremonyState;
|
|
||||||
|
|
||||||
import pp.mdga.client.CeremonyState;
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public class PodiumState extends CeremonyStates {
|
|
||||||
|
|
||||||
private final CeremonyState parent;
|
|
||||||
|
|
||||||
public PodiumState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (CeremonyState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectNext(){
|
|
||||||
parent.setState(parent.getStatisticsState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package pp.mdga.client.ceremonyState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public class StatisticsState extends CeremonyStates {
|
|
||||||
public StatisticsState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectNext(){
|
|
||||||
logic.setState(logic.getDialogs());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package pp.mdga.client.dialogState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public abstract class DialogStates extends ClientState {
|
|
||||||
|
|
||||||
public DialogStates(ClientState parent, ClientGameLogic logic){
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
package pp.mdga.client.dialogState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.DialogsState;
|
|
||||||
import pp.mdga.game.Color;
|
|
||||||
import pp.mdga.game.Player;
|
|
||||||
import pp.mdga.message.client.*;
|
|
||||||
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
|
|
||||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
|
||||||
import pp.mdga.message.server.ServerStartGameMessage;
|
|
||||||
import pp.mdga.message.server.UpdateReadyMessage;
|
|
||||||
import pp.mdga.message.server.UpdateTSKMessage;
|
|
||||||
import pp.mdga.notification.LobbyReadyNotification;
|
|
||||||
import pp.mdga.notification.TskSelectNotification;
|
|
||||||
import pp.mdga.notification.TskUnselectNotification;
|
|
||||||
|
|
||||||
public class LobbyState extends DialogStates {
|
|
||||||
|
|
||||||
private final DialogsState parent;
|
|
||||||
|
|
||||||
public LobbyState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (DialogsState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
logic.send(new JoinedLobbyMessage(parent.getOwnPlayerName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectLeave() {
|
|
||||||
parent.setState(parent.getStartDialog());
|
|
||||||
logic.send(new LeaveGameMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectTSK(Color color) {
|
|
||||||
logic.send(new SelectTSKMessage(color));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deselectTSK(Color color) {
|
|
||||||
logic.send(new DeselectTSKMessage(color));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectReady() {
|
|
||||||
logic.send(new LobbyReadyMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectUnready(){
|
|
||||||
logic.send(new LobbyNotReadyMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectStart(){
|
|
||||||
if(logic.isHost() && logic.getGame().allReady()){
|
|
||||||
logic.send(new StartGameMessage(false));
|
|
||||||
} else if(logic.isHost() && !logic.getGame().allReady()) {
|
|
||||||
logic.send(new StartGameMessage(true));
|
|
||||||
} else {
|
|
||||||
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(ServerStartGameMessage msg){
|
|
||||||
parent.startGame();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(LobbyPlayerJoinedMessage msg){
|
|
||||||
logic.addNotification(new TskSelectNotification(msg.getPlayer().getColor(), msg.getPlayer().getName(), parent.getOwnPlayerId()== msg.getId()));
|
|
||||||
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(UpdateTSKMessage msg){
|
|
||||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
|
||||||
logic.getGame().getPlayers().get(msg.getId()).setColor(msg.getColor());
|
|
||||||
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), parent.getOwnPlayerId()== msg.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(LobbyPlayerLeaveMessage msg){
|
|
||||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
|
||||||
logic.getGame().getPlayers().remove(msg.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(UpdateReadyMessage msg){
|
|
||||||
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
|
|
||||||
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
package pp.mdga.client.dialogState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.DialogsState;
|
|
||||||
import pp.mdga.notification.LobbyDialogNotification;
|
|
||||||
|
|
||||||
public class NetworkDialogState extends DialogStates {
|
|
||||||
|
|
||||||
private final DialogsState parent;
|
|
||||||
|
|
||||||
public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (DialogsState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkIP(String IP){
|
|
||||||
String[] parts = IP.split("\\.");
|
|
||||||
|
|
||||||
// Step 2: Check if there are exactly 4 parts
|
|
||||||
if (parts.length != 4) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 3: Check each part for valid number
|
|
||||||
for (String part : parts) {
|
|
||||||
try {
|
|
||||||
// Step 4: Convert each part into a number
|
|
||||||
int num = Integer.parseInt(part);
|
|
||||||
|
|
||||||
// Step 5: Check whether the number lies in between 0 and 255
|
|
||||||
if (num < 0 || num > 255) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// If parsing fails, it's not a valid number
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If all checks passed, return true
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectLeave() {
|
|
||||||
parent.setState(parent.getStartDialog());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectJoin(String IP) {
|
|
||||||
parent.setState(parent.getLobby());
|
|
||||||
logic.addNotification(new LobbyDialogNotification());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package pp.mdga.client.dialogState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.DialogsState;
|
|
||||||
|
|
||||||
public class StartDialogState extends DialogStates {
|
|
||||||
|
|
||||||
private final DialogsState parent;
|
|
||||||
|
|
||||||
public StartDialogState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (DialogsState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectJoin(String name) {
|
|
||||||
parent.setOwnPlayerName(name);
|
|
||||||
parent.setState(parent.getNetworkDialog());
|
|
||||||
logic.setHost(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectHost(String name) {
|
|
||||||
parent.setOwnPlayerName(name);
|
|
||||||
parent.setState(parent.getLobby());
|
|
||||||
logic.setHost(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
parent.setState(parent.getNetworkDialog());
|
|
||||||
parent.setOwnPlayerName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectLeave() {
|
|
||||||
parent.exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package pp.mdga.client.gameState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.GameState;
|
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
|
||||||
|
|
||||||
public class AnimationState extends GameStates {
|
|
||||||
|
|
||||||
private final GameState parent;
|
|
||||||
|
|
||||||
public AnimationState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (GameState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectAnimationEnd(){
|
|
||||||
logic.send(new AnimationEndMessage());
|
|
||||||
parent.setState(parent.getWaiting());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package pp.mdga.client.gameState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.GameState;
|
|
||||||
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
|
|
||||||
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
|
|
||||||
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
|
|
||||||
import pp.mdga.message.server.DieMessage;
|
|
||||||
import pp.mdga.message.server.RankingResponseMessage;
|
|
||||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
|
||||||
|
|
||||||
public class DetermineStartPlayerState extends GameStates {
|
|
||||||
|
|
||||||
private final GameState parent;
|
|
||||||
private DetermineStartPlayerStates state;
|
|
||||||
|
|
||||||
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
|
|
||||||
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
|
||||||
|
|
||||||
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (GameState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
state = rollRankingDiceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
state = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(DetermineStartPlayerStates state) {
|
|
||||||
this.state.exit();
|
|
||||||
state.enter();
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectDice() {
|
|
||||||
state.selectDice();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DieMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(RankingRollAgainMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(RankingResponseMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RollRankingDiceState getRollRankingDice() {
|
|
||||||
return rollRankingDiceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WaitRankingState getWaitRanking() {
|
|
||||||
return waitRankingState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DetermineStartPlayerStates getState(){
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameState getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package pp.mdga.client.gameState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.game.PieceState;
|
|
||||||
import pp.mdga.game.ShieldState;
|
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
|
||||||
import pp.mdga.notification.ShieldActiveNotification;
|
|
||||||
import pp.mdga.notification.ShieldSuppressedNotification;
|
|
||||||
import pp.mdga.notification.SwapPieceNotification;
|
|
||||||
import pp.mdga.notification.ThrowPieceNotification;
|
|
||||||
|
|
||||||
public abstract class GameStates extends ClientState {
|
|
||||||
public GameStates(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handlePowerCard(PlayCardMessage msg){
|
|
||||||
if (msg.getCard().equals(BonusCard.TURBO)){
|
|
||||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
|
||||||
} else if (msg.getCard().equals(BonusCard.SHIELD)){
|
|
||||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
|
||||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
|
||||||
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
|
||||||
} else {
|
|
||||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
|
||||||
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
|
||||||
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
|
|
||||||
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
|
|
||||||
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
|
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
|
|
||||||
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
|
|
||||||
}
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard());
|
|
||||||
logic.getGame().getDiscardPile().add(msg.getCard());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void throwPiece(Piece piece){
|
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
|
||||||
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
|
|
||||||
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
|
||||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
|
||||||
piece.setState(PieceState.WAITING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
package pp.mdga.client.gameState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.GameState;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.server.*;
|
|
||||||
import pp.mdga.notification.*;
|
|
||||||
|
|
||||||
public class SpectatorState extends GameStates {
|
|
||||||
|
|
||||||
private final GameState parent;
|
|
||||||
|
|
||||||
public SpectatorState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (GameState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(CeremonyMessage msg){
|
|
||||||
logic.setState(logic.getCeremony());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DieMessage msg){
|
|
||||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
|
||||||
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
|
||||||
if(msg.getDiceEye() == 6){
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
|
||||||
logic.getGame().getGameStatistics().increaseDiced6();
|
|
||||||
}
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PlayCardMessage msg){
|
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
|
||||||
handlePowerCard(msg);
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
|
||||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(ActivePlayerMessage msg){
|
|
||||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
|
||||||
logic.getGame().setActiveColor(msg.getColor());
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(MoveMessage msg){
|
|
||||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
|
||||||
if (msg.isHomeMove()){
|
|
||||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
|
||||||
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
|
||||||
} else {
|
|
||||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
|
||||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
|
||||||
logic.getGame().getGameStatistics().increasePiecesThrown();
|
|
||||||
}
|
|
||||||
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
|
|
||||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
|
||||||
} else {
|
|
||||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
|
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
package pp.mdga.client.gameState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.GameState;
|
|
||||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
|
||||||
import pp.mdga.client.gameState.turnState.MovePieceState;
|
|
||||||
import pp.mdga.client.gameState.turnState.PlayPowerCardState;
|
|
||||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
|
||||||
import pp.mdga.client.gameState.turnState.RollDiceState;
|
|
||||||
import pp.mdga.client.gameState.turnState.TurnStates;
|
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.server.*;
|
|
||||||
|
|
||||||
public class TurnState extends GameStates {
|
|
||||||
|
|
||||||
private GameState parent;
|
|
||||||
private TurnStates state;
|
|
||||||
|
|
||||||
private final ChoosePieceState choosePieceState = new ChoosePieceState(this, logic);
|
|
||||||
private final MovePieceState movePieceState = new MovePieceState(this, logic);
|
|
||||||
private final PlayPowerCardState playPowerCardState = new PlayPowerCardState(this, logic);
|
|
||||||
private final PowerCardState powerCardState = new PowerCardState(this, logic);
|
|
||||||
private final RollDiceState rollDiceState = new RollDiceState(this, logic);
|
|
||||||
|
|
||||||
public TurnState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (GameState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
state = powerCardState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
state = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(TurnStates state){
|
|
||||||
this.state.exit();
|
|
||||||
state.enter();
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectPiece(Piece piece){
|
|
||||||
state.selectPiece(piece);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectCard(BonusCard card){
|
|
||||||
state.selectCard(card);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectAnimationEnd(){
|
|
||||||
state.selectAnimationEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(SelectPieceMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(WaitPieceMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(StartPieceMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(NoTurnMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(MoveMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(CeremonyMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(EndOfTurnMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(SpectatorMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DiceAgainMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PossibleCardMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PlayCardMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DiceNowMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DieMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChoosePieceState getChoosePiece() {
|
|
||||||
return choosePieceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MovePieceState getMovePiece() {
|
|
||||||
return movePieceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayPowerCardState getPlayPowerCard() {
|
|
||||||
return playPowerCardState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PowerCardState getPowerCard() {
|
|
||||||
return powerCardState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RollDiceState getRollDice() {
|
|
||||||
return rollDiceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameState getParent(){
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TurnStates getState(){
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
package pp.mdga.client.gameState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.GameState;
|
|
||||||
import pp.mdga.game.*;
|
|
||||||
import pp.mdga.message.server.*;
|
|
||||||
import pp.mdga.notification.*;
|
|
||||||
|
|
||||||
public class WaitingState extends GameStates {
|
|
||||||
|
|
||||||
private final GameState parent;
|
|
||||||
|
|
||||||
public WaitingState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (GameState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(CeremonyMessage msg){
|
|
||||||
logic.setState(logic.getCeremony());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DiceNowMessage msg){
|
|
||||||
logic.addNotification(new DiceNowNotification());
|
|
||||||
parent.setState(parent.getTurn());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DieMessage msg){
|
|
||||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
|
||||||
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
|
||||||
if(msg.getDiceEye() == 6){
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
|
||||||
logic.getGame().getGameStatistics().increaseDiced6();
|
|
||||||
}
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PlayCardMessage msg){
|
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
|
||||||
handlePowerCard(msg);
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
|
||||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(ActivePlayerMessage msg){
|
|
||||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
|
||||||
logic.getGame().setActiveColor(msg.getColor());
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(MoveMessage msg){
|
|
||||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
|
||||||
if (msg.isHomeMove()){
|
|
||||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
|
||||||
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
|
||||||
for(int i = msg.getTargetIndex() + 1; i < 4; i++){
|
|
||||||
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
|
|
||||||
pieceToMove.setState(PieceState.HOME);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pieceToMove.setState(PieceState.HOMEFINISHED);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
|
||||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
|
||||||
logic.getGame().getGameStatistics().increasePiecesThrown();
|
|
||||||
}
|
|
||||||
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
|
|
||||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
|
||||||
} else {
|
|
||||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
|
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent.setState(parent.getAnimation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.determineStartPlayerState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.GameStates;
|
|
||||||
|
|
||||||
public abstract class DetermineStartPlayerStates extends GameStates {
|
|
||||||
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.determineStartPlayerState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
|
||||||
import pp.mdga.message.client.RequestDieMessage;
|
|
||||||
import pp.mdga.message.server.DieMessage;
|
|
||||||
import pp.mdga.notification.DiceNowNotification;
|
|
||||||
|
|
||||||
public class RollRankingDiceState extends DetermineStartPlayerStates {
|
|
||||||
|
|
||||||
private final DetermineStartPlayerState parent;
|
|
||||||
|
|
||||||
public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (DetermineStartPlayerState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
logic.addNotification(new DiceNowNotification());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectDice(){
|
|
||||||
logic.send(new RequestDieMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DieMessage msg){
|
|
||||||
parent.setState(parent.getWaitRanking());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.determineStartPlayerState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
|
||||||
import pp.mdga.message.server.RankingResponseMessage;
|
|
||||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
|
||||||
import pp.mdga.notification.ActivePlayerNotification;
|
|
||||||
|
|
||||||
public class WaitRankingState extends DetermineStartPlayerStates {
|
|
||||||
|
|
||||||
private final DetermineStartPlayerState parent;
|
|
||||||
|
|
||||||
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (DetermineStartPlayerState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(RankingRollAgainMessage msg){
|
|
||||||
parent.setState(parent.getRollRankingDice());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(RankingResponseMessage msg){
|
|
||||||
logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
|
|
||||||
logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
|
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.TurnState;
|
|
||||||
import pp.mdga.client.gameState.turnState.choosePieceState.*;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.server.*;
|
|
||||||
|
|
||||||
public class ChoosePieceState extends TurnStates {
|
|
||||||
|
|
||||||
private TurnState parent;
|
|
||||||
private ChoosePieceStates currentState;
|
|
||||||
|
|
||||||
private final NoPieceState noPieceState = new NoPieceState(this, logic);
|
|
||||||
private final SelectPieceState selectPieceState = new SelectPieceState(this, logic);
|
|
||||||
private final StartPieceState startPieceState = new StartPieceState(this, logic);
|
|
||||||
private final WaitingPieceState waitingPieceState = new WaitingPieceState(this, logic);
|
|
||||||
|
|
||||||
public ChoosePieceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (TurnState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
currentState = noPieceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
currentState.exit();
|
|
||||||
currentState= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(ChoosePieceStates state){
|
|
||||||
currentState.exit();
|
|
||||||
currentState = state;
|
|
||||||
currentState.enter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectPiece(Piece piece){
|
|
||||||
currentState.selectPiece(piece);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(SelectPieceMessage msg){
|
|
||||||
currentState.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(WaitPieceMessage msg){
|
|
||||||
currentState.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(StartPieceMessage msg){
|
|
||||||
currentState.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(NoTurnMessage msg){
|
|
||||||
currentState.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(MoveMessage msg){
|
|
||||||
currentState.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NoPieceState getNoPiece(){
|
|
||||||
return noPieceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SelectPieceState getSelectPiece(){
|
|
||||||
return selectPieceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StartPieceState getStartPiece(){
|
|
||||||
return startPieceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WaitingPieceState getWaitingPiece(){
|
|
||||||
return waitingPieceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChoosePieceStates getState(){
|
|
||||||
return currentState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TurnState getParent(){
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.TurnState;
|
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
|
||||||
import pp.mdga.message.server.*;
|
|
||||||
|
|
||||||
public class MovePieceState extends TurnStates {
|
|
||||||
|
|
||||||
private final TurnState parent;
|
|
||||||
|
|
||||||
public MovePieceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (TurnState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectAnimationEnd(){
|
|
||||||
logic.send(new AnimationEndMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(CeremonyMessage msg){
|
|
||||||
logic.setState(logic.getCeremony());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(EndOfTurnMessage msg){
|
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(SpectatorMessage msg){
|
|
||||||
parent.getParent().setState(parent.getParent().getSpectator());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DiceAgainMessage msg){
|
|
||||||
parent.setState(parent.getRollDice());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TurnState getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.TurnState;
|
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
|
||||||
import pp.mdga.notification.PlayCardNotification;
|
|
||||||
|
|
||||||
public class PlayPowerCardState extends TurnStates {
|
|
||||||
|
|
||||||
private final TurnState parent;
|
|
||||||
|
|
||||||
private PlayCardMessage playCardMessage;
|
|
||||||
|
|
||||||
public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (TurnState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
|
|
||||||
handlePowerCard(playCardMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
playCardMessage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayCard(PlayCardMessage playCardMessage) {
|
|
||||||
this.playCardMessage = playCardMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectAnimationEnd(){
|
|
||||||
parent.setState(parent.getRollDice());
|
|
||||||
logic.send(new AnimationEndMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.TurnState;
|
|
||||||
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState;
|
|
||||||
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates;
|
|
||||||
import pp.mdga.client.gameState.turnState.powerCardState.ShieldState;
|
|
||||||
import pp.mdga.client.gameState.turnState.powerCardState.SwapState;
|
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.server.DiceNowMessage;
|
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
|
||||||
import pp.mdga.message.server.PossibleCardMessage;
|
|
||||||
import pp.mdga.message.server.PossiblePieceMessage;
|
|
||||||
|
|
||||||
public class PowerCardState extends TurnStates {
|
|
||||||
|
|
||||||
private final TurnState parent;
|
|
||||||
private PowerCardStates state;
|
|
||||||
|
|
||||||
private final ChoosePowerCardState choosePowerCardState = new ChoosePowerCardState(this, logic);
|
|
||||||
private final ShieldState shieldState = new ShieldState(this, logic);
|
|
||||||
private final SwapState swapState = new SwapState(this, logic);
|
|
||||||
|
|
||||||
|
|
||||||
public PowerCardState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (TurnState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
state = choosePowerCardState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void exit() {
|
|
||||||
state.exit();
|
|
||||||
state = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(PowerCardStates state) {
|
|
||||||
this.state.exit();
|
|
||||||
state.enter();
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PossibleCardMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PlayCardMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DiceNowMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PossiblePieceMessage msg){
|
|
||||||
state.received(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectCard(BonusCard card) {
|
|
||||||
state.selectCard(card);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectPiece(Piece piece) {
|
|
||||||
state.selectPiece(piece);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChoosePowerCardState getChoosePowerCard() {
|
|
||||||
return choosePowerCardState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShieldState getShield() {
|
|
||||||
return shieldState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SwapState getSwap() {
|
|
||||||
return swapState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TurnState getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PowerCardStates getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.TurnState;
|
|
||||||
import pp.mdga.message.server.DieMessage;
|
|
||||||
import pp.mdga.message.server.NoTurnMessage;
|
|
||||||
|
|
||||||
public class RollDiceState extends TurnStates {
|
|
||||||
|
|
||||||
private final TurnState parent;
|
|
||||||
|
|
||||||
public RollDiceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (TurnState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
logic.getGame().setDiceModifier(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TurnState getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void received(DieMessage msg){
|
|
||||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
|
||||||
parent.setState(parent.getChoosePiece());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(NoTurnMessage msg){
|
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.GameStates;
|
|
||||||
|
|
||||||
public abstract class TurnStates extends GameStates {
|
|
||||||
public TurnStates(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.TurnStates;
|
|
||||||
|
|
||||||
public abstract class ChoosePieceStates extends TurnStates {
|
|
||||||
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.server.*;
|
|
||||||
import pp.mdga.message.server.StartPieceMessage;
|
|
||||||
import pp.mdga.notification.MovePieceNotification;
|
|
||||||
import pp.mdga.notification.SelectableMoveNotification;
|
|
||||||
import pp.mdga.notification.WaitMoveNotification;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class NoPieceState extends ChoosePieceStates {
|
|
||||||
|
|
||||||
private final ChoosePieceState parent;
|
|
||||||
|
|
||||||
public NoPieceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (ChoosePieceState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(SelectPieceMessage msg) {
|
|
||||||
parent.setState(parent.getSelectPiece());
|
|
||||||
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new));
|
|
||||||
parent.getSelectPiece().setPossiblePieces(pieces);
|
|
||||||
logic.addNotification(new SelectableMoveNotification(pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new)), msg.getTargetIndex(), msg.getIsHomeMove()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(WaitPieceMessage msg){
|
|
||||||
logic.addNotification(new WaitMoveNotification(msg.getPieceID()));
|
|
||||||
parent.setState(parent.getWaitingPiece());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(StartPieceMessage msg){
|
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
|
||||||
List<UUID> listPiece = new ArrayList<>();
|
|
||||||
List<Integer> listIndex = new ArrayList<>();
|
|
||||||
List<Boolean> homeMove = new ArrayList<>();
|
|
||||||
listPiece.add(piece.getUuid());
|
|
||||||
listIndex.add(msg.getTargetIndex());
|
|
||||||
homeMove.add(false);
|
|
||||||
logic.addNotification(new SelectableMoveNotification(listPiece, listIndex, homeMove));
|
|
||||||
parent.setState(parent.getStartPiece());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(NoTurnMessage msg){
|
|
||||||
parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
|
||||||
import pp.mdga.message.server.MoveMessage;
|
|
||||||
import pp.mdga.notification.HomeMoveNotification;
|
|
||||||
import pp.mdga.notification.MovePieceNotification;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class SelectPieceState extends ChoosePieceStates {
|
|
||||||
|
|
||||||
private final ChoosePieceState parent;
|
|
||||||
private ArrayList<Piece> possiblePieces;
|
|
||||||
|
|
||||||
public SelectPieceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (ChoosePieceState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
possiblePieces = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces){
|
|
||||||
this.possiblePieces = possiblePieces;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectPiece(Piece piece){
|
|
||||||
if(possiblePieces.contains(piece)){
|
|
||||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(MoveMessage msg){
|
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
|
||||||
if(msg.isHomeMove()){
|
|
||||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
|
||||||
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
|
||||||
} else {
|
|
||||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
|
||||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
|
||||||
logic.getGame().getGameStatistics().increasePiecesThrown();
|
|
||||||
}
|
|
||||||
logic.addNotification(new MovePieceNotification(piece.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(piece), msg.getTargetIndex()));
|
|
||||||
}
|
|
||||||
parent.getParent().setState(parent.getParent().getMovePiece());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
|
||||||
import pp.mdga.message.server.MoveMessage;
|
|
||||||
|
|
||||||
public class StartPieceState extends ChoosePieceStates {
|
|
||||||
|
|
||||||
private final ChoosePieceState parent;
|
|
||||||
private Piece moveablePiece;
|
|
||||||
|
|
||||||
|
|
||||||
public StartPieceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (ChoosePieceState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectPiece(Piece piece){
|
|
||||||
if(moveablePiece.equals(piece)){
|
|
||||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(MoveMessage msg){
|
|
||||||
parent.getParent().setState(parent.getParent().getMovePiece());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.game.PieceState;
|
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
|
||||||
import pp.mdga.message.server.MoveMessage;
|
|
||||||
|
|
||||||
public class WaitingPieceState extends ChoosePieceStates {
|
|
||||||
|
|
||||||
private final ChoosePieceState parent;
|
|
||||||
private Piece moveablePiece;
|
|
||||||
|
|
||||||
public WaitingPieceState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (ChoosePieceState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
moveablePiece = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectPiece(Piece piece){
|
|
||||||
if(moveablePiece.equals(piece)){
|
|
||||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(MoveMessage msg){
|
|
||||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
|
||||||
pieceToMove.setState(PieceState.ACTIVE);
|
|
||||||
parent.getParent().setState(parent.getParent().getMovePiece());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
import pp.mdga.message.client.NoPowerCardMessage;
|
|
||||||
import pp.mdga.message.client.SelectCardMessage;
|
|
||||||
import pp.mdga.message.server.DiceNowMessage;
|
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
|
||||||
import pp.mdga.message.server.PossibleCardMessage;
|
|
||||||
import pp.mdga.message.server.PossiblePieceMessage;
|
|
||||||
import pp.mdga.notification.SelectableCardsNotification;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* State where the player can choose a power card
|
|
||||||
*/
|
|
||||||
public class ChoosePowerCardState extends PowerCardStates {
|
|
||||||
|
|
||||||
private final PowerCardState parent;
|
|
||||||
private ArrayList<BonusCard> possibleCards;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param parent parent state
|
|
||||||
* @param logic game logic
|
|
||||||
*/
|
|
||||||
public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (PowerCardState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enter the state
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
possibleCards = new ArrayList<>();
|
|
||||||
//TODO: logic.send(new RequestPossibleCardsMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exit the state
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
possibleCards = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the possible cards
|
|
||||||
* @param msg possible cards message
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void received(PossibleCardMessage msg){
|
|
||||||
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
|
|
||||||
logic.addNotification(new SelectableCardsNotification(possibleCards));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select a card
|
|
||||||
* @param card card to select
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void selectCard(BonusCard card){
|
|
||||||
if(card != null){
|
|
||||||
logic.send(new SelectCardMessage(card));
|
|
||||||
} else {
|
|
||||||
logic.send(new NoPowerCardMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receive a card
|
|
||||||
* @param msg card message
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void received(PlayCardMessage msg){
|
|
||||||
if(msg.getCard().equals(BonusCard.TURBO)){
|
|
||||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
|
||||||
} else {
|
|
||||||
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receive a die now message
|
|
||||||
* @param msg dice now message
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void received(DiceNowMessage msg){
|
|
||||||
parent.getParent().setState(parent.getParent().getRollDice());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receive a possible piece message and decide if the player can swap or shield
|
|
||||||
* @param msg possible piece message
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void received(PossiblePieceMessage msg){
|
|
||||||
if (msg.getEnemyPossiblePieces().isEmpty()){
|
|
||||||
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
|
||||||
parent.setState(parent.getShield());
|
|
||||||
} else {
|
|
||||||
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
|
||||||
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
|
||||||
parent.setState(parent.getSwap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.TurnStates;
|
|
||||||
|
|
||||||
public abstract class PowerCardStates extends TurnStates {
|
|
||||||
public PowerCardStates(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
|
||||||
|
|
||||||
import java.lang.System.Logger.Level;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class ShieldState extends PowerCardStates {
|
|
||||||
|
|
||||||
private final PowerCardState parent;
|
|
||||||
|
|
||||||
private ArrayList<Piece> possiblePieces;
|
|
||||||
|
|
||||||
public ShieldState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (PowerCardState) parent;
|
|
||||||
possiblePieces = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
logic.addNotification(null);
|
|
||||||
//TODO: selectable piece notification
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
possiblePieces = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
|
||||||
this.possiblePieces = possiblePieces;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectPiece(Piece piece) {
|
|
||||||
if (possiblePieces.contains(piece)) {
|
|
||||||
logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid()));
|
|
||||||
} else {
|
|
||||||
LOGGER.log(Level.DEBUG, "Invalid piece selected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PlayCardMessage msg) {
|
|
||||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
|
||||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
|
||||||
import pp.mdga.game.Piece;
|
|
||||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
|
||||||
import pp.mdga.notification.SelectableSwapNotification;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class SwapState extends PowerCardStates {
|
|
||||||
|
|
||||||
private final PowerCardState parent;
|
|
||||||
|
|
||||||
private ArrayList<Piece> possibleOwnPieces;
|
|
||||||
private ArrayList<Piece> possibleEnemyPieces;
|
|
||||||
private Piece selectedOwnPiece;
|
|
||||||
private Piece selectedEnemyPiece;
|
|
||||||
|
|
||||||
public SwapState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (PowerCardState) parent;
|
|
||||||
possibleOwnPieces = new ArrayList<>();
|
|
||||||
possibleEnemyPieces = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
ArrayList<UUID> ownPieces = new ArrayList<>(possibleOwnPieces.stream().map(Piece::getUuid).toList());
|
|
||||||
ArrayList<UUID> enemyPieces = new ArrayList<>(possibleEnemyPieces.stream().map(Piece::getUuid).toList());
|
|
||||||
logic.addNotification(new SelectableSwapNotification(ownPieces, enemyPieces));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
possibleOwnPieces = null;
|
|
||||||
possibleEnemyPieces = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPossibleOwnPieces(ArrayList<Piece> possibleOwnPieces) {
|
|
||||||
this.possibleOwnPieces = possibleOwnPieces;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPossibleEnemyPieces(ArrayList<Piece> possibleEnemyPieces) {
|
|
||||||
this.possibleEnemyPieces = possibleEnemyPieces;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectPiece(Piece piece){
|
|
||||||
if (possibleOwnPieces.contains(piece)){
|
|
||||||
selectedOwnPiece = piece;
|
|
||||||
} else if (possibleEnemyPieces.contains(piece)){
|
|
||||||
selectedEnemyPiece = piece;
|
|
||||||
}
|
|
||||||
if (selectedOwnPiece != null && selectedEnemyPiece != null){
|
|
||||||
logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getUuid(), selectedEnemyPiece.getUuid()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(PlayCardMessage msg) {
|
|
||||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
|
||||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package pp.mdga.client.settingsState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public class AudioSettingsState extends SettingStates {
|
|
||||||
public AudioSettingsState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package pp.mdga.client.settingsState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public class MainSettingsState extends SettingStates {
|
|
||||||
public MainSettingsState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package pp.mdga.client.settingsState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public abstract class SettingStates extends ClientState {
|
|
||||||
public SettingStates(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package pp.mdga.client.settingsState;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
|
|
||||||
public class VideoSettingsState extends SettingStates {
|
|
||||||
public VideoSettingsState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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() {
|
public GameState getGameState() {
|
||||||
return this.gameState;
|
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() {
|
public CeremonyState getCeremonyState() {
|
||||||
return this.ceremonyState;
|
return this.ceremonyState;
|
||||||
|
|||||||
@@ -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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 {
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user