mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-09-19 06:53:13 +02:00
Compare commits
124 Commits
logic
...
9120e4d53c
Author | SHA1 | Date | |
---|---|---|---|
|
9120e4d53c | ||
|
1a62b76104 | ||
|
cc7f277bef | ||
|
274df8dfd1 | ||
|
0c2b266f5e | ||
|
16b4dbae18 | ||
|
88409dcc99 | ||
|
5cacff39b7 | ||
|
093723a9d0 | ||
|
dfdbcdc9f3 | ||
|
bd725e2dc4 | ||
|
dd9d9144dd | ||
|
1a429e4bb6 | ||
|
ad6fb5e926 | ||
|
72cb7049ba | ||
|
2e42f3afac | ||
|
8474c9f5bc | ||
|
b7ed03f7e8 | ||
|
a44b6b5e4c | ||
|
5268f75e17 | ||
|
687d1621fc | ||
|
a6944aa6e3 | ||
|
b8365c76a1 | ||
|
19216cc174 | ||
|
c6a23b9b8e | ||
|
c0f42fb1eb | ||
|
160873e2cc | ||
|
8df859bbef | ||
|
e30d10a85d | ||
|
bafc3f1db6 | ||
|
03571fcf74 | ||
|
e7a6802488 | ||
|
a6e6b5e158 | ||
|
74c3d925e6 | ||
|
f67fa4d7f0 | ||
|
225a8c0e08 | ||
|
9a6ce27fe1 | ||
|
437114704a | ||
|
9b4cac4e56 | ||
|
e780513b35 | ||
|
d582c59a7d | ||
|
7d2c85f617 | ||
|
4a882bc4ac | ||
|
3c4eac1fcd | ||
|
75d5a15bdb | ||
|
17f121f7d1 | ||
|
a66c570b51 | ||
|
e1e7f2eaf6 | ||
|
46d2dce372 | ||
|
c39f1f6d4c | ||
|
738b04f2d9 | ||
|
ecba1c3135 | ||
|
748226f4ed | ||
|
f658f53ba9 | ||
|
4a8304ee4f | ||
|
7fe9604338 | ||
|
7f09a6dae8 | ||
|
270129bc97 | ||
|
62ec6f6bef | ||
|
b24c14900c | ||
|
44c55ce3a6 | ||
|
895bea048c | ||
|
885ab5bdc9 | ||
|
c6355b2c09 | ||
|
ada6bf3f24 | ||
|
db471ac679 | ||
|
84059c4085 | ||
|
09b363f943 | ||
|
fd347c7780 | ||
|
b38a34efa5 | ||
|
10e24cf30e | ||
|
3369057afb | ||
|
7ada56e215 | ||
|
373b9e6d53 | ||
|
3de31de9f7 | ||
|
7252259ab3 | ||
|
f33c673a05 | ||
|
65a7958b66 | ||
|
91e4df7478 | ||
|
399606d9a0 | ||
|
559afcaffd | ||
|
15f5f91ddb | ||
|
067a8063a5 | ||
|
35e367ba24 | ||
|
fe68d991fc | ||
|
88dc633e8e | ||
|
0b9cbb0f5f | ||
|
c3a33b4402 | ||
|
e12f00aad6 | ||
|
47bac0185f | ||
|
dafe1dab2a | ||
|
8ba4ea2819 | ||
|
f6f708fd5b | ||
|
1203077aed | ||
|
ddbf79c928 | ||
|
aa47dd579f | ||
|
cdce478d77 | ||
|
f11f4a59f1 | ||
|
d631e8df1e | ||
|
af80d40700 | ||
|
3a6f8a945a | ||
|
bb9727d54a | ||
|
7da8b3e545 | ||
|
b6968df451 | ||
|
aa986fb948 | ||
|
6e63de6e99 | ||
|
962ecd08fa | ||
|
580a26b3ea | ||
|
0cda6b5fa0 | ||
|
cc8c3795b8 | ||
|
3c21165efb | ||
|
818fdf4670 | ||
|
b7d679b492 | ||
|
a42093df23 | ||
|
6157db51da | ||
|
843052989b | ||
|
8e01fa3192 | ||
|
e2126a7ea7 | ||
|
0b46d14650 | ||
|
9e28deedf7 | ||
|
9c0172b413 | ||
|
2933d022aa | ||
|
bdefb7193e | ||
|
69b68a6975 |
@@ -1,6 +1,5 @@
|
|||||||
// Styling of Lemur components
|
// Styling of Lemur components
|
||||||
// For documentation, see:
|
// For documentation, see:
|
||||||
// For documentation, see:
|
|
||||||
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
|
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA
|
import com.jme3.math.ColorRGBA
|
||||||
@@ -12,6 +11,7 @@ import com.simsilica.lemur.Command
|
|||||||
import com.simsilica.lemur.HAlignment
|
import com.simsilica.lemur.HAlignment
|
||||||
import com.simsilica.lemur.Insets3f
|
import com.simsilica.lemur.Insets3f
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent
|
import com.simsilica.lemur.component.QuadBackgroundComponent
|
||||||
|
import com.simsilica.lemur.component.TbtQuadBackgroundComponent
|
||||||
|
|
||||||
def bgColor = color(1, 1, 1, 1)
|
def bgColor = color(1, 1, 1, 1)
|
||||||
def buttonEnabledColor = color(0, 0, 0, 1)
|
def buttonEnabledColor = color(0, 0, 0, 1)
|
||||||
@@ -19,7 +19,7 @@ def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
|
|||||||
def buttonBgColor = color(1, 1, 1, 1)
|
def buttonBgColor = color(1, 1, 1, 1)
|
||||||
def sliderColor = color(0.6, 0.8, 0.8, 1)
|
def sliderColor = color(0.6, 0.8, 0.8, 1)
|
||||||
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
|
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
|
||||||
def gradientColor = color(1, 1, 1, 1)
|
def gradientColor = color(0.5, 0.75, 0.85, 0.5)
|
||||||
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
|
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
|
||||||
def solidWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 1))
|
def solidWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 1))
|
||||||
def greyBackground = new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
|
def greyBackground = new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
|
||||||
@@ -30,8 +30,10 @@ def lightGrey = color(0.6, 0.6, 0.6, 1.0)
|
|||||||
|
|
||||||
|
|
||||||
def gradient = TbtQuadBackgroundComponent.create(
|
def gradient = TbtQuadBackgroundComponent.create(
|
||||||
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png", generateMips: false),
|
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
|
||||||
1, 1, 1, 126, 126, 1f, false)
|
generateMips: false),
|
||||||
|
1, 1, 1, 126, 126,
|
||||||
|
1f, false)
|
||||||
|
|
||||||
def doubleGradient = new QuadBackgroundComponent(gradientColor)
|
def doubleGradient = new QuadBackgroundComponent(gradientColor)
|
||||||
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
|
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
|
||||||
@@ -77,7 +79,6 @@ selector("header", "pp") {
|
|||||||
textVAlignment = VAlignment.Center
|
textVAlignment = VAlignment.Center
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container Stil
|
|
||||||
selector("container", "pp") {
|
selector("container", "pp") {
|
||||||
background = solidWhiteBackground.clone()
|
background = solidWhiteBackground.clone()
|
||||||
background.setColor(bgColor)
|
background.setColor(bgColor)
|
||||||
@@ -90,8 +91,8 @@ selector("toolbar") {
|
|||||||
|
|
||||||
}
|
}
|
||||||
selector("slider", "pp") {
|
selector("slider", "pp") {
|
||||||
insets = new Insets3f(5, 10, 5, 10) // Abstand
|
background = gradient.clone()
|
||||||
background = new QuadBackgroundComponent(sliderBgColor)
|
background.setColor(bgColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
def pressedCommand = new Command<Button>() {
|
def pressedCommand = new Command<Button>() {
|
||||||
@@ -112,6 +113,30 @@ def enabledCommand = new Command<Button>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def repeatCommand = new Command<Button>() {
|
||||||
|
private long startTime
|
||||||
|
private long lastClick
|
||||||
|
|
||||||
|
void execute(Button source) {
|
||||||
|
// Only do the repeating click while the mouse is
|
||||||
|
// over the button (and pressed of course)
|
||||||
|
if (source.isPressed() && source.isHighlightOn()) {
|
||||||
|
long elapsedTime = System.currentTimeMillis() - startTime
|
||||||
|
// After half a second pause, click 8 times a second
|
||||||
|
if (elapsedTime > 500 && elapsedTime > lastClick + 125) {
|
||||||
|
source.click()
|
||||||
|
|
||||||
|
// Try to quantize the last click time to prevent drift
|
||||||
|
lastClick = ((elapsedTime - 500) / 125) * 125 + 500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startTime = System.currentTimeMillis()
|
||||||
|
lastClick = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def stdButtonCommands = [
|
def stdButtonCommands = [
|
||||||
(ButtonAction.Down) : [pressedCommand],
|
(ButtonAction.Down) : [pressedCommand],
|
||||||
(ButtonAction.Up) : [pressedCommand],
|
(ButtonAction.Up) : [pressedCommand],
|
||||||
|
@@ -0,0 +1,110 @@
|
|||||||
|
////////////////////////////////////////
|
||||||
|
// Programming project code
|
||||||
|
// UniBw M, 2022, 2023, 2024
|
||||||
|
// www.unibw.de/inf2
|
||||||
|
// (c) Mark Minas (mark.minas@unibw.de)
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
package pp.monopoly.client;
|
||||||
|
|
||||||
|
import com.jme3.input.controls.ActionListener;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.system.AppSettings;
|
||||||
|
import pp.monopoly.client.MonopolyAppState;
|
||||||
|
import pp.monopoly.client.gui.TestWorld;
|
||||||
|
import pp.monopoly.model.IntPoint;
|
||||||
|
|
||||||
|
import java.lang.System.Logger;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the state responsible for managing the battle interface within the Battleship game.
|
||||||
|
* This state handles the display and interaction of the battle map, including the opponent's map.
|
||||||
|
* It manages GUI components, input events, and the layout of the interface when this state is enabled.
|
||||||
|
*/
|
||||||
|
public class GameAppState extends MonopolyAppState {
|
||||||
|
private static final Logger LOGGER = System.getLogger(MonopolyAppState.class.getName());
|
||||||
|
private static final float DEPTH = 0f;
|
||||||
|
private static final float GAP = 20f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A listener for handling click events in the battle interface.
|
||||||
|
* When a click is detected, it triggers the corresponding actions on the opponent's map.
|
||||||
|
*/
|
||||||
|
private final ActionListener clickListener = (name, isPressed, tpf) -> click(isPressed);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root node for all GUI components in the battle state.
|
||||||
|
*/
|
||||||
|
private final Node battleNode = new Node("Game"); //NON-NLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A view representing the opponent's map in the GUI.
|
||||||
|
*/
|
||||||
|
private TestWorld testWorld;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the battle state by initializing, laying out, and adding GUI components.
|
||||||
|
* Attaches the components to the GUI node and registers input listeners.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void enableState() {
|
||||||
|
battleNode.detachAllChildren();
|
||||||
|
initializeGuiComponents();
|
||||||
|
layoutGuiComponents();
|
||||||
|
addGuiComponents();
|
||||||
|
getApp().getGuiNode().attachChild(battleNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the battle state by removing GUI components and unregistering input listeners.
|
||||||
|
* Also handles cleanup of resources, such as the opponent's map view.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void disableState() {
|
||||||
|
getApp().getGuiNode().detachChild(battleNode);
|
||||||
|
getApp().getInputManager().removeListener(clickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the GUI components used in the battle state.
|
||||||
|
* Creates the opponent's map view and adds a grid overlay to it.
|
||||||
|
*/
|
||||||
|
private void initializeGuiComponents() {
|
||||||
|
testWorld = new TestWorld(getApp());
|
||||||
|
testWorld.initializeScene();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the initialized GUI components to the battle node.
|
||||||
|
* Currently, it attaches the opponent's map view to the node.
|
||||||
|
*/
|
||||||
|
private void addGuiComponents() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lays out the GUI components within the window, positioning them appropriately.
|
||||||
|
* The opponent's map view is positioned based on the window's dimensions and a specified gap.
|
||||||
|
*/
|
||||||
|
private void layoutGuiComponents() {
|
||||||
|
final AppSettings s = getApp().getContext().getSettings();
|
||||||
|
final float windowWidth = s.getWidth();
|
||||||
|
final float windowHeight = s.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles click events in the battle interface. If the event indicates a click (not a release),
|
||||||
|
* it translates the cursor position to the model's coordinate system and triggers the game logic
|
||||||
|
* for interacting with the opponent's map.
|
||||||
|
*
|
||||||
|
* @param isPressed whether the mouse button is currently pressed (true) or released (false)
|
||||||
|
*/
|
||||||
|
private void click(boolean isPressed) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float tpf) {
|
||||||
|
testWorld.update(tpf);
|
||||||
|
super.update(tpf);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +1,11 @@
|
|||||||
package pp.monopoly.client;
|
////////////////////////////////////////
|
||||||
|
// Programming project code
|
||||||
|
// UniBw M, 2022, 2023, 2024
|
||||||
|
// www.unibw.de/inf2
|
||||||
|
// (c) Mark Minas (mark.minas@unibw.de)
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
import java.lang.System.Logger;
|
package pp.monopoly.client;
|
||||||
import java.lang.System.Logger.Level;
|
|
||||||
import java.util.prefs.Preferences;
|
|
||||||
|
|
||||||
import java.lang.System.Logger;
|
import java.lang.System.Logger;
|
||||||
import java.lang.System.Logger.Level;
|
import java.lang.System.Logger.Level;
|
||||||
@@ -11,16 +14,17 @@ import java.util.prefs.Preferences;
|
|||||||
import com.jme3.app.Application;
|
import com.jme3.app.Application;
|
||||||
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.asset.AssetLoadException;
|
||||||
|
import com.jme3.asset.AssetNotFoundException;
|
||||||
import com.jme3.audio.AudioData;
|
import com.jme3.audio.AudioData;
|
||||||
import com.jme3.audio.AudioNode;
|
import com.jme3.audio.AudioNode;
|
||||||
|
|
||||||
|
|
||||||
import pp.monopoly.notification.GameEventListener;
|
import pp.monopoly.notification.GameEventListener;
|
||||||
import pp.monopoly.notification.SoundEvent;
|
import pp.monopoly.notification.SoundEvent;
|
||||||
import static pp.util.PreferencesUtils.getPreferences;
|
import static pp.util.PreferencesUtils.getPreferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An application state that plays sounds based on game events.
|
* An application state that plays sounds.
|
||||||
*/
|
*/
|
||||||
public class GameSound extends AbstractAppState implements GameEventListener {
|
public class GameSound extends AbstractAppState implements GameEventListener {
|
||||||
private static final Logger LOGGER = System.getLogger(GameSound.class.getName());
|
private static final Logger LOGGER = System.getLogger(GameSound.class.getName());
|
||||||
@@ -67,6 +71,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the enabled state of this AppState.
|
* Sets the enabled state of this AppState.
|
||||||
|
* Overrides {@link com.jme3.app.state.AbstractAppState#setEnabled(boolean)}
|
||||||
*
|
*
|
||||||
* @param enabled {@code true} to enable the AppState, {@code false} to disable it.
|
* @param enabled {@code true} to enable the AppState, {@code false} to disable it.
|
||||||
*/
|
*/
|
||||||
@@ -74,15 +79,16 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
if (isEnabled() == enabled) return;
|
if (isEnabled() == enabled) return;
|
||||||
super.setEnabled(enabled);
|
super.setEnabled(enabled);
|
||||||
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled);
|
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled); //NON-NLS
|
||||||
PREFERENCES.putBoolean(ENABLED_PREF, enabled);
|
PREFERENCES.putBoolean(ENABLED_PREF, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the sound effects for the game and stores the application reference.
|
* Initializes the sound effects for the game.
|
||||||
|
* Overrides {@link AbstractAppState#initialize(AppStateManager, Application)}
|
||||||
*
|
*
|
||||||
* @param stateManager The state manager
|
* @param stateManager The state manager
|
||||||
* @param app The application instance
|
* @param app The application
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initialize(AppStateManager stateManager, Application app) {
|
public void initialize(AppStateManager stateManager, Application app) {
|
||||||
@@ -103,16 +109,18 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
/**
|
/**
|
||||||
* Loads a sound from the specified file.
|
* Loads a sound from the specified file.
|
||||||
*
|
*
|
||||||
|
* @param app The application
|
||||||
* @param name The name of the sound file.
|
* @param name The name of the sound file.
|
||||||
* @return The loaded AudioNode.
|
* @return The loaded AudioNode.
|
||||||
*/
|
*/
|
||||||
private AudioNode loadSound(String name) {
|
private AudioNode loadSound(Application app, String name) {
|
||||||
try {
|
try {
|
||||||
AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
||||||
sound.setLooping(false);
|
sound.setLooping(false);
|
||||||
sound.setPositional(false);
|
sound.setPositional(false);
|
||||||
return sound;
|
return sound;
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (AssetLoadException | AssetNotFoundException ex) {
|
||||||
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
|
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -231,4 +239,4 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
|||||||
case BUTTON -> button();
|
case BUTTON -> button();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//heloo
|
}
|
||||||
|
@@ -18,7 +18,6 @@ import com.jme3.input.controls.ActionListener;
|
|||||||
import com.jme3.input.controls.KeyTrigger;
|
import com.jme3.input.controls.KeyTrigger;
|
||||||
import com.jme3.input.controls.MouseButtonTrigger;
|
import com.jme3.input.controls.MouseButtonTrigger;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
import com.simsilica.lemur.GuiGlobals;
|
import com.simsilica.lemur.GuiGlobals;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
import com.simsilica.lemur.style.BaseStyles;
|
import com.simsilica.lemur.style.BaseStyles;
|
||||||
@@ -280,19 +279,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
private void handleB(boolean isPressed) {
|
private void handleB(boolean isPressed) {
|
||||||
if (isPressed) {
|
if (isPressed) {
|
||||||
Dialog tmp = new BuyCard(this);
|
Dialog tmp = new BuyCard(this);
|
||||||
if (eventCard != null && isBuyCardPopupOpen) {
|
|
||||||
// Schließe das SettingsMenu
|
|
||||||
System.out.println("Schließe BuyCardPopup...");
|
|
||||||
eventCard.close();
|
|
||||||
eventCard = null;
|
|
||||||
tmp.open();
|
tmp.open();
|
||||||
} else {
|
|
||||||
// Öffne das SettingsMenu
|
|
||||||
System.out.println("Öffne BuyCardPopup...");
|
|
||||||
eventCard = new EventCard(this);
|
|
||||||
eventCard.open();
|
|
||||||
dialogManager.close(tmp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,6 +308,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
|
|
||||||
attachGameSound();
|
attachGameSound();
|
||||||
attachGameMusic();
|
attachGameMusic();
|
||||||
|
stateManager.attach(new GameAppState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -444,6 +432,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(ClientStateEvent event) {
|
public void receivedEvent(ClientStateEvent event) {
|
||||||
|
stateManager.getState(GameAppState.class).setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,10 +3,8 @@ package pp.monopoly.client.gui;
|
|||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
|
|
||||||
|
|
||||||
import pp.monopoly.model.Board;
|
import pp.monopoly.model.Board;
|
||||||
import pp.monopoly.model.Item;
|
import pp.monopoly.model.Item;
|
||||||
import pp.monopoly.model.Item;
|
|
||||||
import pp.monopoly.model.Visitor;
|
import pp.monopoly.model.Visitor;
|
||||||
import pp.monopoly.notification.GameEventListener;
|
import pp.monopoly.notification.GameEventListener;
|
||||||
import pp.monopoly.notification.ItemAddedEvent;
|
import pp.monopoly.notification.ItemAddedEvent;
|
||||||
@@ -26,14 +24,10 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
|
|||||||
*
|
*
|
||||||
* @param board the game board to synchronize
|
* @param board the game board to synchronize
|
||||||
* @param root the root node to which the view representations of the board items are attached
|
* @param root the root node to which the view representations of the board items are attached
|
||||||
* @param board the game board to synchronize
|
|
||||||
* @param root the root node to which the view representations of the board items are attached
|
|
||||||
*/
|
*/
|
||||||
protected BoardSynchronizer(Board board, Node root) {
|
|
||||||
protected BoardSynchronizer(Board board, Node root) {
|
protected BoardSynchronizer(Board board, Node root) {
|
||||||
super(root);
|
super(root);
|
||||||
this.board = board;
|
this.board = board;
|
||||||
this.board = board;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +42,6 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the existing items from the board to the view during initialization.
|
|
||||||
* Adds the existing items from the board to the view during initialization.
|
* Adds the existing items from the board to the view during initialization.
|
||||||
*/
|
*/
|
||||||
protected void addExisting() {
|
protected void addExisting() {
|
||||||
@@ -56,36 +49,26 @@ abstract class BoardSynchronizer extends ModelViewSynchronizer<Item> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the event when an item is removed from the board.
|
|
||||||
* Handles the event when an item is removed from the board.
|
* Handles the event when an item is removed from the board.
|
||||||
*
|
*
|
||||||
* @param event the event indicating that an item has been removed from the board
|
* @param event the event indicating that an item has been removed from the board
|
||||||
* @param event the event indicating that an item has been removed from the board
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(ItemRemovedEvent event) {
|
public void receivedEvent(ItemRemovedEvent event) {
|
||||||
if (board == event.getBoard()) {
|
if (board == event.getBoard()) {
|
||||||
delete(event.getItem());
|
delete(event.getItem());
|
||||||
}
|
}
|
||||||
if (board == event.getBoard()) {
|
|
||||||
delete(event.getItem());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the event when an item is added to the board.
|
|
||||||
* Handles the event when an item is added to the board.
|
* Handles the event when an item is added to the board.
|
||||||
*
|
*
|
||||||
* @param event the event indicating that an item has been added to the board
|
* @param event the event indicating that an item has been added to the board
|
||||||
* @param event the event indicating that an item has been added to the board
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(ItemAddedEvent event) {
|
public void receivedEvent(ItemAddedEvent event) {
|
||||||
if (board == event.getBoard()) {
|
if (board == event.getBoard()) {
|
||||||
add(event.getItem());
|
add(event.getItem());
|
||||||
}
|
}
|
||||||
if (board == event.getBoard()) {
|
|
||||||
add(event.getItem());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,17 +6,12 @@ import com.jme3.scene.Geometry;
|
|||||||
import com.jme3.scene.shape.Quad;
|
import com.jme3.scene.shape.Quad;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.simsilica.lemur.Axis;
|
import com.simsilica.lemur.Axis;
|
||||||
import com.simsilica.lemur.Axis;
|
|
||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.HAlignment;
|
import com.simsilica.lemur.HAlignment;
|
||||||
import com.simsilica.lemur.Container;
|
|
||||||
import com.simsilica.lemur.HAlignment;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
|
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
|
||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
@@ -25,12 +20,10 @@ import pp.monopoly.notification.Sound;
|
|||||||
* Constructs the startup menu dialog for the Monopoly application.
|
* Constructs the startup menu dialog for the Monopoly application.
|
||||||
import pp.monopoly.client.gui.GameMenu;
|
import pp.monopoly.client.gui.GameMenu;
|
||||||
*/
|
*/
|
||||||
*/
|
|
||||||
public class StartMenu extends Dialog {
|
public class StartMenu extends Dialog {
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the Startup Menu dialog for the Monopoly application.
|
|
||||||
* Constructs the Startup Menu dialog for the Monopoly application.
|
* Constructs the Startup Menu dialog for the Monopoly application.
|
||||||
*
|
*
|
||||||
* @param app the MonopolyApp instance
|
* @param app the MonopolyApp instance
|
||||||
@@ -48,10 +41,8 @@ public class StartMenu extends Dialog {
|
|||||||
Geometry background = new Geometry("Background", quad);
|
Geometry background = new Geometry("Background", quad);
|
||||||
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
backgroundMaterial.setTexture("ColorMap", backgroundImage);
|
backgroundMaterial.setTexture("ColorMap", backgroundImage);
|
||||||
backgroundMaterial.setTexture("ColorMap", backgroundImage);
|
|
||||||
background.setMaterial(backgroundMaterial);
|
background.setMaterial(backgroundMaterial);
|
||||||
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
||||||
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
|
||||||
app.getGuiNode().attachChild(background);
|
app.getGuiNode().attachChild(background);
|
||||||
|
|
||||||
// Center container for title and play button
|
// Center container for title and play button
|
||||||
|
@@ -1,80 +0,0 @@
|
|||||||
package pp.monopoly.client.gui;
|
|
||||||
|
|
||||||
import com.jme3.app.SimpleApplication;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Geometry;
|
|
||||||
import com.jme3.scene.shape.Box;
|
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
import com.jme3.system.JmeCanvasContext;
|
|
||||||
import com.jme3.system.AppSettings;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
|
|
||||||
public class TestWorldWithMenu extends SimpleApplication {
|
|
||||||
|
|
||||||
public static void createAndShowGUI() {
|
|
||||||
// Create JFrame
|
|
||||||
JFrame frame = new JFrame("Test World with Menu");
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setLayout(new BorderLayout());
|
|
||||||
frame.setSize(800, 600);
|
|
||||||
|
|
||||||
// Create Menu Bar
|
|
||||||
JMenuBar menuBar = new JMenuBar();
|
|
||||||
JMenu fileMenu = new JMenu("File");
|
|
||||||
JMenuItem exitItem = new JMenuItem(new AbstractAction("Exit") {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fileMenu.add(exitItem);
|
|
||||||
menuBar.add(fileMenu);
|
|
||||||
frame.setJMenuBar(menuBar);
|
|
||||||
|
|
||||||
// Create Canvas for jMonkey
|
|
||||||
AppSettings settings = new AppSettings(true);
|
|
||||||
settings.setWidth(800);
|
|
||||||
settings.setHeight(600);
|
|
||||||
|
|
||||||
TestWorldWithMenu app = new TestWorldWithMenu();
|
|
||||||
app.setSettings(settings);
|
|
||||||
app.createCanvas(); // Create a canvas for embedding
|
|
||||||
JmeCanvasContext ctx = (JmeCanvasContext) app.getContext();
|
|
||||||
ctx.setSystemListener(app);
|
|
||||||
Canvas canvas = ctx.getCanvas();
|
|
||||||
canvas.setSize(800, 600);
|
|
||||||
|
|
||||||
// Add the canvas to JFrame
|
|
||||||
frame.add(canvas, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
// Show the frame
|
|
||||||
frame.setVisible(true);
|
|
||||||
|
|
||||||
// Start the jMonkeyEngine application
|
|
||||||
app.startCanvas();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void simpleInitApp() {
|
|
||||||
// Erstelle ein Quadrat
|
|
||||||
Box box = new Box(1, 0.01f, 1); // Dünnes Quadrat für die Textur
|
|
||||||
Geometry geom = new Geometry("Box", box);
|
|
||||||
|
|
||||||
// Setze das Material mit Textur
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
|
||||||
Texture texture = assetManager.loadTexture("Pictures/board.png"); // Replace with the path to your image
|
|
||||||
mat.setTexture("ColorMap", texture);
|
|
||||||
geom.setMaterial(mat);
|
|
||||||
|
|
||||||
// Füge das Quadrat zur Szene hinzu
|
|
||||||
rootNode.attachChild(geom);
|
|
||||||
|
|
||||||
// Setze die Kameraposition, um das Quadrat zu fokussieren
|
|
||||||
cam.setLocation(new Vector3f(0, 0, 3)); // Kamera auf der Z-Achse, nah am Quadrat
|
|
||||||
cam.lookAt(geom.getLocalTranslation(), Vector3f.UNIT_Y);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -34,13 +34,13 @@ public class MonopolyConfig extends Config {
|
|||||||
* The width of the game map in terms of grid units.
|
* The width of the game map in terms of grid units.
|
||||||
*/
|
*/
|
||||||
@Property("map.width")
|
@Property("map.width")
|
||||||
private int mapWidth = 12;
|
private int mapWidth = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The height of the game map in terms of grid units.
|
* The height of the game map in terms of grid units.
|
||||||
*/
|
*/
|
||||||
@Property("map.height")
|
@Property("map.height")
|
||||||
private int mapHeight = 12;
|
private int mapHeight = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of {@code MonopolyConfig} with default settings.
|
* Creates an instance of {@code MonopolyConfig} with default settings.
|
||||||
|
@@ -199,10 +199,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(BuyPropertyResponse msg) {
|
public void received(BuyPropertyResponse msg) {
|
||||||
if (msg.isSuccessful()) {
|
if (msg.isSuccessful()) {
|
||||||
setInfoText("You successfully bought " + msg.getPropertyName() + "!");
|
|
||||||
playSound(Sound.MONEY_LOST);
|
playSound(Sound.MONEY_LOST);
|
||||||
} else {
|
} else {
|
||||||
setInfoText("Unable to buy " + msg.getPropertyName() + ". Reason: " + msg.getReason());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceResult msg) {
|
public void received(DiceResult msg) {
|
||||||
setInfoText("You rolled a " + msg.calcTotal() + "!");
|
|
||||||
//Set the dice images
|
//Set the dice images
|
||||||
playSound(Sound.DICE_ROLL);
|
playSound(Sound.DICE_ROLL);
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(EventDrawCard msg) {
|
public void received(EventDrawCard msg) {
|
||||||
setInfoText("Event card drawn: " + msg.getCardDescription());
|
|
||||||
// Kartenlogik
|
// Kartenlogik
|
||||||
playSound(Sound.EVENT_CARD);
|
playSound(Sound.EVENT_CARD);
|
||||||
}
|
}
|
||||||
@@ -238,11 +238,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(GameOver msg) {
|
public void received(GameOver msg) {
|
||||||
if (msg.isWinner()) {
|
if (msg.isWinner()) {
|
||||||
setInfoText("Congratulations! You have won the game!");
|
|
||||||
//Winner popup
|
//Winner popup
|
||||||
playSound(Sound.WINNER);
|
playSound(Sound.WINNER);
|
||||||
} else {
|
} else {
|
||||||
setInfoText("Game over. Better luck next time!");
|
|
||||||
// Looser popup
|
// Looser popup
|
||||||
playSound(Sound.LOSER);
|
playSound(Sound.LOSER);
|
||||||
}
|
}
|
||||||
@@ -256,8 +256,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(GameStart msg) {
|
public void received(GameStart msg) {
|
||||||
players = msg.getPlayers();
|
players = msg.getPlayers();
|
||||||
setInfoText("The game has started! Good luck!");
|
|
||||||
setState(new WaitForTurnState(this));
|
setState(new WaitForTurnState(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,10 +268,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(JailEvent msg) {
|
public void received(JailEvent msg) {
|
||||||
if (msg.isGoingToJail()) {
|
if (msg.isGoingToJail()) {
|
||||||
setInfoText("You are sent to jail!");
|
|
||||||
playSound(Sound.GULAG);
|
playSound(Sound.GULAG);
|
||||||
} else {
|
} else {
|
||||||
setInfoText("You are out of jail!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(PlayerStatusUpdate msg) {
|
public void received(PlayerStatusUpdate msg) {
|
||||||
|
|
||||||
setInfoText("Player " + msg.getPlayerName() + " status updated: " + msg.getStatus());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -293,7 +293,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(TimeOutWarning msg) {
|
public void received(TimeOutWarning msg) {
|
||||||
setInfoText("Warning! Time is running out. You have " + msg.getRemainingTime() + " seconds left.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -303,7 +303,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ViewAssetsResponse msg) {
|
public void received(ViewAssetsResponse msg) {
|
||||||
setInfoText("Your current assets are being displayed.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -314,10 +314,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(TradeReply msg) {
|
public void received(TradeReply msg) {
|
||||||
if (msg.getTradeHandler().getStatus()) {
|
if (msg.getTradeHandler().getStatus()) {
|
||||||
setInfoText("Trade accepted by " + msg.getTradeHandler().getReceiver().getName() + ".");
|
|
||||||
playSound(Sound.TRADE_ACCEPTED);
|
playSound(Sound.TRADE_ACCEPTED);
|
||||||
} else {
|
} else {
|
||||||
setInfoText("Trade rejected by " + msg.getTradeHandler().getReceiver().getName() + ".");
|
|
||||||
playSound(Sound.TRADE_REJECTED);
|
playSound(Sound.TRADE_REJECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(TradeRequest msg) {
|
public void received(TradeRequest msg) {
|
||||||
setInfoText("Trade offer received from " + msg.getTradeHandler().getSender().getName());
|
|
||||||
// playSound(Sound.TRADE_REQUEST); no sound effect
|
// playSound(Sound.TRADE_REQUEST); no sound effect
|
||||||
// notifyListeners();
|
// notifyListeners();
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(NextPlayerTurn msg) {
|
public void received(NextPlayerTurn msg) {
|
||||||
setInfoText("It's your turn!");
|
|
||||||
|
System.out.println("Du bsit am zug message empfangen");
|
||||||
setState(new ActiveState(this));
|
setState(new ActiveState(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -175,7 +175,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
LOGGER.log(Level.DEBUG, "Ending turn for player {0}", player.getName());
|
LOGGER.log(Level.DEBUG, "Ending turn for player {0}", player.getName());
|
||||||
Player next = playerHandler.nextPlayer();
|
Player next = playerHandler.nextPlayer();
|
||||||
next.setActive();
|
next.setActive();
|
||||||
send(next, new NextPlayerTurn(next));
|
send(next, new NextPlayerTurn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
send(p, new GameStart(playerHandler.getPlayers()));
|
send(p, new GameStart(playerHandler.getPlayers()));
|
||||||
}
|
}
|
||||||
playerHandler.randomOrder();
|
playerHandler.randomOrder();
|
||||||
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn(playerHandler.getPlayerAtIndex(0)));
|
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,20 +2,13 @@ package pp.monopoly.message.server;
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
public class NextPlayerTurn extends ServerMessage{
|
public class NextPlayerTurn extends ServerMessage{
|
||||||
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor for serialization purposes.
|
* Default constructor for serialization purposes.
|
||||||
*/
|
*/
|
||||||
private NextPlayerTurn() { /* empty */ }
|
public NextPlayerTurn() {
|
||||||
|
|
||||||
public NextPlayerTurn(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -28,9 +21,4 @@ public class NextPlayerTurn extends ServerMessage{
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,8 +3,11 @@ package pp.monopoly.model.fields;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
public class BuildingProperty extends PropertyField {
|
public class BuildingProperty extends PropertyField {
|
||||||
|
|
||||||
private int houses;
|
private int houses;
|
||||||
@@ -17,6 +20,12 @@ public class BuildingProperty extends PropertyField {
|
|||||||
private final int rentFactor4 = 55;
|
private final int rentFactor4 = 55;
|
||||||
private final int rentFactorHotel = 70;
|
private final int rentFactorHotel = 70;
|
||||||
|
|
||||||
|
private BuildingProperty(){
|
||||||
|
super("", 0, 0, 0);
|
||||||
|
this.housePrice = 0;
|
||||||
|
this.color = null;
|
||||||
|
}
|
||||||
|
|
||||||
BuildingProperty(String name, int id, int price, int rent, int housePrice, FieldColor color) {
|
BuildingProperty(String name, int id, int price, int rent, int housePrice, FieldColor color) {
|
||||||
super(name, id, price, rent);
|
super(name, id, price, rent);
|
||||||
this.housePrice = housePrice;
|
this.housePrice = housePrice;
|
||||||
|
@@ -1,11 +1,18 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
public class EventField extends Field{
|
public class EventField extends Field{
|
||||||
|
|
||||||
public EventField(String name, int id) {
|
private EventField() {
|
||||||
|
super("", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventField(String name, int id) {
|
||||||
super(name, id);
|
super(name, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,11 +1,19 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
abstract class Field {
|
@Serializable
|
||||||
|
public abstract class Field {
|
||||||
protected final String name;
|
protected final String name;
|
||||||
protected final int id;
|
protected final int id;
|
||||||
|
|
||||||
|
private Field() {
|
||||||
|
this.name = "";
|
||||||
|
this.id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected Field(String name, int id) {
|
protected Field(String name, int id) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.id= id;
|
this.id= id;
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representing eight distinct colors for properties in the game.
|
* Enum representing eight distinct colors for properties in the game.
|
||||||
*/
|
*/
|
||||||
|
// @Serializable
|
||||||
public enum FieldColor {
|
public enum FieldColor {
|
||||||
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
|
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
|
||||||
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),
|
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),
|
||||||
@@ -17,6 +19,10 @@ public enum FieldColor {
|
|||||||
|
|
||||||
private final ColorRGBA color;
|
private final ColorRGBA color;
|
||||||
|
|
||||||
|
private FieldColor() {
|
||||||
|
this.color = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a FieldColor with the specified ColorRGBA value.
|
* Constructs a FieldColor with the specified ColorRGBA value.
|
||||||
*
|
*
|
||||||
|
@@ -1,11 +1,19 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
public class FineField extends Field{
|
public class FineField extends Field{
|
||||||
|
|
||||||
private final int fine;
|
private final int fine;
|
||||||
|
|
||||||
|
private FineField() {
|
||||||
|
super("", 0);
|
||||||
|
this.fine = 0;
|
||||||
|
}
|
||||||
|
|
||||||
FineField(String name, int id, int fine) {
|
FineField(String name, int id, int fine) {
|
||||||
super(name, id);
|
super(name, id);
|
||||||
this.fine = fine;
|
this.fine = fine;
|
||||||
|
@@ -1,10 +1,17 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
public class FoodField extends PropertyField {
|
public class FoodField extends PropertyField {
|
||||||
|
|
||||||
public FoodField(String name, int id) {
|
private FoodField() {
|
||||||
|
super("", 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FoodField(String name, int id) {
|
||||||
super(name, id, 1500,0);
|
super(name, id, 1500,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +1,15 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
|
@Serializable
|
||||||
public class GateField extends PropertyField{
|
public class GateField extends PropertyField{
|
||||||
|
|
||||||
|
private GateField() {
|
||||||
|
super("", 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
GateField(String name, int id) {
|
GateField(String name, int id) {
|
||||||
super(name, id, 2000, 25);
|
super(name, id, 2000, 25);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
|
@Serializable
|
||||||
public class GoField extends Field{
|
public class GoField extends Field{
|
||||||
|
|
||||||
public GoField() {
|
GoField() {
|
||||||
super("Monatsgehalt", 0);
|
super("Monatsgehalt", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
|
@Serializable
|
||||||
public class GulagField extends Field{
|
public class GulagField extends Field{
|
||||||
|
|
||||||
private int bailCost = 500;
|
private int bailCost = 500;
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an abstract property field in the Monopoly game.
|
* Represents an abstract property field in the Monopoly game.
|
||||||
* Contains attributes related to ownership, price, rent, and mortgage status.
|
* Contains attributes related to ownership, price, rent, and mortgage status.
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public abstract class PropertyField extends Field {
|
public abstract class PropertyField extends Field {
|
||||||
|
|
||||||
private final int price;
|
private final int price;
|
||||||
@@ -13,6 +16,12 @@ public abstract class PropertyField extends Field {
|
|||||||
private Player owner;
|
private Player owner;
|
||||||
private boolean mortgaged = false;
|
private boolean mortgaged = false;
|
||||||
|
|
||||||
|
private PropertyField() {
|
||||||
|
super("", 0);
|
||||||
|
this.price = 0;
|
||||||
|
this.rent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a PropertyField with the specified name, ID, price, and rent.
|
* Constructs a PropertyField with the specified name, ID, price, and rent.
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
public class TestStreckeField extends Field{
|
public class TestStreckeField extends Field{
|
||||||
private int money;
|
private int money;
|
||||||
|
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
package pp.monopoly.model.fields;
|
package pp.monopoly.model.fields;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
public class WacheField extends Field{
|
public class WacheField extends Field{
|
||||||
|
|
||||||
public WacheField() {
|
WacheField() {
|
||||||
super("Wache", 30);
|
super("Wache", 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,25 +1,26 @@
|
|||||||
|
////////////////////////////////////////
|
||||||
|
// Programming project code
|
||||||
|
// UniBw M, 2022, 2023, 2024
|
||||||
|
// www.unibw.de/inf2
|
||||||
|
// (c) Mark Minas (mark.minas@unibw.de)
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
package pp.monopoly.notification;
|
package pp.monopoly.notification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event when a sound needs to be played.
|
* Event when an item is added to a map.
|
||||||
*
|
*
|
||||||
* @param soundFileName the sound file to be played
|
* @param sound the sound to be played
|
||||||
*/
|
*/
|
||||||
public class SoundEvent implements GameEvent {
|
public record SoundEvent(Sound sound) implements GameEvent {
|
||||||
private final String soundFileName;
|
|
||||||
|
|
||||||
public SoundEvent(Sound sound) {
|
|
||||||
this.soundFileName = sound.getFileName(); // Angenommen, Sound hat eine Methode getFileName()
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSoundFileName() {
|
|
||||||
return soundFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the game event listener of this event.
|
||||||
|
*
|
||||||
|
* @param listener the game event listener
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void notifyListener(GameEventListener listener) {
|
public void notifyListener(GameEventListener listener) {
|
||||||
listener.receivedEvent(this);
|
listener.receivedEvent(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -43,6 +43,18 @@ import pp.monopoly.message.server.ServerMessage;
|
|||||||
import pp.monopoly.model.Figure;
|
import pp.monopoly.model.Figure;
|
||||||
import pp.monopoly.model.IntPoint;
|
import pp.monopoly.model.IntPoint;
|
||||||
import pp.monopoly.model.LimitedLinkedList;
|
import pp.monopoly.model.LimitedLinkedList;
|
||||||
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
|
import pp.monopoly.model.fields.EventField;
|
||||||
|
import pp.monopoly.model.fields.Field;
|
||||||
|
import pp.monopoly.model.fields.FieldColor;
|
||||||
|
import pp.monopoly.model.fields.FineField;
|
||||||
|
import pp.monopoly.model.fields.FoodField;
|
||||||
|
import pp.monopoly.model.fields.GateField;
|
||||||
|
import pp.monopoly.model.fields.GoField;
|
||||||
|
import pp.monopoly.model.fields.GulagField;
|
||||||
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
|
import pp.monopoly.model.fields.TestStreckeField;
|
||||||
|
import pp.monopoly.model.fields.WacheField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server implementing the visitor pattern as MessageReceiver for ClientMessages
|
* Server implementing the visitor pattern as MessageReceiver for ClientMessages
|
||||||
@@ -129,7 +141,19 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
|||||||
Serializer.registerClass(NextPlayerTurn.class);
|
Serializer.registerClass(NextPlayerTurn.class);
|
||||||
Serializer.registerClass(Player.class);
|
Serializer.registerClass(Player.class);
|
||||||
Serializer.registerClass(Figure.class);
|
Serializer.registerClass(Figure.class);
|
||||||
Serializer.registerClass(PlayerHandler.class);
|
// Serializer.registerClass(PlayerHandler.class);
|
||||||
|
// Serializer.registerClass(BuildingProperty.class);
|
||||||
|
// Serializer.registerClass(EventField.class);
|
||||||
|
// Serializer.registerClass(Field.class);
|
||||||
|
// // Serializer.registerClass(FieldColor.class);
|
||||||
|
// Serializer.registerClass(FineField.class);
|
||||||
|
// Serializer.registerClass(FoodField.class);
|
||||||
|
// Serializer.registerClass(GateField.class);
|
||||||
|
// Serializer.registerClass(GoField.class);
|
||||||
|
// Serializer.registerClass(GulagField.class);
|
||||||
|
// Serializer.registerClass(PropertyField.class);
|
||||||
|
// Serializer.registerClass(TestStreckeField.class);
|
||||||
|
// Serializer.registerClass(WacheField.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
|
Reference in New Issue
Block a user