mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 23:59:44 +01:00
Merge remote-tracking branch 'origin/gui' into gui
This commit is contained in:
commit
fe68d991fc
@ -246,11 +246,12 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ViewAssetsRequest msg, int from) {
|
public void received(ViewAssetsRequest msg, int from) {
|
||||||
Player player = playerHandler.getPlayerById(from);
|
Player sender = playerHandler.getPlayerById(from);
|
||||||
if (player != null) {
|
Player player = msg.getPlayer();
|
||||||
LOGGER.log(Level.DEBUG, "Processing ViewAssetsRequest for player {0}", player.getName());
|
if (sender != null && player != null) {
|
||||||
|
LOGGER.log(Level.DEBUG, "Processing ViewAssetsRequest for player {0}", sender.getName());
|
||||||
|
|
||||||
send(player, new ViewAssetsResponse(player.getProperties(), player.getAccountBalance(), player.getNumJailCard()));
|
send(sender, new ViewAssetsResponse(boardManager, player.getProperties(), player.getAccountBalance(), player.getNumJailCard()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,25 @@
|
|||||||
package pp.monopoly.message.client;
|
package pp.monopoly.message.client;
|
||||||
|
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a request from a player to view their assets.
|
* Represents a request from a player to view their assets.
|
||||||
*/
|
*/
|
||||||
public class ViewAssetsRequest extends ClientMessage{
|
public class ViewAssetsRequest extends ClientMessage{
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
|
||||||
|
public ViewAssetsRequest(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
public void accept(ClientInterpreter interpreter, int from) {
|
||||||
interpreter.received(this, from);
|
interpreter.received(this, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,13 +2,16 @@ package pp.monopoly.message.server;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.PropertyField;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a response containing the player's assets.
|
* Represents a response containing the player's assets.
|
||||||
*/
|
*/
|
||||||
public class ViewAssetsResponse extends ServerMessage{
|
public class ViewAssetsResponse extends ServerMessage{
|
||||||
|
|
||||||
private final List<PropertyField> properties;
|
private final List<PropertyField> properties;
|
||||||
|
private final BoardManager board;
|
||||||
private final int accountBalance;
|
private final int accountBalance;
|
||||||
private final int jailCards;
|
private final int jailCards;
|
||||||
|
|
||||||
@ -18,7 +21,8 @@ public class ViewAssetsResponse extends ServerMessage{
|
|||||||
* @param properties a List of PropertyField objects representing the player's properties
|
* @param properties a List of PropertyField objects representing the player's properties
|
||||||
* @param accountBalance the player's current account balance
|
* @param accountBalance the player's current account balance
|
||||||
*/
|
*/
|
||||||
public ViewAssetsResponse(List<PropertyField> properties, int accountBalance, int jailCards) {
|
public ViewAssetsResponse(BoardManager board, List<PropertyField> properties, int accountBalance, int jailCards) {
|
||||||
|
this.board = board;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.accountBalance = accountBalance;
|
this.accountBalance = accountBalance;
|
||||||
this.jailCards = jailCards;
|
this.jailCards = jailCards;
|
||||||
@ -47,4 +51,7 @@ public class ViewAssetsResponse extends ServerMessage{
|
|||||||
return jailCards;
|
return jailCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BoardManager getboard() {
|
||||||
|
return board;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class BoardManager {
|
|||||||
* Creates a Monopoly GameBoard
|
* Creates a Monopoly GameBoard
|
||||||
* @return the List of Fields in correct Order
|
* @return the List of Fields in correct Order
|
||||||
*/
|
*/
|
||||||
private static List<Field> createBoard() {
|
private List<Field> createBoard() {
|
||||||
ArrayList<Field> fields = new ArrayList<>();
|
ArrayList<Field> fields = new ArrayList<>();
|
||||||
|
|
||||||
fields.add(new GoField());
|
fields.add(new GoField());
|
||||||
@ -88,4 +88,8 @@ public class BoardManager {
|
|||||||
if (board.contains(field)) return field.getId();
|
if (board.contains(field)) return field.getId();
|
||||||
else throw new NoSuchElementException();
|
else throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Field> getBoard() {
|
||||||
|
return board;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user