Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
Daniel Grigencha
2024-11-25 16:36:53 +01:00
20 changed files with 3153 additions and 31 deletions

View File

@@ -11,8 +11,8 @@ public class InputSyncronizer {
private InputManager inputManager;
protected boolean rightMousePressed = false;
private float rotationAngle = 0f;
private int scrollValue = 50;
private float rotationAngle = 180f;
private int scrollValue = 0;
InputSyncronizer(MdgaApp app) {
this.app = app;
@@ -22,11 +22,6 @@ public class InputSyncronizer {
setupInput();
}
public void update() {
rotateModel();
updateScrollValue();
}
private void setupInput() {
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
@@ -57,25 +52,21 @@ public void onAction(String name, boolean isPressed, float tpf) {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("MouseLeft") && rightMousePressed) {
rotationAngle -= value * 360f;
rotateModel();
} else if (name.equals("MouseRight") && rightMousePressed) {
rotationAngle += value * 360f;
rotateModel();
} else if (name.equals("MouseScrollUp")) {
scrollValue = Math.min(100, scrollValue + 1);
updateScrollValue();
scrollValue = Math.max(1, scrollValue - 5);
} else if (name.equals("MouseScrollDown")) {
scrollValue = Math.max(1, scrollValue - 1);
updateScrollValue();
scrollValue = Math.min(100, scrollValue + 5);
}
}
};
private void rotateModel() {
//System.out.println("Rotation Angle: " + rotationAngle);
public float getRotation() {
return (rotationAngle / 2) % 360;
}
private void updateScrollValue() {
//System.out.println("Scroll Value: " + scrollValue);
public int getScroll() {
return scrollValue;
}
}

View File

@@ -17,7 +17,7 @@ public class MdgaApp extends SimpleApplication {
MdgaView view = null;
private MdgaState state = MdgaState.MAIN;
private static float resolutionFactor = 1f;
private static float resolutionFactor = 1.8f;
public static void main(String[] args) {
AppSettings settings = new AppSettings(true);
@@ -47,6 +47,10 @@ public void simpleInitApp() {
modelSyncronizer = new ModelSyncronizer(this);
inputManager.deleteMapping("SIMPLEAPP_Exit");
inputManager.deleteMapping("FLYCAM_ZoomIn");
inputManager.deleteMapping("FLYCAM_ZoomOut");
inputManager.deleteMapping("FLYCAM_RotateDrag");
flyCam.setEnabled(false);
GuiGlobals.initialize(this);
enter(state);
@@ -54,7 +58,6 @@ public void simpleInitApp() {
@Override
public void simpleUpdate(float tpf) {
inputSyncronizer.update();
view.update();
acousticHandler.update();
notificationSynchronizer.update();
@@ -114,4 +117,6 @@ public MdgaView getView() {
public ModelSyncronizer getModelSyncronizer() {
return modelSyncronizer;
}
public InputSyncronizer getInputSyncronizer() { return inputSyncronizer; }
}

View File

@@ -3,6 +3,7 @@
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.shadow.DirectionalLightShadowFilter;
@@ -32,11 +33,6 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp){
}
public void init() {
app.getFlyByCamera().setEnabled(true);
int zoom = 20;
app.getCamera().setLocation(new Vector3f(-zoom, 0, zoom));
app.getCamera().lookAt(new Vector3f(0, 0, 0), new Vector3f(0, 0, 1));
app.getRootNode().addLight(sun);
app.getRootNode().addLight(ambient);
}
@@ -45,4 +41,37 @@ public void shutdown() {
app.getRootNode().removeLight(sun);
app.getRootNode().removeLight(ambient);
}
public void update(float scroll, float rotation) {
float scrollValue = Math.max(0, Math.min(scroll, 100));
float rotationValue = rotation % 360;
if (rotationValue < 0) {
rotationValue += 360;
}
float radius;
float verticalAngle;
if (scroll < 100f) {
verticalAngle = 20f + (scrollValue / 100f) * 45f;
radius = 30f;
} else {
verticalAngle = 90f;
rotationValue = 270f;
radius = 50f;
}
float verticalAngleRadians = FastMath.DEG_TO_RAD * verticalAngle;
float z = radius * FastMath.sin(verticalAngleRadians);
float x = radius * FastMath.cos(verticalAngleRadians) * FastMath.sin(FastMath.DEG_TO_RAD * rotationValue);
float y = radius * FastMath.cos(verticalAngleRadians) * FastMath.cos(FastMath.DEG_TO_RAD * rotationValue);
Vector3f cameraPosition = new Vector3f(x, y, z);
app.getCamera().setLocation(cameraPosition);
app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Z);
}
}

View File

@@ -0,0 +1,15 @@
package pp.mdga.client.dialog;
import java.util.function.Supplier;
public class GetPercentRunnable {
private final Supplier<Float> action;
public GetPercentRunnable(Supplier<Float> action) {
this.action = action;
}
public float get() {
return action.get();
}
}

View File

@@ -26,7 +26,7 @@ public HostDialog(MdgaApp app, Node node, Runnable backAction) {
Panel imagePanel = new Panel();
imagePanel.setBackground(b);
container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4, texture.getImage().getHeight() / 4, 0));
container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4 * app.getResolutionFactor(), texture.getImage().getHeight() / 4 * app.getResolutionFactor(), 0));
//abstandshalter
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));

View File

@@ -29,7 +29,7 @@ public JoinDialog(MdgaApp app, Node node, Runnable backAction) {
Panel imagePanel = new Panel();
imagePanel.setBackground(b);
container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4, texture.getImage().getHeight() / 4, 0));
container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4 * app.getResolutionFactor(), texture.getImage().getHeight() / 4 * app.getResolutionFactor(), 0));
//abstandshalter
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));

View File

@@ -21,6 +21,7 @@ public class SettingsDialog extends Dialog {
private TextField nameInput;
private HashMap<Slider, PercentRunnable> map = new HashMap<Slider, PercentRunnable>();
private HashMap<Slider, GetPercentRunnable> map2 = new HashMap<Slider, GetPercentRunnable>();
public SettingsDialog(MdgaApp app, Node node, String path) {
super(app, node);
@@ -62,7 +63,7 @@ public void addButton(String label, Runnable action, Vector3f size) {
createButton(label, action, size);
}
public void addSlider(String label, PercentRunnable action, Vector3f size, int start) {
public void addSlider(String label, PercentRunnable action, GetPercentRunnable action2, Vector3f size, int start) {
Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
Slider slider = new Slider("slider");
@@ -71,7 +72,7 @@ public void addSlider(String label, PercentRunnable action, Vector3f size, int s
slider.setBackground(background);
slider.setPreferredSize(size);
slider.setModel(new DefaultRangedValueModel(0, 10, start));
slider.setModel(new DefaultRangedValueModel(0, 100, start));
slider.setPreferredSize(new Vector3f(150 * app.getResolutionFactor(), 30 * app.getResolutionFactor(), 0));
slider.getDecrementButton().setText(" - ");
slider.getIncrementButton().setText(" + ");
@@ -89,11 +90,19 @@ public void addSlider(String label, PercentRunnable action, Vector3f size, int s
container.addChild(subContainer);
map.put(slider, action);
map2.put(slider, action2);
//abstandshalter
container.addChild(new Panel(20 * app.getResolutionFactor(), 10 * app.getResolutionFactor(), ColorRGBA.Gray));
}
public void initVolume() {
map2.forEach((slider, runnable) -> {
double val = (double) runnable.get();
slider.getModel().setPercent(val);
});
}
public void update() {
map.forEach((slider, runnable) -> {
float val = (float) slider.getModel().getPercent();

View File

@@ -55,6 +55,11 @@ public void onLeave() {
boardHandler.shutdown();
}
@Override
public void onUpdate() {
camera.update(app.getInputSyncronizer().getScroll(), app.getInputSyncronizer().getRotation());
}
@Override
protected void enterExtendedSettings() {
leaveButton.show();

View File

@@ -7,6 +7,7 @@
import com.jme3.scene.Node;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import pp.mdga.client.dialog.GetPercentRunnable;
import pp.mdga.client.dialog.PercentRunnable;
import pp.mdga.client.dialog.SettingsButtonDialog;
import pp.mdga.client.MdgaApp;
@@ -61,9 +62,9 @@ public MdgaView(MdgaApp app) {
this.settings.addButton("Zurück", () -> leaveSettings(false), size);
this.audio = new SettingsDialog(app, audioSettingsNode, "audio_icon.png");
this.audio.addSlider("Lautstärke", new PercentRunnable(app.getAcousticHandler()::setMainVolume), size, 5);
this.audio.addSlider("Musik", new PercentRunnable(app.getAcousticHandler()::setMusicVolume), size, 10);
this.audio.addSlider("Sound", new PercentRunnable(app.getAcousticHandler()::setSoundVolume), size, 10);
this.audio.addSlider("Lautstärke", new PercentRunnable(app.getAcousticHandler()::setMainVolume), new GetPercentRunnable(app.getAcousticHandler()::getMainVolume), size, (int) app.getAcousticHandler().getMainVolume() * 100);
this.audio.addSlider("Musik", new PercentRunnable(app.getAcousticHandler()::setMusicVolume), new GetPercentRunnable(app.getAcousticHandler()::getMusicVolume), size, (int) app.getAcousticHandler().getMusicVolume() * 100);
this.audio.addSlider("Sound", new PercentRunnable(app.getAcousticHandler()::setSoundVolume), new GetPercentRunnable(app.getAcousticHandler()::getSoundVolume), size, (int) app.getAcousticHandler().getSoundVolume() * 100);
this.audio.addButton("Zurück", () -> leaveAudio(), size);
this.video = new SettingsDialog(app, videoSettingsNode, "monitor.png");
@@ -75,6 +76,8 @@ public MdgaView(MdgaApp app) {
public void enter() {
app.getGuiNode().attachChild(node);
audio.initVolume();
settingsButton.show();
onEnter();
@@ -90,10 +93,12 @@ public void leave() {
public void update() {
audio.update();
onUpdate();
}
protected abstract void onEnter();
protected abstract void onLeave();
protected void onUpdate() {}
protected Geometry createBackground(String texturePath) {
TextureKey key = new TextureKey(texturePath, true);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@@ -0,0 +1,44 @@
package pp.mdga.client;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T066-T071
*/
public class ClientTest {
@Before
public void Setup() {
}
@Test
public void testClientTerminatesConnection() {
}
@Test
public void testClientConnects() {
}
@Test
public void testClientCantConnect() {
}
@Test
public void testClientReconnect() {
}
@Test
public void testClientDoesntReconnect() {
}
@Test
public void testClientDisconnects() {
}
}

View File

@@ -0,0 +1,88 @@
package pp.mdga.client.Dialog;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T084-T095
*/
public class LobbyTest {
@Before
public void setUp() {
// This method will be executed before each test.
// Initialize common objects or setup required state for Lobby actions.
}
// UC-Lobby-01
@Test
public void testSelectTSK() {
// TODO: Implement test logic for selecting a task (TSK)
}
// UC-Lobby-02
@Test
public void testDeselectTSK() {
// TODO: Implement test logic for deselecting a previously selected task (TSK)
}
// UC-Lobby-03
@Test
public void testChangeTSK() {
// TODO: Implement test logic for changing a selected task (TSK)
}
// UC-Lobby-04
@Test
public void testReady() {
// TODO: Implement test logic for setting the player status to "ready"
}
// UC-Lobby-05
@Test
public void testNotReady() {
// TODO: Implement test logic for setting the player status to "not ready"
}
// UC-Lobby-06
@Test
public void testLeaveLobby() {
// TODO: Implement test logic for a player leaving the lobby
}
// UC-Lobby-07
@Test
public void testStartGame() {
// TODO: Implement test logic for starting the game
}
// UC-Lobby-08
@Test
public void testShowStatus() {
// TODO: Implement test logic for showing the status of all players (ready/not ready)
}
// UC-Lobby-09
@Test
public void testShowNames() {
// TODO: Implement test logic for showing the names of all players in the lobby
}
// UC-Lobby-10
@Test
public void testShowAvailableTSKs() {
// TODO: Implement test logic for displaying the list of available tasks (TSKs)
}
// UC-Lobby-11
@Test
public void testShowAssignedTSKs() {
// TODO: Implement test logic for showing the tasks assigned to players
}
// UC-Lobby-12
@Test
public void testServerAssignsTSK() {
// TODO: Implement test logic for server-side assignment of tasks (TSKs) to players
}
}

View File

@@ -0,0 +1,45 @@
package pp.mdga.client.Dialog;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T079-T083
*/
public class NetworkDialogClientTest {
@Before
public void setUp() {
// This method will be executed before each test.
// Initialize common objects or setup required state for Network Dialog Client actions.
}
// UC-NetworkDialogClient-01
@Test
public void testEnterIP() {
// TODO: Implement test logic for entering an IP address
}
// UC-NetworkDialogClient-02
@Test
public void testEnterPort() {
// TODO: Implement test logic for entering a port number
}
// UC-NetworkDialogClient-03
@Test
public void testConnectToServer() {
// TODO: Implement test logic for attempting to connect to a server
}
@Test
public void testCantConnectToServer() {
// TODO: Implement test logic for handling failed server connection attempts
}
// UC-NetworkDialogClient-04
@Test
public void testCancelJoining() {
// TODO: Implement test logic for canceling the joining process
}
}

View File

@@ -0,0 +1,35 @@
package pp.mdga.client.Dialog;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T076-T078
*/
public class NetworkDialogHostTest {
@Before
public void setUp() {
// This method will be executed before each test.
}
// UC-NetworkDialogHost-01
@Test
public void testSpecifyPort() {
// TODO: Implement test logic for specifying a port
}
// UC-NetworkDialogHost-02
@Test
public void testCreateServer() {
// TODO: Implement test logic for creating a server
// Example: Check that the server is created successfully and starts listening on the specified port.
}
// UC-NetworkDialogHost-03
@Test
public void testCancelServer() {
// TODO: Implement test logic for canceling server creation
// Example: Verify that the server creation process is canceled properly without starting a server.
}
}

View File

@@ -0,0 +1,39 @@
package pp.mdga.client.Dialog;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T072-T075
*/
public class StartDialogTest {
@Before
public void setUp() {
// This method will be executed before each test.
// Initialize common objects or setup required state for Start Dialog actions.
}
// UC-StartDialog-01
@Test
public void testEnterName() {
// TODO: Implement test logic for entering a player name
}
// UC-StartDialog-02
@Test
public void testJoinServer() {
// TODO: Implement test logic for joining a game server
}
// UC-StartDialog-03
@Test
public void testHostServer() {
// TODO: Implement test logic for hosting a server
}
// UC-StartDialog-04
@Test
public void testExitGame() {
// TODO: Implement test logic for exiting the game
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
package pp.mdga.game;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T001-T016
*/
public class GameTest {
@Before
public void setup() {
}
@Test
public void testStartLineUp() {
// TODO: Implement test logic for starting line-up
}
@Test
public void testCreatePowerCardDeck() {
// TODO: Implement test logic for creating power card deck
}
// UC-Game-02
@Test
public void testGameFinishes() {
// TODO: Implement test logic for game finishes
}
// UC-Game-03
@Test
public void testPlayerFinishes() {
// TODO: Implement test logic for player finishes
}
// UC-Game-04
@Test
public void testAllPiecesInWaitingArea() {
// TODO: Implement test logic for checking if all pieces are in the waiting area
}
@Test
public void test3TriesFor6() {
// TODO: Implement test logic for checking 3 tries for rolling a 6
}
// UC-Game-05
@Test
public void testGameTerminates() {
// TODO: Implement test logic for game termination
}
// UC-Game-06
@Test
public void testStartingOrder() {
// TODO: Implement test logic for verifying starting order of players
}
// UC-Game-07
@Test
public void testDouble() {
// TODO: Implement test logic for testing the double rule
}
// UC-Game-08
@Test
public void testChangeActivePlayer() {
// TODO: Implement test logic for changing the active player
}
// UC-Game-09
@Test
public void testUseTurbo() {
// TODO: Implement test logic for using a turbo power-up
}
@Test
public void testMuliplicationChance() {
// TODO: Implement test logic for testing multiplication chance power-up
}
// UC-Game-10
@Test
public void testTurboOn6() {
// TODO: Implement test logic for turbo activation on rolling a 6
}
// UC-Game-11
@Test
public void testAwardCeremony() {
// TODO: Implement test logic for award ceremony
}
@Test
public void testStatistics() {
// TODO: Implement test logic for gathering or displaying game statistics
}
// UC-Game-12
@Test
public void testRefillPowerCardDeck() {
// TODO: Implement test logic for refilling the power card deck
}
}

View File

@@ -0,0 +1,147 @@
package pp.mdga.game;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T035-T058
*/
public class PieceTest {
@Before
public void Setup() {
}
// UC-Piece-01
@Test
public void testMove() {
// TODO: Implement test logic for moving a piece
}
// UC-Piece-02
@Test
public void testCantMove() {
// TODO: Implement test logic for when a piece can't move
}
// UC-Piece-03
@Test
public void testNoPossibleMove() {
// TODO: Implement test logic for when no possible moves are available
}
@Test
public void testThrow() {
// TODO: Implement test logic for throwing a piece off the board
}
// UC-Piece-04
@Test
public void testGetThrown() {
// TODO: Implement test logic for when a piece gets thrown
}
// UC-Piece-05
@Test
public void testLeaveWaitingArea() {
// TODO: Implement test logic for a piece leaving the waiting area
}
// UC-Piece-06
@Test
public void testMustLeaveStartingField() {
// TODO: Implement test logic for a piece that must leave the starting field
}
// UC-Piece-07
@Test
public void testDontHaveToLeaveStartingField() {
// TODO: Implement test logic for when a piece doesn't have to leave the starting field
}
// UC-Piece-08
@Test
public void testCantLeaveStartingField() {
// TODO: Implement test logic for when a piece can't leave the starting field
}
// UC-Piece-09
@Test
public void testReachBonusField() {
// TODO: Implement test logic for when a piece reaches a bonus field
}
@Test
public void testNoPowerCards() {
// TODO: Implement test logic for when there are no power cards available
}
@Test
public void testShufflePile() {
// TODO: Implement test logic for shuffling the pile of power cards
}
// UC-Piece-10
@Test
public void testEnterHouse() {
// TODO: Implement test logic for entering the house area
}
@Test
public void testOnlyEnterOwnHouse() {
// TODO: Implement test logic to ensure a piece can only enter its own house
}
// UC-Piece-11
@Test
public void testActiveHomePiece() {
// TODO: Implement test logic for activating a piece in the home area
}
@Test
public void testCantJumpOverFigureInHouse() {
// TODO: Implement test logic to prevent jumping over another piece in the house
}
// UC-Piece-12
@Test
public void testActiveHomePieceBlocked() {
// TODO: Implement test logic for when an active home piece is blocked
}
@Test
public void testOnStartingFieldWithShield() {
// TODO: Implement test logic for a piece on the starting field with a shield
}
// UC-Piece-13
@Test
public void testThrowFigureWithShield() {
// TODO: Implement test logic for attempting to throw a figure with a shield
}
// UC-Piece-14
@Test
public void testUseSwap() {
// TODO: Implement test logic for using a swap power-up
}
// UC-Piece-15
@Test
public void testUseShield() {
// TODO: Implement test logic for using a shield power-up
}
// UC-Piece-16
@Test
public void testLoseShield() {
// TODO: Implement test logic for when a piece loses its shield
}
// UC-Piece-17
@Test
public void testFinishedPiece() {
// TODO: Implement test logic for a piece that has finished the game
}
}

View File

@@ -0,0 +1,49 @@
package pp.mdga.server;
import org.junit.Before;
import org.junit.Test;
/**
* this test-class tests the testcases T059-T065
*/
public class ServerTest {
@Before
public void Setup() {
}
@Test
public void testServerStart() {
}
@Test
public void testServerDoesntStart() {
}
@Test
public void testAcceptRequest() {
}
@Test
public void testTerminateServer() {
}
@Test
public void testServerEndsGame() {
}
@Test
public void testDeclineConnection() {
}
@Test
public void testDeclineRequest() {
}
}

File diff suppressed because it is too large Load Diff