mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 06:40:00 +01:00
open buy popups
This commit is contained in:
parent
e000dcfc51
commit
1e6188cf24
@ -10,10 +10,18 @@ import com.jme3.scene.shape.Box;
|
|||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
|
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
import pp.monopoly.client.gui.popups.BuyCard;
|
||||||
import pp.monopoly.client.gui.popups.EventCard;
|
import pp.monopoly.client.gui.popups.EventCard;
|
||||||
|
import pp.monopoly.client.gui.popups.FoodFieldCard;
|
||||||
|
import pp.monopoly.client.gui.popups.GateFieldCard;
|
||||||
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
|
import pp.monopoly.model.fields.FoodField;
|
||||||
|
import pp.monopoly.model.fields.GateField;
|
||||||
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.DiceRollEvent;
|
import pp.monopoly.notification.DiceRollEvent;
|
||||||
import pp.monopoly.notification.EventCardEvent;
|
import pp.monopoly.notification.EventCardEvent;
|
||||||
import pp.monopoly.notification.GameEventListener;
|
import pp.monopoly.notification.GameEventListener;
|
||||||
|
import pp.monopoly.notification.PopUpEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestWorld zeigt eine einfache Szene mit einem texturierten Quadrat.
|
* TestWorld zeigt eine einfache Szene mit einem texturierten Quadrat.
|
||||||
@ -101,4 +109,22 @@ public class TestWorld implements GameEventListener{
|
|||||||
public void receivedEvent(EventCardEvent event) {
|
public void receivedEvent(EventCardEvent event) {
|
||||||
new EventCard(app, event.description()).open();
|
new EventCard(app, event.description()).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receivedEvent(PopUpEvent event) {
|
||||||
|
System.err.println("Trigger ?");
|
||||||
|
// if (event.desc() == "BuyCard") {
|
||||||
|
int field = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();
|
||||||
|
Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field);
|
||||||
|
|
||||||
|
if (fieldObject instanceof BuildingProperty) {
|
||||||
|
new BuyCard(app).open();
|
||||||
|
} else if (fieldObject instanceof GateField){
|
||||||
|
new GateFieldCard(app).open();
|
||||||
|
} else if (fieldObject instanceof FoodField) {
|
||||||
|
new FoodFieldCard(app).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
@ -64,6 +64,7 @@ public class BuyCard extends Dialog {
|
|||||||
Button quitButton = buyCardContainer.addChild(new Button("Beenden", new ElementId("button")));
|
Button quitButton = buyCardContainer.addChild(new Button("Beenden", new ElementId("button")));
|
||||||
quitButton.setFontSize(32);
|
quitButton.setFontSize(32);
|
||||||
quitButton.addClickCommands(s -> ifTopDialog(() -> {
|
quitButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
|
System.err.println("Button does something?");
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
close();
|
close();
|
||||||
}));
|
}));
|
||||||
@ -72,7 +73,8 @@ public class BuyCard extends Dialog {
|
|||||||
buyButton.setFontSize(32);
|
buyButton.setFontSize(32);
|
||||||
buyButton.addClickCommands(s -> ifTopDialog( () -> {
|
buyButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
app.getGameLogic().send(new BuyPropertyRequest());
|
close();
|
||||||
|
app.getGameLogic().send(new BuyPropertyResponse());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
float padding = 10; // Padding around the settingsContainer for the background
|
float padding = 10; // Padding around the settingsContainer for the background
|
||||||
|
@ -9,7 +9,6 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,14 +71,12 @@ public class ConfirmTrade extends Dialog {
|
|||||||
negotiateButton.setFontSize(32);
|
negotiateButton.setFontSize(32);
|
||||||
negotiateButton.addClickCommands(s -> ifTopDialog( () -> {
|
negotiateButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
app.getGameLogic().send(new BuyPropertyRequest());
|
|
||||||
}));
|
}));
|
||||||
// Kaufen-Button
|
// Kaufen-Button
|
||||||
Button confirmButton = confirmTradeContainer.addChild(new Button("Bestätigen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen
|
Button confirmButton = confirmTradeContainer.addChild(new Button("Bestätigen", new ElementId("button"))); //TODO ggf die Buttons Sprachabhängig von den Properties machen
|
||||||
confirmButton.setFontSize(32);
|
confirmButton.setFontSize(32);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
app.getGameLogic().send(new BuyPropertyRequest());
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
float padding = 10; // Padding around the settingsContainer for the background
|
float padding = 10; // Padding around the settingsContainer for the background
|
||||||
|
@ -14,7 +14,7 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||||
import pp.monopoly.model.fields.FoodField;
|
import pp.monopoly.model.fields.FoodField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ public class FoodFieldCard extends Dialog {
|
|||||||
buyButton.setFontSize(32);
|
buyButton.setFontSize(32);
|
||||||
buyButton.addClickCommands(s -> ifTopDialog( () -> {
|
buyButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
app.getGameLogic().send(new BuyPropertyRequest());
|
app.getGameLogic().send(new BuyPropertyResponse());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
float padding = 10; // Padding around the settingsContainer for the background
|
float padding = 10; // Padding around the settingsContainer for the background
|
||||||
|
@ -13,7 +13,7 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||||
import pp.monopoly.model.fields.GateField;
|
import pp.monopoly.model.fields.GateField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public class GateFieldCard extends Dialog {
|
|||||||
buyButton.setFontSize(32);
|
buyButton.setFontSize(32);
|
||||||
buyButton.addClickCommands(s -> ifTopDialog(() -> {
|
buyButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
app.getGameLogic().send(new BuyPropertyRequest());
|
app.getGameLogic().send(new BuyPropertyResponse());
|
||||||
close();
|
close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ public class SellHouse extends Dialog {
|
|||||||
confirmButton.setFontSize(32);
|
confirmButton.setFontSize(32);
|
||||||
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
confirmButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
app.getGameLogic().send(new BuyPropertyRequest());
|
//TODO
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.message.client.ClientMessage;
|
import pp.monopoly.message.client.ClientMessage;
|
||||||
|
import pp.monopoly.message.server.BuyPropertyRequest;
|
||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
import pp.monopoly.message.server.EventDrawCard;
|
import pp.monopoly.message.server.EventDrawCard;
|
||||||
import pp.monopoly.message.server.GameOver;
|
import pp.monopoly.message.server.GameOver;
|
||||||
@ -30,6 +31,7 @@ import pp.monopoly.notification.GameEvent;
|
|||||||
import pp.monopoly.notification.GameEventBroker;
|
import pp.monopoly.notification.GameEventBroker;
|
||||||
import pp.monopoly.notification.GameEventListener;
|
import pp.monopoly.notification.GameEventListener;
|
||||||
import pp.monopoly.notification.InfoTextEvent;
|
import pp.monopoly.notification.InfoTextEvent;
|
||||||
|
import pp.monopoly.notification.PopUpEvent;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
import pp.monopoly.notification.SoundEvent;
|
import pp.monopoly.notification.SoundEvent;
|
||||||
import pp.monopoly.notification.UpdatePlayerView;
|
import pp.monopoly.notification.UpdatePlayerView;
|
||||||
@ -329,4 +331,9 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
notifyListeners(new ButtonStatusEvent(true));
|
notifyListeners(new ButtonStatusEvent(true));
|
||||||
setState(new ActiveState(this));
|
setState(new ActiveState(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(BuyPropertyRequest msg) {
|
||||||
|
notifyListeners(new PopUpEvent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
import pp.monopoly.message.server.BuyPropertyRequest;
|
||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
import pp.monopoly.message.server.EventDrawCard;
|
import pp.monopoly.message.server.EventDrawCard;
|
||||||
import pp.monopoly.message.server.NextPlayerTurn;
|
import pp.monopoly.message.server.NextPlayerTurn;
|
||||||
@ -40,7 +41,7 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
private String name;
|
private String name;
|
||||||
private int accountBalance = 15000;
|
private int accountBalance = 15000;
|
||||||
private Figure figure;
|
private Figure figure;
|
||||||
private List<PropertyField> properties = new ArrayList<>();
|
private transient List<PropertyField> properties = new ArrayList<>();
|
||||||
private int getOutOfJailCard;
|
private int getOutOfJailCard;
|
||||||
private int fieldID;
|
private int fieldID;
|
||||||
private DiceResult rollResult;
|
private DiceResult rollResult;
|
||||||
@ -162,11 +163,14 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
*/
|
*/
|
||||||
public int movePos(int position){
|
public int movePos(int position){
|
||||||
fieldID = fieldID+position;
|
fieldID = fieldID+position;
|
||||||
|
System.out.println("Aktuelle Position" +fieldID);
|
||||||
|
System.err.println("Würfelergebniss"+ rollResult.calcTotal());
|
||||||
if(fieldID >= 40) {
|
if(fieldID >= 40) {
|
||||||
fieldID = fieldID%40;
|
fieldID = fieldID%40;
|
||||||
earnMoney(2000);
|
earnMoney(2000);
|
||||||
}
|
}
|
||||||
figure.moveTo(fieldID);
|
figure.moveTo(fieldID);
|
||||||
|
getHandler().getLogic().send(this, new PlayerStatusUpdate(handler));
|
||||||
handler.getLogic().getBoardManager().getFieldAtIndex(fieldID).accept(this);
|
handler.getLogic().getBoardManager().getFieldAtIndex(fieldID).accept(this);
|
||||||
return fieldID;
|
return fieldID;
|
||||||
}
|
}
|
||||||
@ -299,30 +303,41 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(BuildingProperty field) {
|
public Void visit(BuildingProperty field) {
|
||||||
|
if(field.getOwner() == null) {
|
||||||
|
getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||||
|
} else if (field.getOwner() != this){
|
||||||
int rent = field.calcRent();
|
int rent = field.calcRent();
|
||||||
|
|
||||||
field.getOwner().earnMoney(rent);
|
field.getOwner().earnMoney(rent);
|
||||||
pay(rent);
|
pay(rent);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(FoodField field) {
|
public Void visit(FoodField field) {
|
||||||
|
if(field.getOwner() == null) {
|
||||||
|
getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||||
|
} else {
|
||||||
int factor = 4;
|
int factor = 4;
|
||||||
if (field.getOwner().getNumProp(field) == 2) {
|
if (field.getOwner().getNumProp(field) == 2) {
|
||||||
factor = 10;
|
factor = 10;
|
||||||
}
|
}
|
||||||
field.getOwner().earnMoney(rollResult.calcTotal()*factor);
|
field.getOwner().earnMoney(rollResult.calcTotal()*factor);
|
||||||
pay(rollResult.calcTotal()*factor);
|
pay(rollResult.calcTotal()*factor);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(GateField field) {
|
public Void visit(GateField field) {
|
||||||
|
if(field.getOwner() == null) {
|
||||||
|
getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||||
|
} else {
|
||||||
int rent = field.calcRent() * field.getOwner().getNumProp(field);
|
int rent = field.calcRent() * field.getOwner().getNumProp(field);
|
||||||
|
|
||||||
field.getOwner().earnMoney(rent);
|
field.getOwner().earnMoney(rent);
|
||||||
pay(rent);
|
pay(rent);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +390,7 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
*/
|
*/
|
||||||
public int getNumProp(PropertyField field) {
|
public int getNumProp(PropertyField field) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
if (properties.isEmpty()) return 0;
|
||||||
for (PropertyField propertyField : properties) {
|
for (PropertyField propertyField : properties) {
|
||||||
if (propertyField.getClass() == field.getClass()) {
|
if (propertyField.getClass() == field.getClass()) {
|
||||||
count++;
|
count++;
|
||||||
@ -476,6 +492,8 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
public DiceResult rollDice() {
|
public DiceResult rollDice() {
|
||||||
List<Integer> roll = List.of(Dice.rollDice(), Dice.rollDice());
|
List<Integer> roll = List.of(Dice.rollDice(), Dice.rollDice());
|
||||||
rollResult = new DiceResult(roll.get(0), roll.get(1));
|
rollResult = new DiceResult(roll.get(0), roll.get(1));
|
||||||
|
System.out.println(rollResult.calcTotal());
|
||||||
|
move(rollResult.calcTotal());
|
||||||
return rollResult;
|
return rollResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import java.lang.System.Logger;
|
|||||||
import java.lang.System.Logger.Level;
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
import pp.monopoly.MonopolyConfig;
|
import pp.monopoly.MonopolyConfig;
|
||||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||||
import pp.monopoly.message.client.ClientInterpreter;
|
import pp.monopoly.message.client.ClientInterpreter;
|
||||||
import pp.monopoly.message.client.EndTurn;
|
import pp.monopoly.message.client.EndTurn;
|
||||||
import pp.monopoly.message.client.PlayerReady;
|
import pp.monopoly.message.client.PlayerReady;
|
||||||
@ -144,19 +144,14 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
* @param from the connection ID of the player who sent the request
|
* @param from the connection ID of the player who sent the request
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(BuyPropertyRequest msg, int from) {
|
public void received(BuyPropertyResponse msg, int from) {
|
||||||
Player player = playerHandler.getPlayerById(from);
|
Player player = playerHandler.getPlayerById(from);
|
||||||
if (player != null && state == ServerState.INGAME) {
|
if (player != null) {
|
||||||
PropertyField property = (PropertyField) boardManager.getFieldAtIndex(player.move(0)); // Assuming player position for property
|
PropertyField property = (PropertyField) boardManager.getFieldAtIndex(player.getFieldID()); // Assuming player position for property
|
||||||
|
|
||||||
if (property.getOwner() == null && player.getAccountBalance() >= property.getPrice()) {
|
|
||||||
player.buyProperty(property);
|
player.buyProperty(property);
|
||||||
property.setOwner(player);
|
System.out.println("Properties:" +player.getProperties().toString());
|
||||||
player.earnMoney(-property.getPrice());
|
|
||||||
LOGGER.log(Level.INFO, "Player {0} bought property {1}", player.getName(), property.getName());
|
LOGGER.log(Level.INFO, "Player {0} bought property {1}", player.getName(), property.getName());
|
||||||
} else {
|
|
||||||
LOGGER.log(Level.WARNING, "Player {0} cannot buy property {1}", player.getName(), property.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
* Represents a request from a player to buy a property.
|
* Represents a request from a player to buy a property.
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class BuyPropertyRequest extends ClientMessage{
|
public class BuyPropertyResponse extends ClientMessage{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a BuyPropertyRequest with the specified property ID.
|
* Constructs a BuyPropertyRequest with the specified property ID.
|
||||||
*
|
*
|
||||||
* @param propertyId the ID of the property to buy
|
* @param propertyId the ID of the property to buy
|
||||||
*/
|
*/
|
||||||
public BuyPropertyRequest() {}
|
public BuyPropertyResponse() {}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -17,7 +17,7 @@ public interface ClientInterpreter {
|
|||||||
* @param msg the BuyPropertyRequest to be processed
|
* @param msg the BuyPropertyRequest to be processed
|
||||||
* @param from the connection ID from which the message was received
|
* @param from the connection ID from which the message was received
|
||||||
*/
|
*/
|
||||||
void received(BuyPropertyRequest msg, int from);
|
void received(BuyPropertyResponse msg, int from);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a received EndTurn.
|
* Processes a received EndTurn.
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package pp.monopoly.message.server;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
public class BuyPropertyRequest extends ServerMessage{
|
||||||
|
|
||||||
|
public BuyPropertyRequest(){}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(ServerInterpreter interpreter) {
|
||||||
|
interpreter.received(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -89,4 +89,11 @@ public interface ServerInterpreter {
|
|||||||
* @param msg the NextPlayerTurn message received
|
* @param msg the NextPlayerTurn message received
|
||||||
*/
|
*/
|
||||||
void received(NextPlayerTurn msg);
|
void received(NextPlayerTurn msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a NextPlayerTurn message received from the server.
|
||||||
|
*
|
||||||
|
* @param msg the NextPlayerTurn message received
|
||||||
|
*/
|
||||||
|
void received(BuyPropertyRequest msg);
|
||||||
}
|
}
|
||||||
|
@ -73,4 +73,11 @@ public interface GameEventListener {
|
|||||||
* @param event the received event
|
* @param event the received event
|
||||||
*/
|
*/
|
||||||
default void receivedEvent(ButtonStatusEvent event) { /*Do nothing */}
|
default void receivedEvent(ButtonStatusEvent event) { /*Do nothing */}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that all buttons in the toolbar should be disabled
|
||||||
|
*
|
||||||
|
* @param event the received event
|
||||||
|
*/
|
||||||
|
default void receivedEvent(PopUpEvent event) { /*Do nothing */}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package pp.monopoly.notification;
|
||||||
|
|
||||||
|
public record PopUpEvent() implements GameEvent{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyListener(GameEventListener listener) {
|
||||||
|
listener.receivedEvent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,7 +29,7 @@ import pp.monopoly.game.server.Player;
|
|||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.game.server.ServerGameLogic;
|
import pp.monopoly.game.server.ServerGameLogic;
|
||||||
import pp.monopoly.game.server.ServerSender;
|
import pp.monopoly.game.server.ServerSender;
|
||||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||||
import pp.monopoly.message.client.ClientMessage;
|
import pp.monopoly.message.client.ClientMessage;
|
||||||
import pp.monopoly.message.client.EndTurn;
|
import pp.monopoly.message.client.EndTurn;
|
||||||
import pp.monopoly.message.client.PlayerReady;
|
import pp.monopoly.message.client.PlayerReady;
|
||||||
@ -37,6 +37,7 @@ import pp.monopoly.message.client.RollDice;
|
|||||||
import pp.monopoly.message.client.TradeOffer;
|
import pp.monopoly.message.client.TradeOffer;
|
||||||
import pp.monopoly.message.client.TradeResponse;
|
import pp.monopoly.message.client.TradeResponse;
|
||||||
import pp.monopoly.message.client.ViewAssetsRequest;
|
import pp.monopoly.message.client.ViewAssetsRequest;
|
||||||
|
import pp.monopoly.message.server.BuyPropertyRequest;
|
||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
import pp.monopoly.message.server.EventDrawCard;
|
import pp.monopoly.message.server.EventDrawCard;
|
||||||
import pp.monopoly.message.server.GameStart;
|
import pp.monopoly.message.server.GameStart;
|
||||||
@ -120,6 +121,7 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
|||||||
|
|
||||||
private void initializeSerializables() {
|
private void initializeSerializables() {
|
||||||
Serializer.registerClass(IntPoint.class);
|
Serializer.registerClass(IntPoint.class);
|
||||||
|
Serializer.registerClass(BuyPropertyResponse.class);
|
||||||
Serializer.registerClass(BuyPropertyRequest.class);
|
Serializer.registerClass(BuyPropertyRequest.class);
|
||||||
Serializer.registerClass(EndTurn.class);
|
Serializer.registerClass(EndTurn.class);
|
||||||
Serializer.registerClass(PlayerReady.class);
|
Serializer.registerClass(PlayerReady.class);
|
||||||
@ -139,7 +141,7 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
myServer.addMessageListener(this, BuyPropertyRequest.class);
|
myServer.addMessageListener(this, BuyPropertyResponse.class);
|
||||||
myServer.addMessageListener(this, EndTurn.class);
|
myServer.addMessageListener(this, EndTurn.class);
|
||||||
myServer.addMessageListener(this, PlayerReady.class);
|
myServer.addMessageListener(this, PlayerReady.class);
|
||||||
myServer.addMessageListener(this, RollDice.class);
|
myServer.addMessageListener(this, RollDice.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user