mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 06:06:15 +01:00
Merge branch 'gui' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into gui
This commit is contained in:
commit
85e0c68a36
@ -165,7 +165,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
* Constructs a new {@code MonopolyApp} instance.
|
* Constructs a new {@code MonopolyApp} instance.
|
||||||
* Initializes the configuration, server connection, and game logic listeners.
|
* Initializes the configuration, server connection, and game logic listeners.
|
||||||
*/
|
*/
|
||||||
private MonopolyApp() {
|
public MonopolyApp() {
|
||||||
config = new MonopolyAppConfig();
|
config = new MonopolyAppConfig();
|
||||||
config.readFromIfExists(CONFIG_FILE);
|
config.readFromIfExists(CONFIG_FILE);
|
||||||
serverConnection = makeServerConnection();
|
serverConnection = makeServerConnection();
|
||||||
|
@ -370,6 +370,10 @@ public class TestWorld implements GameEventListener {
|
|||||||
new TimeOut(app).open();
|
new TimeOut(app).open();
|
||||||
} else if (event.msg().equals("tradeRequest")) {
|
} else if (event.msg().equals("tradeRequest")) {
|
||||||
new ConfirmTrade(app).open();
|
new ConfirmTrade(app).open();
|
||||||
|
} else if (event.msg().equals("goingToJail")) {
|
||||||
|
new Gulag(app).open();
|
||||||
|
} else if (event.msg().equals("NoMoneyWarning")) {
|
||||||
|
new NoMoneyWarning(app).open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +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.popups.Bankrupt;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.message.client.EndTurn;
|
import pp.monopoly.message.client.EndTurn;
|
||||||
@ -185,8 +186,12 @@ public class Toolbar extends Dialog implements GameEventListener {
|
|||||||
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0));
|
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0));
|
||||||
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
if (app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getAccountBalance() < 0) {
|
||||||
|
new Bankrupt(app).open();
|
||||||
|
} else {
|
||||||
app.getGameLogic().send(new EndTurn());
|
app.getGameLogic().send(new EndTurn());
|
||||||
receivedEvent(new ButtonStatusEvent(false));
|
receivedEvent(new ButtonStatusEvent(false));
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
return endTurnButton;
|
return endTurnButton;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class Bankrupt extends Dialog {
|
|||||||
// Beenden-Button
|
// Beenden-Button
|
||||||
Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
||||||
quitButton.setFontSize(32);
|
quitButton.setFontSize(32);
|
||||||
quitButton.addClickCommands(source -> close());
|
quitButton.addClickCommands(source -> ifTopDialog(this::close));
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
|
@ -68,14 +68,14 @@ public class EventCardPopup extends Dialog {
|
|||||||
eventCardContainer.setLocalTranslation(
|
eventCardContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y) / 2,
|
||||||
8
|
10
|
||||||
);
|
);
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y+ padding) / 2,
|
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y+ padding) / 2,
|
||||||
7
|
9
|
||||||
);
|
);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(eventCardContainer);
|
app.getGuiNode().attachChild(eventCardContainer);
|
||||||
|
@ -261,10 +261,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(JailEvent msg) {
|
public void received(JailEvent msg) {
|
||||||
if (msg.isGoingToJail()) {
|
if (msg.isGoingToJail()) {
|
||||||
|
|
||||||
playSound(Sound.GULAG);
|
playSound(Sound.GULAG);
|
||||||
} else {
|
notifyListeners(new PopUpEvent("goingToJail", msg));
|
||||||
System.out.println("NO MORE JAIL");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,6 +343,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
public void received(NotificationMessage msg) {
|
public void received(NotificationMessage msg) {
|
||||||
if (msg.getKeyWord().equals("rent")) {
|
if (msg.getKeyWord().equals("rent")) {
|
||||||
notifyListeners(new PopUpEvent("rent", msg));
|
notifyListeners(new PopUpEvent("rent", msg));
|
||||||
|
} else if (msg.getKeyWord().equals("jailpay")) {
|
||||||
|
notifyListeners(new PopUpEvent(msg.getKeyWord(), msg));
|
||||||
|
} else if(msg.getKeyWord().equals("NoMoneyWarning")) {
|
||||||
|
notifyListeners(new PopUpEvent("NoMoneyWarning", msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,14 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
return accountBalance >= 0;
|
return accountBalance >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(PlayerState state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the player by a given number of steps, handling board wrapping.
|
* Moves the player by a given number of steps, handling board wrapping.
|
||||||
*
|
*
|
||||||
@ -324,6 +332,7 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
public Void visit(BuildingProperty field) {
|
public Void visit(BuildingProperty field) {
|
||||||
if(field.getOwner() == null) {
|
if(field.getOwner() == null) {
|
||||||
if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest());
|
if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||||
|
else getHandler().getLogic().send(this, new NotificationMessage("NoMoneyWarning"));
|
||||||
} else if (field.getOwner() != this){
|
} else if (field.getOwner() != this){
|
||||||
int rent = field.calcRent();
|
int rent = field.calcRent();
|
||||||
field.getOwner().earnMoney(rent);
|
field.getOwner().earnMoney(rent);
|
||||||
@ -486,6 +495,7 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
*/
|
*/
|
||||||
private static int rollDice() {
|
private static int rollDice() {
|
||||||
return random.nextInt(6) + 1;
|
return random.nextInt(6) + 1;
|
||||||
|
// return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,6 +614,7 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
remainingAttempts--;
|
remainingAttempts--;
|
||||||
if (remainingAttempts <= 0) {
|
if (remainingAttempts <= 0) {
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage("jailpay"));
|
handler.getLogic().send(Player.this, new NotificationMessage("jailpay"));
|
||||||
|
if(getOutOfJailCard == 0) payBail();
|
||||||
} else {
|
} else {
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage("jailtryagain"));
|
handler.getLogic().send(Player.this, new NotificationMessage("jailtryagain"));
|
||||||
}
|
}
|
||||||
@ -614,23 +625,15 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void payBail() {
|
public void payBail() {
|
||||||
if (accountBalance >= 500) {
|
|
||||||
pay(500);
|
pay(500);
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
|
||||||
state = new ActiveState();
|
state = new ActiveState();
|
||||||
} else {
|
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void useJailCard() {
|
public void useJailCard() {
|
||||||
if (getOutOfJailCard > 0) {
|
if (getOutOfJailCard > 0) {
|
||||||
removeJailCard();
|
removeJailCard();
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
|
||||||
state = new ActiveState();
|
state = new ActiveState();
|
||||||
} else {
|
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,13 @@ import pp.monopoly.message.client.AlterProperty;
|
|||||||
import pp.monopoly.message.client.BuyPropertyResponse;
|
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.NotificationAnswer;
|
||||||
import pp.monopoly.message.client.PlayerReady;
|
import pp.monopoly.message.client.PlayerReady;
|
||||||
import pp.monopoly.message.client.RollDice;
|
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.GameOver;
|
||||||
import pp.monopoly.message.server.GameStart;
|
import pp.monopoly.message.server.GameStart;
|
||||||
import pp.monopoly.message.server.NextPlayerTurn;
|
import pp.monopoly.message.server.NextPlayerTurn;
|
||||||
import pp.monopoly.message.server.PlayerStatusUpdate;
|
import pp.monopoly.message.server.PlayerStatusUpdate;
|
||||||
@ -181,8 +183,14 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
send(next, new NextPlayerTurn());
|
send(next, new NextPlayerTurn());
|
||||||
send(next, new PlayerStatusUpdate(playerHandler));
|
send(next, new PlayerStatusUpdate(playerHandler));
|
||||||
send(player, new PlayerStatusUpdate(playerHandler));
|
send(player, new PlayerStatusUpdate(playerHandler));
|
||||||
|
} else {
|
||||||
|
send(player, new GameOver(false));
|
||||||
|
playerHandler.removePlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(playerHandler.getPlayers().size() == 1) {
|
||||||
|
send(playerHandler.getPlayerAtIndex(0), new GameOver(true));
|
||||||
|
}
|
||||||
updateAllPlayers();
|
updateAllPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,5 +408,18 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateAllPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(NotificationAnswer msg, int from) {
|
||||||
|
if(msg.getKeyword().equals("UseJailCard")) {
|
||||||
|
playerHandler.getPlayerById(from).useJailCard();
|
||||||
|
} else if (msg.getKeyword().equals("PayJail")) {
|
||||||
|
playerHandler.getPlayerById(from).payBail();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateAllPlayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,4 +74,12 @@ public interface ClientInterpreter {
|
|||||||
* @param from the connection ID from which the message was received
|
* @param from the connection ID from which the message was received
|
||||||
*/
|
*/
|
||||||
void received(AlterProperty msg, int from);
|
void received(AlterProperty msg, int from);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes a received NotificationAnswer.
|
||||||
|
*
|
||||||
|
* @param msg the NotificationAnswer to be processed
|
||||||
|
* @param from the connection ID from which the message was received
|
||||||
|
*/
|
||||||
|
void received(NotificationAnswer msg, int from);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package pp.monopoly.message.client;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
public class NotificationAnswer extends ClientMessage{
|
||||||
|
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
private NotificationAnswer() {}
|
||||||
|
|
||||||
|
public NotificationAnswer(String keyword) {
|
||||||
|
this.keyword = keyword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKeyword() {
|
||||||
|
return keyword;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(ClientInterpreter interpreter, int from) {
|
||||||
|
interpreter.received(this, from);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -19,7 +19,7 @@ public class Card {
|
|||||||
return description;
|
return description;
|
||||||
} // TODO wird gerade in der EventCard zur erstellung des Popup genutzt
|
} // TODO wird gerade in der EventCard zur erstellung des Popup genutzt
|
||||||
|
|
||||||
String getKeyword() {
|
public String getKeyword() {
|
||||||
return keyword;
|
return keyword;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,387 +0,0 @@
|
|||||||
/*
|
|
||||||
package pp.monopoly;
|
|
||||||
import org.junit.Test;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
public class Testhandbuch {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// T001 UC-game-01 - testStartApplication
|
|
||||||
@Test
|
|
||||||
public void testStartApplication() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
|
||||||
assertNotNull(mainMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
// T002 UC-game-02 - testOpenStartMenu
|
|
||||||
@Test
|
|
||||||
public void testOpenStartMenu() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
|
||||||
mainMenu.showMenu();
|
|
||||||
assertTrue(mainMenu.isMenuVisible());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T003 UC-game-03 - testNavigateToPlayOption
|
|
||||||
@Test
|
|
||||||
public void testNavigateToPlayOption() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
|
||||||
mainMenu.showMenu();
|
|
||||||
mainMenu.startNewGame();
|
|
||||||
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
|
||||||
assertNotNull(newGameMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
// T004 UC-game-04 - testExitApplicationFromMenu
|
|
||||||
@Test
|
|
||||||
public void testExitApplicationFromMenu() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
|
||||||
mainMenu.showMenu();
|
|
||||||
mainMenu.exitGame();
|
|
||||||
assertTrue(app.isClosed());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T005 UC-game-05 - testOpenSettingsFromMenu
|
|
||||||
@Test
|
|
||||||
public void testOpenSettingsFromMenu() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
|
||||||
mainMenu.showMenu();
|
|
||||||
mainMenu.openSettings();
|
|
||||||
SettingMenu settingMenu = app.getStateManager().getState(SettingMenu.class);
|
|
||||||
assertNotNull(settingMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
// T006 UC-game-06 - testOpenGameMenuWithESC
|
|
||||||
@Test
|
|
||||||
public void testOpenGameMenuWithESC() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
app.simpleUpdate(0.1f);
|
|
||||||
GameMenu gameMenu = app.getStateManager().getState(GameMenu.class);
|
|
||||||
assertTrue(gameMenu.isVisible());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T007 UC-game-07 - testEnterHostName
|
|
||||||
@Test
|
|
||||||
public void testEnterHostName() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
|
||||||
newGameMenu.showMenu();
|
|
||||||
newGameMenu.enterHostName("localhost");
|
|
||||||
assertEquals("localhost", newGameMenu.getHostName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T008 UC-game-07 - testEnterPortNumber
|
|
||||||
@Test
|
|
||||||
public void testEnterPortNumber() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
|
||||||
newGameMenu.showMenu();
|
|
||||||
newGameMenu.enterPortNumber(12345);
|
|
||||||
assertEquals(12345, newGameMenu.getPortNumber());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T009 UC-game-07 - testCancelGameCreation
|
|
||||||
@Test
|
|
||||||
public void testCancelGameCreation() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
|
||||||
newGameMenu.showMenu();
|
|
||||||
newGameMenu.cancel();
|
|
||||||
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
|
||||||
assertTrue(mainMenu.isMenuVisible());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T010 UC-game-08 - testEnterPlayerLobby
|
|
||||||
@Test
|
|
||||||
public void testEnterPlayerLobby() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
app.getStateManager().getState(NetworkDialog.class).connect();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
assertNotNull(lobby);
|
|
||||||
}
|
|
||||||
|
|
||||||
// T011 UC-game-09 - testEnterStartingCapital
|
|
||||||
@Test
|
|
||||||
public void testEnterStartingCapital() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
|
||||||
newGameMenu.showMenu();
|
|
||||||
newGameMenu.enterStartingCapital(1500);
|
|
||||||
assertEquals(1500, newGameMenu.getStartingCapital());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T012 UC-game-09 - testIncreaseStartingCapital
|
|
||||||
@Test
|
|
||||||
public void testIncreaseStartingCapital() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
|
||||||
newGameMenu.showMenu();
|
|
||||||
newGameMenu.enterStartingCapital(1500);
|
|
||||||
newGameMenu.increaseStartingCapital(100);
|
|
||||||
assertEquals(1600, newGameMenu.getStartingCapital());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T013 UC-game-09 - testDecreaseStartingCapital
|
|
||||||
@Test
|
|
||||||
public void testDecreaseStartingCapital() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
|
||||||
newGameMenu.showMenu();
|
|
||||||
newGameMenu.enterStartingCapital(1500);
|
|
||||||
newGameMenu.decreaseStartingCapital(100);
|
|
||||||
assertEquals(1400, newGameMenu.getStartingCapital());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T014 UC-game-10 - testDefaultPlayerName
|
|
||||||
@Test
|
|
||||||
public void testDefaultPlayerName() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
app.getStateManager().getState(Lobby.class).initializePlayerNames();
|
|
||||||
assertEquals("Spieler 1", app.getStateManager().getState(Lobby.class).getPlayerName(0));
|
|
||||||
assertEquals("Spieler 2", app.getStateManager().getState(Lobby.class).getPlayerName(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T015 UC-game-11 - testEnterDisplayName
|
|
||||||
@Test
|
|
||||||
public void testEnterDisplayName() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.enterDisplayName("TestPlayer");
|
|
||||||
assertEquals("TestPlayer", lobby.getPlayerName(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T016 UC-game-11 - testDuplicateNameEntry
|
|
||||||
@Test
|
|
||||||
public void testDuplicateNameEntry() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.enterDisplayName("Player1");
|
|
||||||
assertTrue(lobby.isDuplicateName("Player1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T017 UC-game-12 - testSelectPlayerColor
|
|
||||||
@Test
|
|
||||||
public void testSelectPlayerColor() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.selectColor("Red");
|
|
||||||
assertEquals("Red", lobby.getPlayerColor(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T018 UC-game-12 - testSelectOccupiedColor
|
|
||||||
@Test
|
|
||||||
public void testSelectOccupiedColor() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.selectColor("Red");
|
|
||||||
assertTrue(lobby.isColorOccupied("Red"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T019 UC-game-13 - testSelectPlayerToken
|
|
||||||
@Test
|
|
||||||
public void testSelectPlayerToken() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.selectToken("Ship");
|
|
||||||
assertEquals("Ship", lobby.getPlayerToken(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T020 UC-game-13 - testSelectOccupiedToken
|
|
||||||
@Test
|
|
||||||
public void testSelectOccupiedToken() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.selectToken("Ship");
|
|
||||||
assertTrue(lobby.isTokenOccupied("Ship"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T021 UC-game-14 - testCancelPlayerLobby
|
|
||||||
@Test
|
|
||||||
public void testCancelPlayerLobby() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.cancel();
|
|
||||||
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
|
||||||
assertTrue(mainMenu.isMenuVisible());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T022 UC-game-15 - testOpenLobbyMenuWithESC
|
|
||||||
@Test
|
|
||||||
public void testOpenLobbyMenuWithESC() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
app.simpleUpdate(0.1f);
|
|
||||||
LobbyMenu lobbyMenu = app.getStateManager().getState(LobbyMenu.class);
|
|
||||||
assertTrue(lobbyMenu.isVisible());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T023 UC-game-16 - testPlayerReadyConfirmation
|
|
||||||
@Test
|
|
||||||
public void testPlayerReadyConfirmation() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.setPlayerReady(true);
|
|
||||||
assertTrue(lobby.isPlayerReady(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T024 UC-game-17 - testStartGame
|
|
||||||
@Test
|
|
||||||
public void testStartGame() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
|
||||||
lobby.startGame();
|
|
||||||
assertEquals(GameState.InGame, lobby.getGameState());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T025 UC-game-18 - testPlayerMovement
|
|
||||||
@Test
|
|
||||||
public void testPlayerMovement() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
player.move(5);
|
|
||||||
assertEquals(5, player.getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T026 UC-game-19 - testPurchaseProperty
|
|
||||||
@Test
|
|
||||||
public void testPurchaseProperty() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
Property property = game.getProperty(0);
|
|
||||||
player.buyProperty(property);
|
|
||||||
assertTrue(player.getProperties().contains(property));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T027 UC-game-20 - testMovePlayerOnDiceRoll
|
|
||||||
@Test
|
|
||||||
public void testMovePlayerOnDiceRoll() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
int initialPosition = player.getPosition();
|
|
||||||
player.rollDice();
|
|
||||||
assertTrue(player.getPosition() > initialPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
// T028 UC-game-21 - testPassGo
|
|
||||||
@Test
|
|
||||||
public void testPassGo() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
player.move(40); // Assuming 40 steps moves player to Go
|
|
||||||
assertTrue(player.passedGo());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T029 UC-game-22 - testCollectMoneyFromGo
|
|
||||||
@Test
|
|
||||||
public void testCollectMoneyFromGo() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
int initialBalance = player.getBalance();
|
|
||||||
player.move(40); // Move to Go
|
|
||||||
assertTrue(player.getBalance() > initialBalance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// T030 UC-game-23 - testPayRent
|
|
||||||
@Test
|
|
||||||
public void testPayRent() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
PropertyField property = (PropertyField) game.getField(1);
|
|
||||||
player.move(1);
|
|
||||||
int initialBalance = player.getBalance();
|
|
||||||
player.payRent(property);
|
|
||||||
assertTrue(player.getBalance() < initialBalance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// T031 UC-game-24 - testDeclareBankruptcy
|
|
||||||
@Test
|
|
||||||
public void testDeclareBankruptcy() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
player.declareBankruptcy();
|
|
||||||
assertEquals(PlayerState.Bankrupt, player.getState());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T032 UC-game-25 - testTradeProperty
|
|
||||||
@Test
|
|
||||||
public void testTradeProperty() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player1 = game.getPlayer(0);
|
|
||||||
Player player2 = game.getPlayer(1);
|
|
||||||
Property property = game.getProperty(0);
|
|
||||||
player1.offerTrade(player2, property);
|
|
||||||
assertTrue(player2.hasProperty(property));
|
|
||||||
}
|
|
||||||
|
|
||||||
// T033 UC-game-26 - testGameOverCondition
|
|
||||||
@Test
|
|
||||||
public void testGameOverCondition() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
player.declareBankruptcy();
|
|
||||||
assertTrue(game.isGameOver());
|
|
||||||
}
|
|
||||||
|
|
||||||
// T034 UC-game-27 - testPlayerInJail
|
|
||||||
@Test
|
|
||||||
public void testPlayerInJail() {
|
|
||||||
MonopolyApp app = new MonopolyApp();
|
|
||||||
app.simpleInitApp();
|
|
||||||
Game game = app.getStateManager().getState(Game.class);
|
|
||||||
Player player = game.getPlayer(0);
|
|
||||||
game.sendToJail(player);
|
|
||||||
assertEquals(PlayerState.InJail, player.getState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
@ -1,11 +1,13 @@
|
|||||||
package pp.monopoly.client;
|
package pp.monopoly.client;
|
||||||
|
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.simsilica.lemur.Button;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
public class ClientLogicTest {
|
public class ClientLogicTest {
|
||||||
@ -41,7 +43,7 @@ public class ClientLogicTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
// T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
|
// T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
|
||||||
public void testOpenStartMenu() {
|
public void testOpenStartMenu1() {
|
||||||
// Mock des Startmenü-Kindes
|
// Mock des Startmenü-Kindes
|
||||||
Spatial startMenuMock = mock(Spatial.class);
|
Spatial startMenuMock = mock(Spatial.class);
|
||||||
when(guiNodeMock.getChild("StartMenu")).thenReturn(startMenuMock);
|
when(guiNodeMock.getChild("StartMenu")).thenReturn(startMenuMock);
|
||||||
@ -53,7 +55,7 @@ public class ClientLogicTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
// T003: UC-game-03 - Überprüft, ob der „Spiel starten“-Button das Spielerstellungsmenü öffnet
|
// T003: UC-game-03 - Überprüft, ob der „Spiel starten“-Button das Spielerstellungsmenü öffnet
|
||||||
public void testNavigateToPlayOption() {
|
public void testNavigateToPlayOption1() {
|
||||||
// Mock des Spielerstellungsmenü-Kindes
|
// Mock des Spielerstellungsmenü-Kindes
|
||||||
Spatial playMenuMock = mock(Spatial.class);
|
Spatial playMenuMock = mock(Spatial.class);
|
||||||
when(guiNodeMock.getChild("PlayMenu")).thenReturn(playMenuMock);
|
when(guiNodeMock.getChild("PlayMenu")).thenReturn(playMenuMock);
|
||||||
@ -65,7 +67,7 @@ public class ClientLogicTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
// T004: UC-game-04 - Testet, ob die Anwendung geschlossen wird, wenn „Beenden“ im Hauptmenü gewählt wird
|
// T004: UC-game-04 - Testet, ob die Anwendung geschlossen wird, wenn „Beenden“ im Hauptmenü gewählt wird
|
||||||
public void testExitApplicationFromMenu() {
|
public void testExitApplicationFromMenu1() {
|
||||||
// Simuliere den Schließen-Aufruf
|
// Simuliere den Schließen-Aufruf
|
||||||
doNothing().when(app).closeApp();
|
doNothing().when(app).closeApp();
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ public class ClientLogicTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
// T005: UC-game-05 - Überprüft, ob das Einstellungen-Menü aus dem Hauptmenü aufgerufen werden kann
|
// T005: UC-game-05 - Überprüft, ob das Einstellungen-Menü aus dem Hauptmenü aufgerufen werden kann
|
||||||
public void testOpenSettingsFromMenu() {
|
public void testOpenSettingsFromMenu1() {
|
||||||
// Mock des Einstellungsmenü-Kindes
|
// Mock des Einstellungsmenü-Kindes
|
||||||
Spatial settingsMenuMock = mock(Spatial.class);
|
Spatial settingsMenuMock = mock(Spatial.class);
|
||||||
when(guiNodeMock.getChild("SettingsMenu")).thenReturn(settingsMenuMock);
|
when(guiNodeMock.getChild("SettingsMenu")).thenReturn(settingsMenuMock);
|
||||||
@ -90,26 +92,26 @@ public class ClientLogicTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
// T006: UC-game-06 - Testet, ob das Spielmenü geöffnet wird, wenn der Spieler im Spiel „ESC“ drückt
|
// T006: UC-game-06 - Testet, ob das Spielmenü geöffnet wird, wenn der Spieler im Spiel „ESC“ drückt
|
||||||
public void testOpenGameMenuWithESC() {
|
public void testOpenGameMenuWithESC1() {
|
||||||
// Simuliere den ESC-Tastendruck
|
// Simuliere den ESC-Tastendruck
|
||||||
doNothing().when(app).handleEscape(true);
|
doNothing().when(app).escape(true);
|
||||||
|
|
||||||
// Rufe die ESC-Tastenmethode auf
|
// Rufe die ESC-Tastenmethode auf
|
||||||
app.handleEscape(true);
|
app.escape(true);
|
||||||
|
|
||||||
// Verifiziere, dass die Methode aufgerufen wurde
|
// Verifiziere, dass die Methode aufgerufen wurde
|
||||||
verify(app, times(1)).handleEscape(true);
|
verify(app, times(1)).escape(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/*
|
|
||||||
@Test
|
@Test
|
||||||
// T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
|
// T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
|
||||||
public void testOpenStartMenu() {
|
public void testOpenStartMenu() {
|
||||||
Spatial startMenu = app.getGuiNode().getChild("StartMenu");
|
Spatial startMenu = app.getGuiNode().getChild("StartMenu");
|
||||||
assertNotNull("Das Startmenü sollte sichtbar sein", startMenu);
|
assertNotNull("Das Startmenü sollte sichtbar sein", startMenu);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*
|
|
||||||
@Test
|
@Test
|
||||||
// T002: UC-game-02 - Überprüft, ob das Startmenü (MainMenu) angezeigt wird und die Buttons korrekt funktionieren
|
// T002: UC-game-02 - Überprüft, ob das Startmenü (MainMenu) angezeigt wird und die Buttons korrekt funktionieren
|
||||||
public void testMainMenuButtons() {
|
public void testMainMenuButtons() {
|
||||||
@ -236,4 +238,3 @@ public void testMainMenuButtons() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
@ -1,5 +1,5 @@
|
|||||||
package pp.monopoly.game.client;
|
package pp.monopoly.game.client;
|
||||||
/*
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@ -14,7 +14,6 @@ import static org.mockito.Mockito.*;
|
|||||||
/**
|
/**
|
||||||
* Tests the client-side logic of the Monopoly game.
|
* Tests the client-side logic of the Monopoly game.
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
public class ClientGameLogicTest {
|
public class ClientGameLogicTest {
|
||||||
|
|
||||||
private ClientGameLogic logic;
|
private ClientGameLogic logic;
|
||||||
@ -120,4 +119,3 @@ public class ClientGameLogicTest {
|
|||||||
assertTrue("The player should be able to select an available color.", result);
|
assertTrue("The player should be able to select an available color.", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +0,0 @@
|
|||||||
package pp.monopoly.model;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
public class RandomPositionIteratorTest {
|
|
||||||
|
|
||||||
}
|
|
@ -41,6 +41,7 @@ import pp.monopoly.message.client.ViewAssetsRequest;
|
|||||||
import pp.monopoly.message.server.BuyPropertyRequest;
|
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.GameStart;
|
import pp.monopoly.message.server.GameStart;
|
||||||
import pp.monopoly.message.server.JailEvent;
|
import pp.monopoly.message.server.JailEvent;
|
||||||
import pp.monopoly.message.server.NextPlayerTurn;
|
import pp.monopoly.message.server.NextPlayerTurn;
|
||||||
@ -176,6 +177,7 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
|||||||
Serializer.registerClass(NotificationMessage.class);
|
Serializer.registerClass(NotificationMessage.class);
|
||||||
Serializer.registerClass(JailEvent.class);
|
Serializer.registerClass(JailEvent.class);
|
||||||
Serializer.registerClass(AlterProperty.class);
|
Serializer.registerClass(AlterProperty.class);
|
||||||
|
Serializer.registerClass(GameOver.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
|
Loading…
Reference in New Issue
Block a user