fixed failing test, due to wrong assertions or missing messages, as well as... #41
@@ -1,7 +1,9 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.message.client.ForceContinueGameMessage;
|
import pp.mdga.message.client.ForceContinueGameMessage;
|
||||||
|
import pp.mdga.message.client.LeaveGameMessage;
|
||||||
import pp.mdga.message.server.ResumeGameMessage;
|
import pp.mdga.message.server.ResumeGameMessage;
|
||||||
|
import pp.mdga.notification.StartDialogNotification;
|
||||||
|
|
||||||
public class InterruptState extends ClientState {
|
public class InterruptState extends ClientState {
|
||||||
|
|
||||||
@@ -61,6 +63,13 @@ public void selectResume() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectLeave() {
|
||||||
|
logic.send(new LeaveGameMessage());
|
||||||
|
logic.addNotification(new StartDialogNotification());
|
||||||
|
logic.setState(logic.getDialogs());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server resumes the game
|
* The server resumes the game
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
import pp.mdga.game.card.SwapCard;
|
import pp.mdga.game.card.SwapCard;
|
||||||
import pp.mdga.game.card.TurboCard;
|
import pp.mdga.game.card.TurboCard;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +136,20 @@ public PowerCard draw() {
|
|||||||
* @param count the number of cards to add
|
* @param count the number of cards to add
|
||||||
*/
|
*/
|
||||||
private void addBonusCards(PowerCard card, int count) {
|
private void addBonusCards(PowerCard card, int count) {
|
||||||
drawPile.addAll(Collections.nCopies(count, card));
|
Class<? extends PowerCard> cardClass = card.getClass();
|
||||||
|
try {
|
||||||
|
// Get the constructor for the PowerCard class
|
||||||
|
Constructor<? extends PowerCard> constructor = cardClass.getDeclaredConstructor();
|
||||||
|
constructor.setAccessible(true); // Necessary if the constructor is not public
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
// Create a new instance of the PowerCard
|
||||||
|
PowerCard newCard = constructor.newInstance();
|
||||||
|
this.drawPile.add(newCard);
|
||||||
|
}
|
||||||
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||||
|
e.printStackTrace(); // Log any issues with reflection
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ public void testDeselectTSK() {
|
|||||||
serverGameLogic.setCurrentState(lobbyState);
|
serverGameLogic.setCurrentState(lobbyState);
|
||||||
assertEquals(lobbyState, serverGameLogic.getCurrentState());
|
assertEquals(lobbyState, serverGameLogic.getCurrentState());
|
||||||
|
|
||||||
|
serverGameLogic.received(selectTSKMessage, IDClient);
|
||||||
assertEquals(Color.CYBER, serverGameLogic.getGame().getPlayerById(IDClient).getColor());
|
assertEquals(Color.CYBER, serverGameLogic.getGame().getPlayerById(IDClient).getColor());
|
||||||
serverGameLogic.received(deselectTSKMessage, IDClient);
|
serverGameLogic.received(deselectTSKMessage, IDClient);
|
||||||
assertEquals(Color.NONE, serverGameLogic.getGame().getPlayerById(IDClient).getColor());
|
assertEquals(Color.NONE, serverGameLogic.getGame().getPlayerById(IDClient).getColor());
|
||||||
@@ -189,7 +190,7 @@ public void testReady() {
|
|||||||
|
|
||||||
// Send a LobbyReadyMessage and validate the player is marked as ready
|
// Send a LobbyReadyMessage and validate the player is marked as ready
|
||||||
serverGameLogic.received(readyMessage, IDClient);
|
serverGameLogic.received(readyMessage, IDClient);
|
||||||
assertFalse(serverGameLogic.getGame().getPlayerById(IDClient).isReady());
|
assertTrue(serverGameLogic.getGame().getPlayerById(IDClient).isReady());
|
||||||
|
|
||||||
serverGameLogic.received(readyMessage, IDHost);
|
serverGameLogic.received(readyMessage, IDHost);
|
||||||
assertTrue(serverGameLogic.getGame().getPlayerById(IDHost).isReady());
|
assertTrue(serverGameLogic.getGame().getPlayerById(IDHost).isReady());
|
||||||
|
|||||||
@@ -684,6 +684,8 @@ public void testReachBonusField() {
|
|||||||
|
|
||||||
//gets the top bonusCard
|
//gets the top bonusCard
|
||||||
PowerCard card = game.getDrawPile().get(0);
|
PowerCard card = game.getDrawPile().get(0);
|
||||||
|
System.out.println(card);
|
||||||
|
System.out.println(game.getDrawPile().get(1));
|
||||||
|
|
||||||
//sets the dice-seed to 4
|
//sets the dice-seed to 4
|
||||||
game.setDie(die4);
|
game.setDie(die4);
|
||||||
@@ -700,8 +702,8 @@ public void testReachBonusField() {
|
|||||||
assertEquals(game.getBoard().getInfield()[4].getOccupant(),pieceHost3);
|
assertEquals(game.getBoard().getInfield()[4].getOccupant(),pieceHost3);
|
||||||
|
|
||||||
//tests if the player has received a bonusCard
|
//tests if the player has received a bonusCard
|
||||||
assertNotEquals(card, game.getDrawPile().get(0));
|
|
||||||
assertTrue(game.getPlayers().get(IDHost).getHandCards().stream().toList().contains(card));
|
assertTrue(game.getPlayers().get(IDHost).getHandCards().stream().toList().contains(card));
|
||||||
|
assertNotEquals(card, game.getDrawPile().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
12
README.md
Normal file
12
README.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
“Mensch ärgere dich nicht” ist ein klassisches Brettspiel, dessen Ziel es ist, als
|
||||||
|
erster alle seine eigenen Figuren vom Wartebereich ins Haus zu bringen. Die
|
||||||
|
Spieler bewegen ihre Figuren entsprechend dem Würfelergebnis und
|
||||||
|
versuchen, gegnerische Figuren zu schlagen, um deren Fortschritt zu
|
||||||
|
verzögern.
|
||||||
|
Dieses Spiel “Man don’t get angry” (kurz: MDGA) ist eine Abwandlung von
|
||||||
|
dem klassischen “Mensch ärgere dich nicht” mit abgewandelten Regeln und
|
||||||
|
zusätzlichen Features.
|
||||||
|
In dieser Version gibt es ein besonderes Feature: Bonuskarten. Auf
|
||||||
|
bestimmten Feldern können die Spieler Bonuskarten ziehen, die ihnen
|
||||||
|
besondere Vorteile im Spiel verschaffen. Diese Bonuskarten können nur vor
|
||||||
|
dem Wurf des Würfels eingesetzt werden.
|
||||||
Reference in New Issue
Block a user