112 Commits

Author SHA1 Message Date
Felix Koppe
e337b1f888 Fix card select issue 2024-12-06 09:57:28 +01:00
Felix Koppe
0237bcc4be Fix card select issue 2024-12-06 09:51:17 +01:00
Felix Koppe
26836d16cc Fix card select issue 2024-12-06 09:48:24 +01:00
Felix Koppe
a6c8cc33f4 Make cardSelect trigger needCconfirm 2024-12-06 09:31:02 +01:00
Felix Koppe
7f5f4b8c68 Fix broken sound 2024-12-06 09:24:49 +01:00
Felix Koppe
7f3483aa6b Add broken sound 2024-12-06 09:22:10 +01:00
Felix Koppe
8422b7be1e Merge branch 'development' into dev/client_koppe2 2024-12-06 09:11:09 +01:00
Felix Koppe
f0b23ab9c2 Readd broken files 2024-12-06 09:10:47 +01:00
Felix Koppe
78f1dbb3d3 Remove broken files 2024-12-06 09:08:52 +01:00
Felix Koppe
9e758e4417 Merge branch 'dev/model' into dev/client_koppe2 2024-12-06 08:11:37 +01:00
Daniel Grigencha
62ceff822f Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by adding logic for the roll again event to the 'RequestDieMessage' handling.
2024-12-06 04:54:14 +01:00
Hanno Fleischer
33afc4ab3b added selectDice method in RollDiceState 2024-12-06 04:48:05 +01:00
Daniel Grigencha
322d539cfd Merge branch 'dev/model' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into dev/model 2024-12-06 04:28:40 +01:00
Daniel Grigencha
9c4f2387ee Updated 'FirstRollState', 'SecondRollState' and 'ThirdROllState' classes.
Updated the 'FirstRollState', 'SecondRollState' and 'ThirdROllState' class by adding the 'received(RequestDieMessage msg, int from)' method to them.
2024-12-06 04:28:33 +01:00
Daniel Grigencha
9d1430e488 Updated 'AnimationState' class.
Updated the 'AnimationState' class by setting the data type of 'messageReceived' from 'Map' to 'Set'.
2024-12-06 04:27:10 +01:00
Daniel Grigencha
dd2146d417 Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by setting the data type of 'messageReceived' from 'Map' to 'Set'.
2024-12-06 04:26:38 +01:00
Daniel Grigencha
d9ad0f0a4b Updated 'LobbyState' class.
Updated the 'LobbyState' class by setting the first waiting piece on the start node.
2024-12-06 04:25:45 +01:00
Hanno Fleischer
0368ec8541 implemented the correct transition, when the player can play no powercard 2024-12-06 04:18:58 +01:00
Daniel Grigencha
72f0bc5a2f Updated 'RollDiceState' class.
Updated the 'RollDiceState' class by adding the 'received(RequestDieMessage msg, int from)' method to it.
2024-12-06 04:17:29 +01:00
Daniel Grigencha
23ae4a3080 Updated 'DetermineStartPlayaerState' class.
Updated the 'DetermineStartPlayerState' class by calling the right method of the 'entry' inside the 'RequestDieMessage' handling.
2024-12-06 04:14:42 +01:00
Daniel Grigencha
765b1884fe Updated 'AnimationState' class.
Updated the 'AnimationState' class by removing the unused 'DiceNowMessage' call from it.
2024-12-06 03:57:42 +01:00
Daniel Grigencha
e3febd6ba1 Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by removing the 'rolls' attribute and its usage from it.
2024-12-06 03:49:39 +01:00
Daniel Grigencha
1a562a8d38 Updated 'DeterminStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by adding the multi roll support to it. In Addition, the server model will be updated correctly.
2024-12-06 03:29:11 +01:00
Daniel Grigencha
39ed4238b5 Updated 'AnimationState' class.
Updated the 'AnimationState' class by adding a missing semicolon.
2024-12-06 03:27:55 +01:00
Daniel Grigencha
620063e894 Updated 'AnimationState' class.
Updated the 'AnimationState' class by updating the 'messageReceived' attribute in it. In Addition, the 'AnimationEndMessage' handling was updated.
2024-12-06 03:22:25 +01:00
Daniel Grigencha
2d0788eb72 Updated 'TurnState' class.
Updated the 'TurnState' class by updating the imports in it.
2024-12-06 03:20:28 +01:00
Daniel Grigencha
8470a96908 Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by updating the 'AnimationEndMessage' handling in it. In Addition, the 'RequestDieMessage' handling was updated as well.
2024-12-06 02:55:14 +01:00
Hanno Fleischer
a6205c982a now sending AnimationEndMessage when in Waitranking State 2024-12-06 02:40:16 +01:00
Daniel Grigencha
58b9298c91 Merge branch 'dev/model' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into dev/model 2024-12-06 02:38:53 +01:00
Daniel Grigencha
1e6856744b Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by adding the 'received(AnimationEndMessage msg, int from)' method to it.
2024-12-06 02:38:46 +01:00
Hanno Fleischer
f713e00c36 made all 'PowerCards' serializable 2024-12-06 02:30:13 +01:00
Daniel Grigencha
81ae896ae8 Updated 'TurnState' class.
Updated the 'TurnState' class by removing the start state of this state machine of the constructor.
2024-12-06 02:22:46 +01:00
Daniel Grigencha
5b55d39c9a Updated 'AnimationState' class.
Updated the 'AnimationState' class by solving the transition error due to the separat state change.
2024-12-06 02:22:07 +01:00
Hanno Fleischer
f36e2ff7bb adjusted the getter for the card in the intro to get BonusCards instead of PowerCards 2024-12-06 02:16:58 +01:00
Hanno Fleischer
16afe95aa6 Merge branch 'dev/model' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into dev/model 2024-12-06 02:13:08 +01:00
Hanno Fleischer
55d398b428 adjusted all useages of the SelectedPieces consturctor to transfer the right parameters 2024-12-06 02:12:59 +01:00
Daniel Grigencha
affa2ecd7e Added 'ChoosePowerCardState', 'ShieldCardState', 'SwapCardState' and 'TurboCardState' classes.
Updated the 'ChoosePowerCardState', 'ShieldCardState', 'SwapCardState' and 'TurboCardState' classes to this project. They will be used inside the power card state. In Addition, the abstract 'PowerCardAutomatonState' class was added.
2024-12-06 02:11:32 +01:00
Hanno Fleischer
0a1bd1f503 adjusted all State containing 'received(PlayCardMessage msg)' to work with the new message 2024-12-06 02:04:55 +01:00
Daniel Grigencha
a2867fc88a Added 'ServerCardVisitor' class.
Added the 'ServerCardVisitor' class to this project. It will be used as a visitor on the server to differentiate between all types of power cards.
2024-12-06 01:41:45 +01:00
Daniel Grigencha
c6761d91d1 Updated 'PowerCardState' class.
Updated the 'PowerCardState' class by updating the content of the 'enter' in it.
2024-12-06 01:37:24 +01:00
Daniel Grigencha
5708ee6ffe Updated 'PlayCardMessage' class.
Updated the 'PlayCardMessage' class by removing the 'ownPieceID' and 'enemyPieceID' attributes and their getter methods from it. In Addition, the 'pieces' attribute and its getter method was added.
2024-12-06 01:28:44 +01:00
Hanno Fleischer
d61b68aa41 overrode hachCode and equals method of Piece 2024-12-06 01:15:06 +01:00
Daniel Grigencha
e98418b274 Merge branch 'dev/model' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into dev/model 2024-12-06 01:06:20 +01:00
Daniel Grigencha
66dc9c02ea Updated 'PowerCardState' class.
Updated the 'PowerCardState' class by adding the 'currentState', 'choosePowerCardState', 'shieldCardState', 'swapCardState' and 'turboCardState' attributes and its getter methods to it. In Addition, logic was written into the 'enter' method.
2024-12-06 00:53:11 +01:00
Daniel Grigencha
dd95356abd Updated 'TurnState' class.
Updated the 'TurnState' class by adding the 'player' attribute and its getter method to it.
2024-12-06 00:50:48 +01:00
Daniel Grigencha
84776c71b2 Updated 'SelectedPiecesMessage' class.
Updated the 'SelectedPiecesMessage' class by removing 'pieceIdentifier' attribute and its getter method from it. In Addition, the 'pieces' attribute and its getter method was added.
2024-12-06 00:47:33 +01:00
Daniel Grigencha
d07eee6251 Updated 'Piece' class.
Updated the 'Piece' class by overwriting the 'toString' method in it.
2024-12-06 00:45:56 +01:00
Hanno Fleischer
b601ff2cf7 renamed 'PossibleCardMEssage' to 'PossibleCardsMessage' and completed JavaDocs for method 'getPowerCardByType' in 'Player' 2024-12-06 00:36:06 +01:00
Hanno Fleischer
04119d2f3e modified 'ChoosePowerCardState' to work with PowerCards as well as adjusted 'SelectcardMessage' to use 'PowerCards' 2024-12-06 00:31:12 +01:00
Hanno Fleischer
a92c06a70e added a method in 'Player' to return the first 'PowerCard' of a specific Type 2024-12-06 00:30:08 +01:00
Daniel Grigencha
50f9c0ef0c Updated 'PossibleCardMessage' class.
Updated the 'PossibleCardMessage' class by replacing all 'BonusCard' with 'PowerCard' in it.
2024-12-06 00:19:11 +01:00
Daniel Grigencha
f7f246daaa Merge branch 'dev/model' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into dev/model 2024-12-06 00:16:42 +01:00
Daniel Grigencha
8a738a3633 Updated 'Game' class.
Updated the 'Game' class by replacing all 'BonusCard' with 'PowerCard' in it.
2024-12-06 00:16:38 +01:00
Daniel Grigencha
3a32a7ebf7 Updated 'Player' class.
Updated the 'Player' class by replacing all 'BonusCard' with 'PowerCard' in it.
2024-12-06 00:11:50 +01:00
Daniel Grigencha
6894802c00 Added 'HiddenCard', 'ShieldCard', 'SwapCard' and 'TurboCard' classes.
Updated the 'HiddenCard', 'ShieldCard', 'SwapCard' and 'TurboCard' classes to this project. They will be used to display different types of power cards.
2024-12-06 00:04:21 +01:00
Daniel Grigencha
a09211da5f Updated abstract 'PowerCard' class.
Updated the abstract 'PowerCard' class by setting the 'card' attribute to 'protected' in it.
2024-12-06 00:03:16 +01:00
Daniel Grigencha
c9c9c5dcf6 Added abstract 'PowerCard' class.
Added the abstract 'PowerCard' class to this project. It will be used to display different types of hand cards.
2024-12-05 23:58:43 +01:00
Daniel Grigencha
1e46b1dc59 Added 'Visitor' interface.
Added the 'Visitor' interface to this project. It will be used to handle all types of power cards.
2024-12-05 23:54:55 +01:00
Hanno Fleischer
6c74acc334 added a getter for the BonusCrad in PowerCard 2024-12-05 23:07:22 +01:00
Hanno Fleischer
421231aa12 made BonusCard Serializable and added the method calls to display handcards during the intro 2024-12-05 22:46:48 +01:00
Daniel Grigencha
d8bb458e9c Updated 'LobbyState' class.
Updated the 'LobbyState' class by updating the 'initializeGame' method in it.
2024-12-05 23:45:24 +01:00
Hanno Fleischer
f0080118d0 Changed and :
removed the selectAnimationEnd Method from Waitranking and moved logic into the receivedActivePlayerMessage. Added in selectStart to always send a StartGameMessage in order to trigger incorrectRequestMEssage
2024-12-05 22:34:53 +01:00
Daniel Grigencha
8a438ab069 Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by updating the whole start player determination process in it.
2024-12-05 23:29:21 +01:00
Daniel Grigencha
0ce8184069 Updated 'Game' class.
Updated the 'Game' class by adding the 'draw' method to it. In Addition, the 'initializeDrawPile' method was updated by shuffling the 'drawPile' attribute after filling it.
2024-12-05 23:27:06 +01:00
Felix Koppe
2c524477d7 Merge branch 'dev/model' into dev/client_koppe2 2024-12-05 22:18:00 +01:00
Felix Koppe
587af466e8 Merge branch 'development' into dev/client_koppe2
# Conflicts:
#	Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java
2024-12-05 22:17:53 +01:00
Felix Koppe
8d398450f1 Minor changes 2024-12-05 22:15:59 +01:00
Felix Koppe
0a96dd6f9f Repair sounds 2024-12-05 22:07:36 +01:00
Felix Koppe
e8a556de27 Add missle 2024-12-05 22:02:02 +01:00
Hanno Fleischer
1214d3c87c added an getter for the error id in the IncorrectrequestMessage and implemeted how to handle it in the client game logic. 2024-12-05 21:11:40 +01:00
Daniel Grigencha
f2c34aee2d Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by updating the 'received(RequestDieMessage msg, int from)' method in it.
2024-12-05 22:03:48 +01:00
Daniel Grigencha
2da1fec7dd Updated 'RankingResponseMessage' class.
Updated the 'RankingResponseMessage' class by removing the 'startingPlayerId' attribute and its getter method from it. In Addition the 'rankingResults' attribute and its getter method were added.
2024-12-05 22:01:05 +01:00
Daniel Grigencha
5d76a89b95 Updated 'LobbyState' class.
Updated the 'LobbyState' class by updating the 'JoinedLobbyMessage' and 'LobbyReadyMessage' handlings in it.
2024-12-05 21:58:20 +01:00
Daniel Grigencha
60ebef3518 Updated 'LobbyState' class.
Updated the 'LobbyState' class by adding an 'IncorrectRequestMessage' to the start game handling.
2024-12-05 19:58:23 +01:00
Felix Koppe
a399b14291 Improve interrupt 2024-12-05 18:11:57 +01:00
Felix Koppe
9d21e2ce87 Merge commit 2024-12-05 18:00:27 +01:00
Felix Koppe
2255bfd648 Remove test binding 2024-12-05 18:00:04 +01:00
Hanno Fleischer
74194d8514 Merge branch 'development' into 'dev/model'
Development

See merge request progproj/gruppen-ht24/Gruppe-01!34
2024-12-05 16:58:50 +00:00
Fleischer Hanno
cabd98a24a adjusted a broadcast in lobby state to a send to reduce traffic (original commit f1124f32) and removed souts as well as added comments back into the code 2024-12-05 17:51:18 +01:00
Felix Koppe
f1124f3245 Fix missing ready update from server on join of new player in LobbyState 2024-12-05 16:38:09 +01:00
Felix Koppe
fc4a357e9e Merge branch 'dev/model' into dev/client_koppe2 2024-12-05 16:25:23 +01:00
Felix Koppe
a8b02faa96 Merge branch 'development' into dev/client_koppe2
# Conflicts:
#	Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java
2024-12-05 16:25:11 +01:00
Hanno Fleischer
4478291852 added the movement of pieces in the intro state to be also done in the model 2024-12-05 15:22:38 +01:00
Hanno Fleischer
0622c35303 fixed state transitions and implemented the Intro state to move the pieces to the correct start setup
added some logic so that the client only transitions to the intro state when the animation has finished at it received the new active Player, and after animating the setup it switches to the corresponding state baserd on  the active player and displays the now new active player.
2024-12-05 14:02:02 +01:00
Daniel Grigencha
3b0cd9ebdb Updated the JavaDocs in multiple classes, to improve readability. 2024-12-05 05:21:33 +01:00
Daniel Grigencha
e81aa67d36 Updated the JavaDocs in multiple classes, to improve readability. 2024-12-05 05:09:15 +01:00
Daniel Grigencha
4fb848420b Updated the 'DisconnectedMessage' class.
Updated the 'DisconnectedMessage' class by adding JavaDocs.
2024-12-05 05:03:39 +01:00
Daniel Grigencha
07a833afe7 Updated the 'ClientInterpreter' interface.
Updated the 'ClientInterpreter' interface by adjusting the JavaDocs.
2024-12-05 05:00:29 +01:00
Daniel Grigencha
6576250113 Updated the 'Player' class.
Updated the 'Player' class by adjusting the JavaDocs and writing the logic for the 'isFinished()' method.
2024-12-05 04:54:12 +01:00
Daniel Grigencha
154efccf31 Updated 'Game' class.
Updated the 'Game' class by adjusting the JavaDocs and rewriting the constructor for maintainability and readability.
2024-12-05 04:52:59 +01:00
Daniel Grigencha
f90aed7bbb Updated 'Color' enum.
Updated the 'Color' enum by adjusting the JavaDocs and adding a new static method 'getColor(int)'
2024-12-05 04:51:55 +01:00
Daniel Grigencha
3a86837307 Updated the JavaDocs in multiple classes, to improve readability. 2024-12-05 04:50:34 +01:00
Daniel Grigencha
da0756452c Updated the JavaDocs in multiple classes, to improve readability. 2024-12-05 04:49:49 +01:00
Daniel Grigencha
bfe8a20f92 Updated 'Board' class.
Updated the 'Board' class by rewriting the constructor, to make it maintainable and scalable.
2024-12-05 04:46:01 +01:00
Hanno Fleischer
354cdc0a9c added Intro state and its logic 2024-12-04 17:03:57 +01:00
Felix Koppe
5c71531277 Merge branch 'development' into dev/client_koppe2 2024-12-04 13:43:33 +01:00
Hanno Fleischer
e8d1442e5b made the model checkstyle compliant 2024-12-04 12:10:48 +01:00
Hanno Fleischer
bdacc4aad3 created the Intro state and renamed all packages to be checkstyle compliant 2024-12-04 12:08:38 +01:00
Hanno Fleischer
8e8104b672 forgot to add StartGameMessage in previous commit 2024-12-04 11:10:26 +01:00
Hanno Fleischer
de899cef35 removed from every Message the getInfoTest method and only overrode the toString method in messages with content, in every other message it is handled through the parent class 2024-12-04 11:07:55 +01:00
Daniel Grigencha
29711d6210 Updated 'ClientStartGameMessage' class.
Updated the 'ClientStartGameMesssage' class by preparing it for the correct BPMN diagram.
2024-12-04 02:46:07 +01:00
Daniel Grigencha
29d8e791f6 Updated 'Player' class.
Updated the 'Player' class by adding the 'setPieceInHome' method to it.
2024-12-04 02:44:28 +01:00
Daniel Grigencha
4440341f79 Updated 'LobbyState' class.
Updated the 'LobbyState' class by updating the creation of the 'ServerStartGameMessage' object. In Addition, the start process if all players are ready was removed.
2024-12-04 02:44:03 +01:00
Daniel Grigencha
de5c8bf44c Updated 'Game' class.
Updated the 'Game' class by adding the 'getPlayersAsList' method to it.
2024-12-04 02:43:29 +01:00
Daniel Grigencha
ab5cece1b3 Updated 'StartGameMessage' class.
Updated the 'StartGameMessage' class by removing the unused 'forceStartGame' attribute from it.
2024-12-04 02:42:57 +01:00
Daniel Grigencha
b8ed5060d6 Updated 'Board' class.
Updated the 'Board' class by removing the 'playerData' attribute and its getter method from it.
2024-12-04 02:42:16 +01:00
Daniel Grigencha
c0b72ae4da Updated 'ServerStartGameMessage' class.
Updated the 'ServerStartGameMessage' class by adding the 'players' attribute and its getter method to it.
2024-12-04 02:41:44 +01:00
Daniel Grigencha
c1b4caa82b Updated 'LobbyState' class.
Updated the 'LobbyState' class by updating the 'received(ServerStartGameMessage msg)' method in it after updating the 'ServerStartGameMessage' class.
2024-12-04 02:22:58 +01:00
Daniel Grigencha
a757158477 Updated 'MdgaServer' class.
Updated the 'MdgaServer' class by removing the serializer registration in it.
2024-12-04 02:09:20 +01:00
Daniel Grigencha
964ff87b11 Updated client states.
Updated the client states by removing all references to the 'PlayerData' class.
2024-12-04 01:47:31 +01:00
Felix Koppe
82234a7ff9 Merge commit 2024-12-02 15:44:41 +01:00
Felix Koppe
5b8032bed9 Prepare for model 2024-12-01 17:44:37 +01:00
159 changed files with 8273 additions and 1479 deletions

View File

@@ -1,5 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
<option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
<module name="Projekte.mdga.client.main" />

View File

@@ -38,7 +38,8 @@ public enum Asset {
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
shieldCard,
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
dice
dice,
missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
;
private final String modelPath;

View File

@@ -149,16 +149,16 @@ else if(boardSelect != null) {
if (name.equals("Right")) {
isRotateRight = !isRotateRight;
}
if(name.equals("Test") &&isPressed){
if(name.equals("Test2") &&isPressed){
if(app.getView() instanceof GameView gameView){
if(p == null) {
p = UUID.randomUUID();
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
gameView.getBoardHandler().movePieceStartAnim(p,0);
gameView.getBoardHandler().movePieceAnim(p,0, 8);
//gameView.getBoardHandler().movePieceAnim(p,0, 8);
} else {
gameView.getBoardHandler().throwBombAnim(p);
gameView.getBoardHandler().throwMissileAnim(p);
//gameView.getBoardHandler().movePieceStartAnim(p,0);
}

View File

@@ -128,7 +128,7 @@ public void simpleInitApp() {
gameView = new GameView(this);
ceremonyView = new CeremonyView(this);
enter(MdgaState.GAME);
enter(MdgaState.MAIN);
}
/**

View File

@@ -74,10 +74,11 @@ public void selectCard(BonusCard card) {
this.card = card;
GameView gameView = (GameView) app.getView();
if(card != null) {
if(card == null) {
gameView.needConfirm();
} else {
gameView.noConfirm();
gameView.needNoPower();
}
}
@@ -93,14 +94,17 @@ public void confirm() {
} else if (a != null) {
selectPiece(a);
gameView.getBoardHandler().clearSelectable();
} else if (card != null){
selectCard(card);
gameView.getGuiHandler().clearSelectableCards();
} else {
throw new RuntimeException("nothing to confirm");
if(null == card) {
selectCard(null);
} else {
selectCard(card);
gameView.getGuiHandler().clearSelectableCards();
}
}
gameView.noConfirm();
gameView.noNoPower();
}
public void selectTsk(Color color) {

View File

@@ -1,5 +1,6 @@
package pp.mdga.client;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.gui.GuiHandler;
import pp.mdga.client.view.CeremonyView;
@@ -88,9 +89,11 @@ private void handleGame(Notification notification) {
if (notification instanceof AcquireCardNotification n) {
guiHandler.addCardOwn(n.getBonusCard());
app.getAcousticHandler().playSound(MdgaSound.BONUS);
} else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor());
boardHandler.showDice(n.getColor());
app.getAcousticHandler().playSound(MdgaSound.UI90);
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
app.enter(MdgaState.CEREMONY);
CeremonyView ceremonyView = (CeremonyView) app.getView();
@@ -125,8 +128,8 @@ private void handleGame(Notification notification) {
} else if (notification instanceof HomeMoveNotification home) {
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
guiHandler.hideText();
} else if (notification instanceof InterruptNotification) {
gameView.enterInterrupt();
} else if (notification instanceof InterruptNotification notification1) {
gameView.enterInterrupt(notification1.getColor());
} else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) {
//StartMove
@@ -161,6 +164,7 @@ private void handleGame(Notification notification) {
}
} else if (notification instanceof SelectableCardsNotification n) {
guiHandler.setSelectableCards(n.getCards());
gameView.needNoPower();
} else if (notification instanceof ShieldActiveNotification n) {
boardHandler.shieldPiece(n.getPieceId());
} else if (notification instanceof ShieldSuppressedNotification n) {

View File

@@ -113,9 +113,9 @@ public void playSound(MdgaSound sound) {
assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
break;
case EXPLOSION:
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 4f));
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 4f));
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 4f));
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 0f));
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 0f));
break;
case LOSE:
assets.add(new SoundAssetDelayVolume(SoundAsset.LOSE, 1.0f, 0.0f));
@@ -123,6 +123,15 @@ public void playSound(MdgaSound sound) {
case BONUS:
assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
break;
case UI90:
assets.add(new SoundAssetDelayVolume(SoundAsset.UI90, 1.0f, 0.0f));
break;
case MISSILE:
assets.add(new SoundAssetDelayVolume(SoundAsset.MISSILE, 1.0f, 0.0f));
break;
case MATRIX:
assets.add(new SoundAssetDelayVolume(SoundAsset.MATRIX, 1.0f, 0.0f));
break;
default:
break;
}

View File

@@ -35,4 +35,7 @@ public enum MdgaSound {
EXPLOSION,
LOSE,
BONUS,
UI90,
MISSILE,
MATRIX,
}

View File

@@ -35,6 +35,8 @@ enum SoundAsset {
UI90("ui90.ogg"),
BONUS("bonus.ogg"),
LOSE("lose.ogg"),
MISSILE("missile.ogg"),
MATRIX("matrix.wav"),
CONNECTED("connected.wav");
private final String path;

View File

@@ -8,6 +8,7 @@
import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
public class Explosion {
@@ -34,8 +35,6 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
this.location = location;
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
mat.getAdditionalRenderState().setDepthWrite(false);
mat.getAdditionalRenderState().setDepthTest(false);
}
/**
@@ -56,7 +55,6 @@ private void initializeEmitter() {
fire.setParticlesPerSec(0);
fire.setLocalTranslation(location);
fire.move(0, 0, 45);
smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
smoke.setMaterial(mat);
@@ -74,7 +72,8 @@ private void initializeEmitter() {
smoke.setParticlesPerSec(0);
smoke.setLocalTranslation(location);
smoke.move(0, 0, 45);
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
}
/**

View File

@@ -57,7 +57,7 @@ public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint,
id = uuid;
explosion = new Explosion(app, rootNode, nodePoint);
explosion = new Explosion(app, rootNode, targetPoint);
}
/**
@@ -83,8 +83,6 @@ private void spawnJet() {
jetModel.setMaterial(mat);
rootNode.attachChild(jetModel);
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
}
/**

View File

@@ -0,0 +1,138 @@
package pp.mdga.client.animation;
import com.jme3.material.Material;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import java.util.UUID;
public class MissileAnimation {
private final Node rootNode; // Root-Knoten, an den die Animation gehängt wird
private final MdgaApp app; // Referenz auf die Hauptanwendung
private final Vector3f start; // Startpunkt der Rakete
private final Vector3f target; // Zielpunkt der Rakete
private final float flightTime; // Gesamtdauer des Flugs
private Explosion explosion;
private Spatial missileModel; // 3D-Modell der Rakete
private UUID id;
/**
* Konstruktor für die MissileAnimation.
*
* @param app Die Hauptanwendung.
* @param rootNode Der Root-Knoten, an den die Animation gehängt wird.
* @param target Der Zielpunkt der Rakete.
* @param flightTime Die Zeit, die die Rakete für den gesamten Flug benötigt.
*/
public MissileAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f target, float flightTime) {
this.app = app;
this.rootNode = rootNode;
this.flightTime = flightTime;
explosion = new Explosion(app, rootNode, target);
id = uuid;
this.target = target.add(new Vector3f(1.5f, -1, 0));
start = BoardHandler.gridToWorld(12, 0);
start.add(new Vector3f(0, 0, 0));
}
/**
* Startet die Raketenanimation.
*/
public void start() {
loadMissile();
app.getAcousticHandler().playSound(MdgaSound.MISSILE);
animateMissile();
}
/**
* Lädt das Raketenmodell und setzt es auf den Startpunkt.
*/
private void loadMissile() {
missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath()); // Lade das Missile-Modell
missileModel.scale(Asset.missile.getSize());
missileModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.missile.getDiffPath()));
missileModel.setMaterial(mat);
missileModel.setLocalTranslation(start); // Setze Startposition
rootNode.attachChild(missileModel); // Füge das Modell zur Szene hinzu
}
/**
* Animiert die Rakete entlang einer Parabel.
*/
private void animateMissile() {
missileModel.addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
float progress = elapsedTime / flightTime;
if (progress >= 0.95f) {
explosion.trigger();
}
if (progress >= 1) {
explosion.trigger();
// Flug abgeschlossen
rootNode.detachChild(missileModel); // Entferne Rakete nach dem Ziel
this.spatial.removeControl(this); // Entferne die Steuerung
return;
}
// Berechne die aktuelle Position entlang der Parabel
Vector3f currentPosition = computeParabolicPath(start, target, progress);
missileModel.setLocalTranslation(currentPosition);
// Passe die Ausrichtung an (Nase der Rakete zeigt in Flugrichtung)
Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
.subtract(currentPosition)
.normalizeLocal();
missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y); // Z ist oben, Y ist "Up"
missileModel.rotate(0, FastMath.HALF_PI, 0);
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// Keine Render-Logik benötigt
}
});
}
/**
* Berechnet eine Parabelbewegung von `start` zu `target`.
*
* @param start Der Startpunkt der Rakete.
* @param target Der Zielpunkt der Rakete.
* @param t Der Fortschritt des Flugs (0 bis 1).
* @return Die Position der Rakete entlang der Parabel.
*/
private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {
Vector3f midPoint = start.add(target).multLocal(0.5f); // Berechne die Mitte zwischen Start und Ziel
midPoint.addLocal(0, 0, 20); // Erhöhe den Scheitelpunkt der Parabel entlang der Z-Achse
// Quadratische Interpolation (Parabel)
Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
return FastMath.interpolateLinear(t, startToMid, midToTarget);
}
}

View File

@@ -10,6 +10,7 @@
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.animation.MissileAnimation;
import pp.mdga.client.animation.MoveControl;
import pp.mdga.client.animation.JetAnimation;
import pp.mdga.client.gui.DiceControl;
@@ -201,7 +202,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
* @param y The y-coordinate on the grid
* @return The corresponding world position
*/
private static Vector3f gridToWorld(int x, int y) {
public static Vector3f gridToWorld(int x, int y) {
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
}
@@ -727,7 +728,7 @@ public void throwPieceAnim(UUID uuid){
}
/**
* Animates the throwing of a piece to the next available waiting node.
* Animates the throwing of a piece to the next available waiting node and plays jet animation.
*
* @param uuid the UUID of the piece to animate
*/
@@ -738,6 +739,18 @@ public void throwBombAnim(UUID uuid){
anim.start();
}
/**
* Animates the throwing of a piece to the next available waiting node and plays ship animation.
*
* @param uuid the UUID of the piece to animate
*/
public void throwMissileAnim(UUID uuid){
Vector3f targetPoint = pieces.get(uuid).getLocation();
MissileAnimation anim = new MissileAnimation(app, rootNode, uuid, targetPoint, 2);
anim.start();
}
/**
* Animates the swapping of two pieces by swapping their positions and rotations.
*

View File

@@ -8,18 +8,21 @@
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView;
import pp.mdga.game.Color;
public class InterruptDialog extends Dialog {
private ButtonRight forceButton;
private LabelButton label;
private String text = "";
public InterruptDialog(MdgaApp app, Node node) {
super(app, node);
forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
label = new LabelButton(app, node, "Warte auf Spieler...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
label = new LabelButton(app, node, "Warte auf " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
float offset = 2.8f;
@@ -40,4 +43,21 @@ protected void onHide() {
forceButton.hide();
label.hide();
}
public void setColor(Color color) {
switch (color) {
case AIRFORCE:
text = "Luftwaffe";
break;
case ARMY:
text = "Heer";
break;
case NAVY:
text = "Marine";
break;
case CYBER:
text = "CIR";
break;
}
}
}

View File

@@ -131,6 +131,8 @@ public void selectCard(CardControl cardControl) {
cardControl.select();
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
}
app.getModelSynchronize().selectCard(cardSelect);
}
public Camera getCardLayerCamera() {

View File

@@ -5,6 +5,7 @@
import com.jme3.network.serializing.serializers.EnumSerializer;
import pp.mdga.Resources;
import pp.mdga.game.*;
import pp.mdga.game.card.*;
import pp.mdga.message.client.*;
import pp.mdga.message.server.*;
import pp.mdga.server.ServerGameLogic;
@@ -124,7 +125,7 @@ private void initializeSerializables() {
Serializer.registerClass(NoTurnMessage.class);
Serializer.registerClass(PauseGameMessage.class);
Serializer.registerClass(PlayCardMessage.class);
Serializer.registerClass(PossibleCardMessage.class);
Serializer.registerClass(PossibleCardsMessage.class);
Serializer.registerClass(PossiblePieceMessage.class);
Serializer.registerClass(RankingResponseMessage.class);
Serializer.registerClass(RankingRollAgainMessage.class);
@@ -144,12 +145,17 @@ private void initializeSerializables() {
Serializer.registerClass(Piece.class);
Serializer.registerClass(BonusNode.class);
Serializer.registerClass(StartNode.class);
Serializer.registerClass(PlayerData.class);
Serializer.registerClass(HomeNode.class);
Serializer.registerClass(PowerCard.class);
Serializer.registerClass(TurboCard.class);
Serializer.registerClass(SwapCard.class);
Serializer.registerClass(ShieldCard.class);
Serializer.registerClass(HiddenCard.class);
Serializer.registerClass(Color.class, new EnumSerializer());
Serializer.registerClass(PieceState.class, new EnumSerializer());
Serializer.registerClass(ShieldState.class, new EnumSerializer());
Serializer.registerClass(BonusCard.class, new EnumSerializer());
}
private void registerListeners() {

View File

@@ -20,6 +20,8 @@ public class GameView extends MdgaView {
private ButtonLeft leaveButton;
private ButtonRight confirmButton;
private ButtonRight noPowerButton;
private Color ownColor = null;
private InterruptDialog interruptDialog;
@@ -31,10 +33,13 @@ public class GameView extends MdgaView {
public GameView(MdgaApp app) {
super(app);
setOwnColor(Color.AIRFORCE);
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
noPowerButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Verzichten", 1);
interruptDialog = new InterruptDialog(app, guiNode);
fpp = new FilterPostProcessor(app.getAssetManager());
@@ -65,6 +70,7 @@ public void onLeave() {
confirmButton.hide();
noPowerButton.hide();
app.getViewPort().removeProcessor(fpp);
}
@@ -109,6 +115,7 @@ public Color getOwnColor() {
}
public void needConfirm() {
noPowerButton.hide();
confirmButton.show();
}
@@ -116,7 +123,16 @@ public void noConfirm() {
confirmButton.hide();
}
public void enterInterrupt() {
public void needNoPower() {
confirmButton.hide();
noPowerButton.show();
}
public void noNoPower() {
noPowerButton.show();
}
public void enterInterrupt(Color color) {
enterOverlay(Overlay.INTERRUPT);
guiNode.detachChild(guiHandlerNode);
@@ -124,6 +140,7 @@ public void enterInterrupt() {
app.getInputSynchronize().setClickAllowed(false);
interruptDialog.setColor(color);
interruptDialog.show();
}
@@ -135,6 +152,8 @@ public void leaveInterrupt() {
app.getInputSynchronize().setClickAllowed(true);
app.getAcousticHandler().playSound(MdgaSound.START);
interruptDialog.hide();
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
# Blender MTL File: 'untitled.blend'
# Material Count: 3
newmtl Material.001
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd untiffftled.jpg
newmtl Material.002
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd untiffftled.jpg
newmtl Material.004
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd untiffftled.jpg

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -1,9 +1,8 @@
package pp.mdga.client;
import pp.mdga.client.ceremonyState.CeremonyStates;
import pp.mdga.client.ceremonyState.PodiumState;
import pp.mdga.client.ceremonyState.StatisticsState;
import pp.mdga.notification.CeremonyNotification;
import pp.mdga.client.ceremonystate.CeremonyStates;
import pp.mdga.client.ceremonystate.PodiumState;
import pp.mdga.client.ceremonystate.StatisticsState;
public class CeremonyState extends ClientState {

View File

@@ -5,13 +5,13 @@
import pp.mdga.game.Color;
import pp.mdga.game.Game;
import pp.mdga.game.Piece;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.ClientMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.*;
import pp.mdga.notification.InfoNotification;
import pp.mdga.notification.Notification;
import pp.mdga.notification.StartDialogNotification;
import java.util.ArrayList;
import java.util.Map;
import java.util.UUID;
/**
@@ -52,20 +52,21 @@ public ClientGameLogic(ClientSender clientSender) {
*
* @param msg the message to be sent
*/
public void send(ClientMessage msg){
public void send(ClientMessage msg) {
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
clientSender.send(msg);
}
/**
* This method is used to get a piece by its id
*
* @param pieceId the UUID of the piece
* @return the piece
*/
private Piece getPiece(UUID pieceId){
for(Map.Entry<Color, PlayerData> entry : game.getBoard().getPlayerData().entrySet()){
for(Piece piece : entry.getValue().getPieces()){
if(piece.getUuid().equals(pieceId)){
private Piece getPiece(UUID pieceId) {
for (var player : this.game.getPlayers().values()) {
for (Piece piece : player.getPieces()) {
if (piece.getUuid().equals(pieceId)) {
return piece;
}
}
@@ -78,7 +79,7 @@ private Piece getPiece(UUID pieceId){
*
* @return the clientSender
*/
public ClientSender getClientSender(){
public ClientSender getClientSender() {
return clientSender;
}
@@ -123,7 +124,7 @@ public void setOwnPlayerId(int ownPlayerId) {
*
* @return the game
*/
public Game getGame(){
public Game getGame() {
return game;
}
@@ -132,7 +133,7 @@ public Game getGame(){
*
* @return the current State
*/
public ClientState getState(){
public ClientState getState() {
return state;
}
@@ -141,7 +142,7 @@ public ClientState getState(){
*
* @return if the client is a host
*/
public boolean isHost(){
public boolean isHost() {
return isHost;
}
@@ -150,8 +151,8 @@ public boolean isHost(){
*
* @return the calculated moves as int
*/
public int getCalculatedMoves(){
return game.getDiceEyes() * game.getDiceModifier();
public int getCalculatedMoves() {
return 0;
}
/**
@@ -159,7 +160,7 @@ public int getCalculatedMoves(){
*
* @param isHost the boolean value
*/
public void setHost(boolean isHost){
public void setHost(boolean isHost) {
this.isHost = isHost;
}
@@ -329,7 +330,7 @@ public void received(PlayCardMessage msg) {
* @param msg the PossibleCard message received
*/
@Override
public void received(PossibleCardMessage msg) {
public void received(PossibleCardsMessage msg) {
state.received(msg);
}
@@ -412,7 +413,7 @@ public void received(ShutdownMessage msg) {
*/
@Override
public void received(IncorrectRequestMessage msg) {
state.received(msg);
addNotification(new InfoNotification(Resources.stringLookup("incorrect.request." + msg.getId())));
}
/**
@@ -480,14 +481,14 @@ public void received(SelectPieceMessage msg) {
*
* @param pieceId the pieceID
*/
public void selectPiece(UUID pieceId){
public void selectPiece(UUID pieceId) {
state.selectPiece(getPiece(pieceId));
}
/**
* This method call the method selectNExt of the state
*/
public void selectNext(){
public void selectNext() {
state.selectNext();
}
@@ -496,7 +497,7 @@ public void selectNext(){
*
* @param card the BonusCard to selected
*/
public void selectCard(BonusCard card){
public void selectCard(BonusCard card) {
state.selectCard(card);
}
@@ -505,7 +506,7 @@ public void selectCard(BonusCard card){
*
* @param color the Color to be selected
*/
public void selectTsk(Color color){
public void selectTsk(Color color) {
state.selectTSK(color);
}
@@ -514,14 +515,14 @@ public void selectTsk(Color color){
*
* @param color the color to be deselcted
*/
public void deselectTSK(Color color){
public void deselectTSK(Color color) {
state.deselectTSK(color);
}
/**
* This method calls the selectDice method of the state
*/
public void selectDice(){
public void selectDice() {
state.selectDice();
}
@@ -530,7 +531,7 @@ public void selectDice(){
*
* @param name the name to be set
*/
public void selectName(String name){
public void selectName(String name) {
state.setName(name);
}
@@ -539,8 +540,8 @@ public void selectName(String name){
*
* @param ready the value if this method should ready or unready
*/
public void selectReady(boolean ready){
if(ready){
public void selectReady(boolean ready) {
if (ready) {
state.selectReady();
} else {
state.selectUnready();
@@ -552,14 +553,14 @@ public void selectReady(boolean ready){
*
* @param name the name of the player hosting
*/
public void selectHost(String name){
public void selectHost(String name) {
state.selectHost(name);
}
/**
* This method calls the selectLeave method of the state
*/
public void selectLeave(){
public void selectLeave() {
state.selectLeave();
}
@@ -568,28 +569,28 @@ public void selectLeave(){
*
* @param ip the ip to cennect to
*/
public void selectJoin(String ip){
public void selectJoin(String ip) {
state.selectJoin(ip);
}
/**
* This method calls the selectAnimationEnd method of the state
*/
public void selectAnimationEnd(){
public void selectAnimationEnd() {
state.selectAnimationEnd();
}
/**
* This method calls the selectStart method of the state
*/
public void selectStart(){
public void selectStart() {
state.selectStart();
}
/**
* This method calls the selectResume method of the state
*/
public void selectResume(){
public void selectResume() {
state.selectResume();
}
@@ -598,7 +599,7 @@ public void selectResume(){
*
* @param state the new state
*/
public void setState(ClientState state){
public void setState(ClientState state) {
this.state.exit();
state.enter();
this.state = state;
@@ -607,7 +608,7 @@ public void setState(ClientState state){
/**
* This method is used to enter the interrupt state and save the previous state
*/
public void enterInterrupt(){
public void enterInterrupt() {
interruptState.enter();
interruptState.setPreviousState(state);
this.state = interruptState;
@@ -618,7 +619,7 @@ public void enterInterrupt(){
*
* @return the GameState
*/
public GameState getGameState(){
public GameState getGameState() {
return gameState;
}
@@ -627,7 +628,7 @@ public GameState getGameState(){
*
* @return the CeremonyState
*/
public CeremonyState getCeremony(){
public CeremonyState getCeremony() {
return ceremonyState;
}
@@ -636,7 +637,7 @@ public CeremonyState getCeremony(){
*
* @return the InterruptState
*/
public InterruptState getInterrupt(){
public InterruptState getInterrupt() {
return interruptState;
}
@@ -645,7 +646,7 @@ public InterruptState getInterrupt(){
*
* @return the DialogsState
*/
public DialogsState getDialogs(){
public DialogsState getDialogs() {
return dialogsState;
}
@@ -654,7 +655,7 @@ public DialogsState getDialogs(){
*
* @return the SettingsState
*/
public SettingsState getSettings(){
public SettingsState getSettings() {
return settingsState;
}
@@ -663,8 +664,8 @@ public SettingsState getSettings(){
*
* @return the next notification
*/
public Notification getNotification(){
if(!notifications.isEmpty()){
public Notification getNotification() {
if (!notifications.isEmpty()) {
return notifications.remove(0);
} else {
return null;
@@ -676,7 +677,7 @@ public Notification getNotification(){
*
* @param notification the notification to be added
*/
public void addNotification(Notification notification){
public void addNotification(Notification notification) {
notifications.add(notification);
}

View File

@@ -116,7 +116,7 @@ public void received(PlayCardMessage msg) {
}
@Override
public void received(PossibleCardMessage msg) {
public void received(PossibleCardsMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}

View File

@@ -1,9 +1,9 @@
package pp.mdga.client;
import pp.mdga.client.dialogState.DialogStates;
import pp.mdga.client.dialogState.LobbyState;
import pp.mdga.client.dialogState.NetworkDialogState;
import pp.mdga.client.dialogState.StartDialogState;
import pp.mdga.client.dialogstate.DialogStates;
import pp.mdga.client.dialogstate.LobbyState;
import pp.mdga.client.dialogstate.NetworkDialogState;
import pp.mdga.client.dialogstate.StartDialogState;
import pp.mdga.game.Color;
import pp.mdga.message.server.*;

View File

@@ -1,6 +1,6 @@
package pp.mdga.client;
import pp.mdga.client.gameState.*;
import pp.mdga.client.gamestate.*;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.message.client.LeaveGameMessage;
@@ -241,7 +241,7 @@ public void received(DiceAgainMessage msg){
* @param msg the message to be received
*/
@Override
public void received(PossibleCardMessage msg){
public void received(PossibleCardsMessage msg){
state.received(msg);
}

View File

@@ -1,9 +1,9 @@
package pp.mdga.client;
import pp.mdga.client.settingsState.AudioSettingsState;
import pp.mdga.client.settingsState.MainSettingsState;
import pp.mdga.client.settingsState.SettingStates;
import pp.mdga.client.settingsState.VideoSettingsState;
import pp.mdga.client.settingsstate.AudioSettingsState;
import pp.mdga.client.settingsstate.MainSettingsState;
import pp.mdga.client.settingsstate.SettingStates;
import pp.mdga.client.settingsstate.VideoSettingsState;
public class SettingsState extends ClientState {

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonyState;
package pp.mdga.client.ceremonystate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonyState;
package pp.mdga.client.ceremonystate;
import pp.mdga.client.CeremonyState;
import pp.mdga.client.ClientGameLogic;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonyState;
package pp.mdga.client.ceremonystate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState;
package pp.mdga.client.dialogstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState;
package pp.mdga.client.dialogstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
@@ -6,16 +6,14 @@
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import pp.mdga.game.Player;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.*;
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
import pp.mdga.message.server.ServerStartGameMessage;
import pp.mdga.message.server.UpdateReadyMessage;
import pp.mdga.message.server.UpdateTSKMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.*;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class LobbyState extends DialogStates {
@@ -58,41 +56,47 @@ public void selectReady() {
}
@Override
public void selectUnready(){
public void selectUnready() {
logic.send(new LobbyNotReadyMessage());
}
@Override
public void selectStart(){
if(logic.isHost() && logic.getGame().areAllReady()){
logic.send(new StartGameMessage(false));
} else if(logic.isHost() && !logic.getGame().areAllReady()) {
logic.send(new StartGameMessage(true));
public void selectStart() {
if (logic.isHost() && logic.getGame().areAllReady()) {
logic.send(new StartGameMessage());
} else {
logic.send(new StartGameMessage());
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
}
}
@Override
public void received(ServerStartGameMessage msg){
public void received(ServerStartGameMessage msg) {
for (Player player: msg.getPlayers()) {
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
if (entry.getValue().getColor() == player.getColor()) {
this.logic.getGame().getPlayers().put(entry.getKey(), player);
}
}
}
logic.getGame().setBoard(msg.getBoard());
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) {
for (var player : logic.getGame().getPlayers().values()) {
List<UUID> pieces = new ArrayList<>();
for (Piece piece : logic.getGame().getBoard().getPlayerData().get(entry.getValue().getColor()).getPieces()) {
for (Piece piece : player.getPieces()) {
pieces.add(piece.getUuid());
}
logic.addNotification(new PlayerInGameNotification(entry.getValue().getColor(), pieces, entry.getValue().getName()));
logic.addNotification(new PlayerInGameNotification(player.getColor(), pieces, player.getName()));
}
logic.setState(logic.getGameState());
}
@Override
public void received(LobbyPlayerJoinedMessage msg){
if(msg.getPlayer().getName().equals(logic.getOwnPlayerName())){
public void received(LobbyPlayerJoinedMessage msg) {
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
logic.setOwnPlayerId(msg.getId());
}
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()){
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
logic.setHost(true);
}
@@ -101,9 +105,9 @@ public void received(LobbyPlayerJoinedMessage msg){
}
@Override
public void received(UpdateTSKMessage msg){
if(msg.isTaken()) {
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId()== msg.getId()));
public void received(UpdateTSKMessage msg) {
if (msg.isTaken()) {
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId() == msg.getId()));
} else {
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
}
@@ -112,13 +116,13 @@ public void received(UpdateTSKMessage msg){
}
@Override
public void received(LobbyPlayerLeaveMessage msg){
public void received(LobbyPlayerLeaveMessage msg) {
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
logic.getGame().getPlayers().remove(msg.getId());
}
@Override
public void received(UpdateReadyMessage msg){
public void received(UpdateReadyMessage msg) {
//TODO server sendet kein update on UNready
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState;
package pp.mdga.client.dialogstate;
import pp.mdga.Resources;
import pp.mdga.client.ClientGameLogic;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState;
package pp.mdga.client.dialogstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,40 +0,0 @@
package pp.mdga.client.gameState.determineStartPlayerState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.DetermineStartPlayerState;
import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage;
import pp.mdga.notification.ActivePlayerNotification;
public class WaitRankingState extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent;
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(RankingRollAgainMessage msg){
parent.setState(parent.getRollRankingDice());
}
@Override
public void received(RankingResponseMessage msg){
logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
parent.getParent().setState(parent.getParent().getWaiting());
}
}

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.gameState;
package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,11 +1,14 @@
package pp.mdga.client.gameState;
package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.ActivePlayerMessage;
import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage;
@@ -17,12 +20,33 @@ public class DetermineStartPlayerState extends GameStates {
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
private final Intro intro = new Intro(this, logic);
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (GameState) parent;
}
public RollRankingDiceState getRollRankingDice() {
return rollRankingDiceState;
}
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
public DetermineStartPlayerStates getState(){
return state;
}
public Intro getIntro(){
return intro;
}
public GameState getParent() {
return parent;
}
@Override
public void enter() {
this.setState(this.rollRankingDiceState);
@@ -46,6 +70,11 @@ public void selectDice() {
state.selectDice();
}
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
@Override
public void received(DieMessage msg){
state.received(msg);
@@ -61,19 +90,8 @@ public void received(RankingResponseMessage msg){
state.received(msg);
}
public RollRankingDiceState getRollRankingDice() {
return rollRankingDiceState;
}
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
public DetermineStartPlayerStates getState(){
return state;
}
public GameState getParent() {
return parent;
@Override
public void received(ActivePlayerMessage msg){
state.received(msg);
}
}

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.gameState;
package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
@@ -12,39 +12,45 @@
import pp.mdga.notification.SwapPieceNotification;
import pp.mdga.notification.ThrowPieceNotification;
import java.util.UUID;
public abstract class GameStates extends ClientState {
public GameStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
protected void handlePowerCard(PlayCardMessage msg){
if (msg.getCard().equals(BonusCard.TURBO)){
protected void handlePowerCard(PlayCardMessage msg) {
if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
logic.getGame().setDiceModifier(msg.getDiceModifier());
} else if (msg.getCard().equals(BonusCard.SHIELD)){
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
} else {
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
}
} else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) {
handleShield(msg.getPieces().get(0).getUuid());
} else {
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
}
logic.getGame().getDiscardPile().add(logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard()));
logic.getGame().getDiscardPile().add(msg.getCard());
}
protected void throwPiece(Piece piece){
protected void throwPiece(Piece piece) {
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
logic.getGame().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
piece.setState(PieceState.WAITING);
}
private void handleShield(UUID uuid) {
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(uuid)) % 10 != 0) {
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(uuid));
} else {
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(uuid));
}
}
}

View File

@@ -1,11 +1,14 @@
package pp.mdga.client.gameState;
package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;
import pp.mdga.notification.*;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.HomeMoveNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayCardNotification;
public class SpectatorState extends GameStates {
@@ -27,15 +30,15 @@ public void exit() {
}
@Override
public void received(CeremonyMessage msg){
public void received(CeremonyMessage msg) {
logic.setState(logic.getCeremony());
}
@Override
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
public void received(DieMessage msg) {
//logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){
if (msg.getDiceEye() == 6) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6();
}
@@ -43,8 +46,8 @@ public void received(DieMessage msg){
}
@Override
public void received(PlayCardMessage msg){
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -52,26 +55,26 @@ public void received(PlayCardMessage msg){
}
@Override
public void received(ActivePlayerMessage msg){
public void received(ActivePlayerMessage msg) {
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation());
}
@Override
public void received(MoveMessage msg){
public void received(MoveMessage msg) {
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()){
if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
} else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().increasePiecesThrown();
}
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else {

View File

@@ -1,14 +1,14 @@
package pp.mdga.client.gameState;
package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gameState.turnState.MovePieceState;
import pp.mdga.client.gameState.turnState.PlayPowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.client.gameState.turnState.RollDiceState;
import pp.mdga.client.gameState.turnState.TurnStates;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gamestate.turnstate.MovePieceState;
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gamestate.turnstate.RollDiceState;
import pp.mdga.client.gamestate.turnstate.TurnStates;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;
@@ -108,7 +108,7 @@ public void received(DiceAgainMessage msg){
}
@Override
public void received(PossibleCardMessage msg){
public void received(PossibleCardsMessage msg){
state.received(msg);
}

View File

@@ -1,9 +1,10 @@
package pp.mdga.client.gameState;
package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.game.*;
import pp.mdga.game.Piece;
import pp.mdga.game.PieceState;
import pp.mdga.message.server.*;
import pp.mdga.notification.*;
@@ -27,21 +28,21 @@ public void exit() {
}
@Override
public void received(CeremonyMessage msg){
public void received(CeremonyMessage msg) {
logic.setState(logic.getCeremony());
}
@Override
public void received(DiceNowMessage msg){
public void received(DiceNowMessage msg) {
logic.addNotification(new DiceNowNotification());
parent.setState(parent.getTurn());
}
@Override
public void received(DieMessage msg){
public void received(DieMessage msg) {
logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
if (msg.getDiceEye() == 6) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6();
}
@@ -49,8 +50,8 @@ public void received(DieMessage msg){
}
@Override
public void received(PlayCardMessage msg){
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -58,21 +59,21 @@ public void received(PlayCardMessage msg){
}
@Override
public void received(ActivePlayerMessage msg){
public void received(ActivePlayerMessage msg) {
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation());
}
@Override
public void received(MoveMessage msg){
public void received(MoveMessage msg) {
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()){
if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
for(int i = msg.getTargetIndex() + 1; i < 4; i++){
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
pieceToMove.setState(PieceState.HOME);
break;
}
@@ -84,7 +85,7 @@ public void received(MoveMessage msg){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().increasePiecesThrown();
}
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.determineStartPlayerState;
package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates;
import pp.mdga.client.gamestate.GameStates;
public abstract class DetermineStartPlayerStates extends GameStates {
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -0,0 +1,85 @@
package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.game.Player;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DrawCardNotification;
import pp.mdga.notification.MovePieceNotification;
import java.util.Map;
public class Intro extends DetermineStartPlayerStates{
private final DetermineStartPlayerState parent;
private int animationCounter = 0;
/**
* Constructor for Intro
*
* @param parent the parent state
* @param logic the client game logic
*/
public Intro(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
/**
* This method is used to get the parent state;
*
* @return the parent state
*/
public DetermineStartPlayerState getParent(){
return parent;
}
/**
* This method is used to enter this state and play all necessary intro animations.
*/
@Override
public void enter() {
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
//logic.addNotification(new WaitMoveNotification(entry.getValue().getPieces()[0].getUuid()));
logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
animationCounter++;
if(entry.getKey() == logic.getOwnPlayerId()){
logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0).getCard()));
} else {
logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), entry.getValue().getHandCards().get(0).getCard()));
}
}
}
/**
* This method i s used to exit this state.
*/
@Override
public void exit() {
animationCounter = 0;
}
/**
* This method is used when the view has completed the animation.
*/
@Override
public void selectAnimationEnd(){
animationCounter--;
if(animationCounter != 0){
return;
}
logic.send(new AnimationEndMessage());
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
parent.getParent().setState(parent.getParent().getTurn());
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
} else {
parent.getParent().setState(parent.getParent().getWaiting());
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
}
}
}

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.determineStartPlayerState;
package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.DetermineStartPlayerState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage;
import pp.mdga.notification.DiceNowNotification;
@@ -28,13 +28,12 @@ public void exit() {
@Override
public void selectDice(){
System.out.println("selectDice");
logic.send(new RequestDieMessage());
}
@Override
public void received(DieMessage msg){
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
parent.setState(parent.getWaitRanking());
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
}
}

View File

@@ -0,0 +1,58 @@
package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.ActivePlayerNotification;
public class WaitRankingState extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent;
private boolean canChange = false;
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
private void changeToIntro(){
if(!canChange){
canChange = true;
return;
}
parent.setState(parent.getIntro());
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(DiceNowMessage msg){
parent.setState(parent.getRollRankingDice());
}
@Override
public void received(RankingResponseMessage msg){
}
@Override
public void selectAnimationEnd(){
changeToIntro();
logic.send(new AnimationEndMessage());
}
@Override
public void received(ActivePlayerMessage msg){
logic.getGame().setActiveColor(msg.getColor());
changeToIntro();
}
}

View File

@@ -1,9 +1,9 @@
package pp.mdga.client.gameState.turnState;
package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gameState.turnState.choosePieceState.*;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState;
package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.*;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState;
package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.PlayCardNotification;
@@ -20,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
handlePowerCard(playCardMessage);
}

View File

@@ -1,17 +1,17 @@
package pp.mdga.client.gameState.turnState;
package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState;
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates;
import pp.mdga.client.gameState.turnState.powerCardState.ShieldState;
import pp.mdga.client.gameState.turnState.powerCardState.SwapState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gamestate.turnstate.powercardstate.ChoosePowerCardState;
import pp.mdga.client.gamestate.turnstate.powercardstate.PowerCardStates;
import pp.mdga.client.gamestate.turnstate.powercardstate.ShieldState;
import pp.mdga.client.gamestate.turnstate.powercardstate.SwapState;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.message.server.PossibleCardMessage;
import pp.mdga.message.server.PossibleCardsMessage;
import pp.mdga.message.server.PossiblePieceMessage;
public class PowerCardState extends TurnStates {
@@ -48,7 +48,7 @@ public void setState(PowerCardStates state) {
}
@Override
public void received(PossibleCardMessage msg){
public void received(PossibleCardsMessage msg){
state.received(msg);
}

View File

@@ -1,10 +1,13 @@
package pp.mdga.client.gameState.turnState;
package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.NoTurnMessage;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.RollDiceNotification;
public class RollDiceState extends TurnStates {
@@ -17,7 +20,7 @@ public RollDiceState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.addNotification(new DiceNowNotification());
}
@Override
@@ -29,6 +32,11 @@ public TurnState getParent() {
return parent;
}
@Override
public void selectDice(){
logic.send(new RequestDieMessage());
}
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
parent.setState(parent.getChoosePiece());

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState;
package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates;
import pp.mdga.client.gamestate.GameStates;
public abstract class TurnStates extends GameStates {
public TurnStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.TurnStates;
import pp.mdga.client.gamestate.turnstate.TurnStates;
public abstract class ChoosePieceStates extends TurnStates {
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,12 +1,11 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;
import pp.mdga.message.server.StartPieceMessage;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.WaitMoveNotification;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
@@ -31,24 +31,26 @@ public void exit() {
}
public void setPossiblePieces(ArrayList<Piece> possiblePieces){
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
this.possiblePieces = possiblePieces;
}
@Override
public void selectPiece(Piece piece){
public void selectPiece(Piece piece) {
ArrayList<Piece> pieces = new ArrayList<>();
if(possiblePieces.contains(piece)){
logic.send(new SelectedPiecesMessage(piece.getUuid()));
pieces.add(piece);
logic.send(new SelectedPiecesMessage(pieces));
}
}
@Override
public void received(MoveMessage msg){
public void received(MoveMessage msg) {
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if(msg.isHomeMove()){
if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
} else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());

View File

@@ -1,12 +1,14 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
public class StartPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
@@ -30,8 +32,10 @@ public void exit() {
@Override
public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){
logic.send(new SelectedPiecesMessage(piece.getUuid()));
pieces.add(piece);
logic.send(new SelectedPiecesMessage(pieces));
}
}

View File

@@ -1,13 +1,16 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.game.PieceState;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
import java.util.List;
public class WaitingPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
@@ -29,8 +32,10 @@ public void exit() {
@Override
public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){
logic.send(new SelectedPiecesMessage(piece.getUuid()));
pieces.add(piece);
logic.send(new SelectedPiecesMessage(pieces));
}
}

View File

@@ -1,14 +1,15 @@
package pp.mdga.client.gameState.turnState.powerCardState;
package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.game.BonusCard;
import pp.mdga.game.card.*;
import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.SelectCardMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.message.server.PossibleCardMessage;
import pp.mdga.message.server.PossibleCardsMessage;
import pp.mdga.message.server.PossiblePieceMessage;
import pp.mdga.notification.SelectableCardsNotification;
@@ -21,7 +22,7 @@
public class ChoosePowerCardState extends PowerCardStates {
private final PowerCardState parent;
private ArrayList<BonusCard> possibleCards;
private ArrayList<PowerCard> possibleCards = new ArrayList<>();
/**
* Constructor
@@ -38,8 +39,6 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
*/
@Override
public void enter() {
possibleCards = new ArrayList<>();
//TODO: logic.send(new RequestPossibleCardsMessage());
}
/**
@@ -47,7 +46,7 @@ public void enter() {
*/
@Override
public void exit() {
possibleCards = null;
possibleCards = new ArrayList<>();
}
/**
@@ -55,9 +54,15 @@ public void exit() {
* @param msg possible cards message
*/
@Override
public void received(PossibleCardMessage msg){
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
logic.addNotification(new SelectableCardsNotification(possibleCards));
public void received(PossibleCardsMessage msg){
possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards();
ArrayList<BonusCard> possibleBonusCards = new ArrayList<>();
for (PowerCard card : possibleCards) {
if (!possibleBonusCards.contains(card.getCard())) {
possibleBonusCards.add(card.getCard());
}
}
logic.addNotification(new SelectableCardsNotification(possibleBonusCards));
}
/**
@@ -67,7 +72,7 @@ public void received(PossibleCardMessage msg){
@Override
public void selectCard(BonusCard card){
if(card != null){
logic.send(new SelectCardMessage(card));
logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card)));
} else {
logic.send(new NoPowerCardMessage());
}
@@ -79,10 +84,9 @@ public void selectCard(BonusCard card){
*/
@Override
public void received(PlayCardMessage msg){
if(msg.getCard().equals(BonusCard.TURBO)){
logic.getGame().setDiceModifier(msg.getDiceModifier());
} else {
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
if(msg.getCard().getCard().equals(BonusCard.TURBO)){
parent.getParent().getPlayPowerCard().setPlayCard(msg);
parent.getParent().setState(parent.getParent().getPlayPowerCard());
}
}

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.powerCardState;
package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.TurnStates;
import pp.mdga.client.gamestate.turnstate.TurnStates;
public abstract class PowerCardStates extends TurnStates {
public PowerCardStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.powerCardState;
package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.powerCardState;
package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState;
package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState;
package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState;
package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState;
package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;

View File

@@ -2,31 +2,38 @@
import com.jme3.network.serializing.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* This class will be used to hold all Board relevant data.
*/
@Serializable
public class Board {
private Map<Color, PlayerData> playerData = new HashMap<>();
/**
* The size of the board.
*/
public static final int BOARD_SIZE = 40;
/**
* Create Board attributes.
*/
private final Node[] infield;
/**
* This constructor is used to create a new board
*/
public Board() {
infield = new Node[40];
for (int i = 0; i < 40; i++) {
if (i % 10 == 0) {
infield[i] = new StartNode(
i == 0 ? Color.AIRFORCE :
i == 10 ? Color.CYBER :
i == 20 ? Color.NAVY :
Color.ARMY
);
} else if (i == 4 || i == 14 || i == 24 || i == 34) {
infield = new Node[BOARD_SIZE];
initializeBoard();
}
/**
* Initializes the board by setting up the nodes.
* Start nodes, bonus nodes, and regular nodes are created based on their positions.
*/
private void initializeBoard() {
for (int i = 0; i < BOARD_SIZE; i++) {
if (isStartNode(i)) {
infield[i] = createStartNode(i);
} else if (isBonusNode(i)) {
infield[i] = new BonusNode();
} else {
infield[i] = new Node(null);
@@ -35,23 +42,48 @@ public Board() {
}
/**
* This method will be used to add the given color and playerData parameters to the playerData attribute of
* Board class.
* Checks if the given index is a start node.
*
* @param color as the color of the player as a Color enumeration.
* @param playerData as the playerData of the player as a PlayerData object.
* @param i the index to check
* @return true if the index is a start node, false otherwise
*/
public void addPlayerData(Color color, PlayerData playerData) {
this.playerData.put(color, playerData);
private boolean isStartNode(int i) {
return i % 10 == 0;
}
/**
* This method returns the playerData
* Checks if the given index is a bonus node.
*
* @return the playerData
* @param i the index to check
* @return true if the index is a bonus node, false otherwise
*/
public Map<Color, PlayerData> getPlayerData() {
return playerData;
private boolean isBonusNode(int i) {
return i % 10 == 4;
}
/**
* Creates a start node with the appropriate color based on the index.
*
* @param i the index of the start node
* @return a new StartNode with the corresponding color
*/
private StartNode createStartNode(int i) {
return new StartNode(Color.getColor(i));
}
/**
* This method returns the index of a specific piece on the board
*
* @param piece the piece to be searched for
* @return the index of the piece
*/
public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) {
if (infield[i].getOccupant() == piece) {
return i;
}
}
return -1;
}
/**
@@ -73,18 +105,8 @@ public void setPieceOnBoard(int index, Piece piece) {
infield[index].setOccupant(piece);
}
/**
* This method returns the index of a specific piece on the board
*
* @param piece the piece to be searched for
* @return the index of the piece
*/
public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) {
if (infield[i].getOccupant() == piece) {
return i;
}
}
return -1;
@Override
public String toString() {
return "Default Board";
}
}

View File

@@ -1,8 +1,11 @@
package pp.mdga.game;
import com.jme3.network.serializing.Serializable;
/**
* Enum representing the different types of bonus cards.
*/
@Serializable
public enum BonusCard {
/**
* The hidden bonus card.

View File

@@ -7,7 +7,10 @@
*/
@Serializable
public class BonusNode extends Node {
BonusNode(){
/**
* Constructor.
*/
BonusNode() {
super(null);
}
}

View File

@@ -3,8 +3,8 @@
import com.jme3.network.serializing.Serializable;
/**
* This enumeration will be used to show the four different TSK which can be picked from a player.
* In Addition, the NONE color will be used to show a none color.
* This enumeration represents the four different TSK colors that a player can choose.
* Additionally, the NONE color indicates the absence of a color.
*/
@Serializable
public enum Color {
@@ -58,4 +58,19 @@ public Color next() {
return colors[nextIndex];
}
/**
* This method will be used to return the color of the given index.
*
* @param i as the index of the color as an Integer.
* @return a Color enumeration.
*/
public static Color getColor(int i) {
for (Color color : Color.values()) {
if (color.ordinal() == i) {
return color;
}
}
return null;
}
}

View File

@@ -1,7 +1,5 @@
package pp.mdga.game;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory;

View File

@@ -1,9 +1,14 @@
package pp.mdga.game;
import pp.mdga.game.card.PowerCard;
import pp.mdga.game.card.ShieldCard;
import pp.mdga.game.card.SwapCard;
import pp.mdga.game.card.TurboCard;
import java.util.*;
/**
* The Game class represents the game state of the Ludo game.
* The Game class represents the game state of the game.
* It contains all the information needed to play the game.
* The game state is updated by the game logic.
*/
@@ -14,57 +19,108 @@ public class Game {
public static final int AMOUNT_OF_TURBO_CARDS = 16;
/**
* The number of shield and swap cards available in the game.
* The number of shield cards available in the game.
*/
public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12;
public static final int AMOUNT_OF_SHIELD_CARDS = 12;
// The modifier applied to the dice roll.
private int diceModifier = 1;
/**
* The number of swap cards available in the game.
*/
public static final int AMOUNT_OF_SWAP_CARDS = 12;
// The number of eyes shown on the dice.
private int diceEyes;
// A map of player IDs to Player objects.
/**
* A map of player IDs to Player objects.
*/
private Map<Integer, Player> players = new HashMap<>();
// The statistics of the game.
/**
* The statistics of the game.
*/
private Statistic gameStatistics;
// The pile of bonus cards available for drawing.
private List<BonusCard> drawPile;
/**
* The pile of bonus cards available for drawing.
*/
private List<PowerCard> drawPile = new ArrayList<>();
// The pile of bonus cards that have been discarded.
private List<BonusCard> discardPile = new ArrayList<>();
/**
* The pile of bonus cards that have been discarded.
*/
private List<PowerCard> discardPile = new ArrayList<>();
// The game board.
/**
* The game board.
*/
private Board board;
// The die used in the game.
/**
* The die used in the game.
*/
private Die die;
// The host of this game
/**
* The host of this game
*/
private int host = -1;
// The color of the active player.
/**
* The color of the active player.
*/
private Color activeColor;
/**
* The dice modifier.
*/
private int diceModifier;
/**
* The number of eyes on the dice.
*/
private int diceEyes;
/**
* This constructor creates a new Game object.
*/
public Game() {
gameStatistics = new Statistic();
drawPile = new ArrayList<>();
for (int i = 0; i < AMOUNT_OF_TURBO_CARDS; i++) {
drawPile.add(BonusCard.TURBO);
}
for (int i = 0; i < AMOUNT_OF_SHIELD_AND_SWAP_CARDS; i++) {
drawPile.add(BonusCard.SWAP);
drawPile.add(BonusCard.SHIELD);
}
initializeDrawPile();
board = new Board();
die = new Die();
}
/**
* This method initializes the draw pile with the predefined number of bonus cards.
*/
private void initializeDrawPile() {
this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
Collections.shuffle(this.drawPile);
}
/**
* This method will be used to remove the first card of the drawPile attribute of Game class.
*
* @return first card as a PowerCard enumeration.
*/
public PowerCard draw() {
if (!this.drawPile.isEmpty()) {
return this.drawPile.remove(0);
}
return null;
}
/**
* This method adds a number of bonus cards to the draw pile.
*
* @param card the card to add
* @param count the number of cards to add
*/
private void addBonusCards(PowerCard card, int count) {
drawPile.addAll(Collections.nCopies(count, card));
}
/**
* This method adds a player to the game.
*
@@ -99,7 +155,7 @@ public void updatePlayerActiveState(int id, boolean active) {
* If yes it will return true, otherwise false.
*
* @param color as the color which should be checked if taken as a Color enumeration.
* @return true or false.
* @return true or false.
*/
public boolean isColorTaken(Color color) {
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
@@ -152,6 +208,15 @@ public Player getPlayerByColor(Color color) {
return null;
}
/**
* This method will be used to return all connected players as a list.
*
* @return players as a List of Player objects.
*/
public List<Player> getPlayersAsList() {
return new ArrayList<>(this.players.values());
}
/**
* This method will be used to return the id of the active player depending on the activeColor attribute of Game
* class.
@@ -166,7 +231,7 @@ public int getActivePlayerId() {
* This method will be used to return the id of the Player defined by the given color parameter.
*
* @param color as the color of the player as a Color enumeration.
* @return the id of the player as an Integer.
* @return the id of the player as an Integer.
*/
public int getPlayerIdByColor(Color color) {
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
@@ -216,8 +281,8 @@ public boolean areAllReady() {
* @return the piece specified by the UUID
*/
public Piece getPieceThroughUUID(UUID pieceId) {
for (var playerData : board.getPlayerData().values()) {
for (var piece : playerData.getPieces()) {
for (var player : this.getPlayers().values()) {
for (var piece : player.getPieces()) {
if (piece.getUuid().equals(pieceId)) {
return piece;
}
@@ -235,24 +300,6 @@ public boolean isHost() {
return this.host != -1;
}
/**
* This method returns the dice modifier.
*
* @return the dice modifier
*/
public int getDiceModifier() {
return diceModifier;
}
/**
* This method returns the dice eyes.
*
* @return the dice eyes
*/
public int getDiceEyes() {
return diceEyes;
}
/**
* This method returns the players.
*
@@ -272,21 +319,21 @@ public Statistic getGameStatistics() {
}
/**
* This method returns the draw pile.
* This method will be used to return drawPile attribute of Game class.
*
* @return the draw pile
* @return drawPile as a List of PowerCard objects.
*/
public List<BonusCard> getDrawPile() {
return drawPile;
public List<PowerCard> getDrawPile() {
return this.drawPile;
}
/**
* This method returns the discard pile.
* This method will be used to return discardPile attribute of Game class.
*
* @return the discard pile
* @return discardPile as a List of PowerCard objects.
*/
public List<BonusCard> getDiscardPile() {
return discardPile;
public List<PowerCard> getDiscardPile() {
return this.discardPile;
}
/**
@@ -325,24 +372,6 @@ public int getHost() {
return this.host;
}
/**
* This method sets the dice modifier.
*
* @param diceModifier the new dice modifier
*/
public void setDiceModifier(int diceModifier) {
this.diceModifier = diceModifier;
}
/**
* This method sets the dice eyes.
*
* @param diceEyes the new dice eyes
*/
public void setDiceEyes(int diceEyes) {
this.diceEyes = diceEyes;
}
/**
* This method sets the players.
*
@@ -362,20 +391,22 @@ public void setGameStatistics(Statistic gameStatistics) {
}
/**
* This method sets the draw pile.
* This method will be used to set drawPile attribute of Game class to the given discardPile parameter.
* It will be used to test cases.
*
* @param drawPile the new draw pile
* @param drawPile the new value of drawPile attribute as a List of PowerCards.
*/
public void setDrawPile(List<BonusCard> drawPile) {
public void setDrawPile(List<PowerCard> drawPile) {
this.drawPile = drawPile;
}
/**
* This method sets the discard pile.
* This method will be used to set discardPile attribute of Game class to the given discardPile parameter.
* It will be used to test cases.
*
* @param discardPile the new discard pile
* @param discardPile the new value of discardPile attribute as a List of PowerCards.
*/
public void setDiscardPile(List<BonusCard> discardPile) {
public void setDiscardPile(List<PowerCard> discardPile) {
this.discardPile = discardPile;
}
@@ -414,4 +445,40 @@ public void setDie(Die die) {
public void setHost(int host) {
this.host = host;
}
/**
* This method will be used to get the dice eyes.
*
* @return the dice eyes
*/
public int getDiceEyes() {
return diceEyes;
}
/**
* This method is used to get the dice modifier.
*
* @return the dice modifier
*/
public int getDiceModifier() {
return diceModifier;
}
/**
* This method will be used to set the dice eyes.
*
* @param diceEyes the new dice eyes
*/
public void setDiceEyes(int diceEyes) {
this.diceEyes = diceEyes;
}
/**
* This method is used to set the dice modifier.
*
* @param diceModifier the new dice modifier
*/
public void setDiceModifier(int diceModifier) {
this.diceModifier = diceModifier;
}
}

View File

@@ -7,6 +7,9 @@
*/
@Serializable
public class HomeNode extends Node {
/**
* Constructor.
*/
public HomeNode() {
super(null);
}

View File

@@ -3,22 +3,33 @@
import com.jme3.network.serializing.Serializable;
/**
* This class will be used the represent a Node on which the pieces can travel along
* Represents a node on the board.
*/
@Serializable
public class Node {
/**
* The occupant of the node.
*/
protected Piece occupant;
public Node(Piece piece){
/**
* This constructor is used to create a new node object with a given occupant.
*
* @param piece as the occupant of the node.
*/
public Node(Piece piece) {
occupant = piece;
}
private Node(){
/**
* This constructor is used to create a new node object with a default occupant.
*/
private Node() {
occupant = new Piece(Color.AIRFORCE, PieceState.WAITING);
}
/**
* This method is used to get an occupant of the Node.
* This method is used to get an occupant of the node.
*
* @return the current occupant of the node
*/
@@ -27,7 +38,7 @@ public Piece getOccupant() {
}
/**
* This method is used to set a new Occupant
* This method is used to set a new occupant
*
* @param occupant the new occupant of the node
*/
@@ -58,9 +69,9 @@ public boolean isOccupied() {
* This method will be used to check if the node is occupied by a piece of the given color.
*
* @param color as the color of the piece as a Color object.
* @return true or false.
* @return true or false.
*/
public boolean isOccupied(Color color) {
return this.occupant != null && this.occupant.getColor() == color;
return isOccupied() && this.occupant.getColor() == color;
}
}

View File

@@ -51,74 +51,117 @@ private Piece() {
}
/**
* This method is used to get the color of the piece
* Sets the shield state of the piece.
*
* @return the color of the piece
* @param shield the new shield state
*/
public void setShield(ShieldState shield) {
this.shield = shield;
}
/**
* This method is used to get the color of the piece
* Gets the shield state of the piece.
*
* @return the color of the piece
* @return the shield state
*/
public ShieldState getShield() {
return shield;
}
/**
* This method is used to get the color of the piece
* Sets the state of the piece.
*
* @param state the state of the piece
* @param state the new state
*/
public void setState(PieceState state) {
this.state = state;
}
/**
* This method is used to get the color of the piece
* Gets the state of the piece.
*
* @return the color of the piece
* @return the state
*/
public PieceState getState() {
return state;
}
/**
* This method is used to get the color of the piece
* Checks if the piece is shielded.
*
* @return the color of the piece
* @return true if the piece is shielded, false otherwise
*/
public boolean isShielded() {
return shield == ShieldState.ACTIVE;
}
/**
* This method is used to get the color of the piece
* Checks if the shield of a piece is suppressed.
*
* @return the color of the piece
* @return true if the shield is suppressed, false otherwise
*/
public boolean isSuppressed() {
return shield == ShieldState.SUPPRESSED;
}
/**
* This method is used to get the color of the piece
* Gets the color of the piece.
*
* @return the color of the piece
* @return the color
*/
public Color getColor() {
return color;
}
/**
* This method is used to get the color of the piece
* Gets the unique identifier of the piece.
*
* @return the color of the piece
* @return the UUID
*/
public UUID getUuid() {
return uuid;
}
/**
* This method will return all necessary information of Piece class in a more readable way.
*
* @return information as a String.
*/
@Override
public String toString() {
return "Piece with UUID: %s and color: %s with state: %s".formatted(this.uuid, color, state);
}
/**
* This method will be used to create the hash code of this Piece class.
*
* @return hashCode as an Integer.
*/
@Override
public int hashCode() {
return this.uuid.hashCode();
}
/**
* This method will be used to check if the given obj parameter is equal to this object.
* It will return false if the obj parameter is null or if the hash codes of both objects are not equal. Otherwise
* it will return true.
*
* @param obj as the object which will be compared as an Object.
* @return true or false.
*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj instanceof Piece) {
Piece piece = (Piece) obj;
return this.hashCode() == piece.hashCode();
}
return false;
}
}

View File

@@ -22,5 +22,5 @@ public enum PieceState {
/**
* The piece is finished.
*/
HOMEFINISHED;
HOMEFINISHED
}

View File

@@ -2,11 +2,12 @@
import com.jme3.network.serializing.Serializable;
import pp.mdga.Resources;
import pp.mdga.game.card.PowerCard;
import java.util.ArrayList;
/**
* This class will be used to handle general PlayerData
* This class represents a player in the game.
*/
@Serializable
public class Player {
@@ -23,7 +24,7 @@ public class Player {
/**
* The hand cards of the player.
*/
private ArrayList<BonusCard> handCards = new ArrayList<>();
private ArrayList<PowerCard> handCards = new ArrayList<>();
/**
* The color of the player.
@@ -44,10 +45,29 @@ public class Player {
* Node and piece attributes
*/
private int startNodeIndex = -1;
/**
* The home nodes of the player.
*/
private HomeNode[] homeNodes = new HomeNode[Resources.MAX_PIECES];
/**
* The waiting area of the player.
*/
private Piece[] waitingArea = new Piece[Resources.MAX_PIECES];
/**
* The pieces of the player.
*/
private Piece[] pieces = new Piece[Resources.MAX_PIECES];
/**
* Constructor.
*/
public Player() {
this("");
}
/**
* This constructor constructs a new Player object
*
@@ -57,13 +77,6 @@ public Player(String name) {
this.name = name;
}
/**
* Constructor.
*/
public Player() {
this("");
}
/**
* This method will be used to initialize all nodes and pieces of the Player class.
*/
@@ -73,6 +86,7 @@ public void initialize() {
this.pieces[index] = new Piece(this.color, PieceState.WAITING);
this.waitingArea[index] = this.pieces[index];
}
startNodeIndex = color.ordinal() * 10;
}
/**
@@ -80,22 +94,17 @@ public void initialize() {
*
* @param card the card to be added to the players hand
*/
public void addHandCard(BonusCard card) {
handCards.add(card);
public void addHandCard(PowerCard card) {
this.handCards.add(card);
}
/**
* This method returns a BonusCard to be removed from the players hand.
* This method will be used to remove the given card parameter from the handCards attribute of Player card.
*
* @param card the cards type to be removed
* @return the removed card or null if there is none of that card type
* @param card as the card which should be removed from the handCards attribute as a PowerCard object.
*/
public BonusCard removeHandCard(BonusCard card) {
BonusCard cardToRemove = handCards.stream().filter(c -> c.equals(card)).findFirst().orElse(null);
if (cardToRemove != null) {
handCards.remove(cardToRemove);
}
return cardToRemove;
public void removeHandCard(PowerCard card) {
this.handCards.remove(card);
}
/**
@@ -120,7 +129,27 @@ public void addWaitingPiece(Piece piece) {
* @return true or false.
*/
public boolean isFinished() {
return false;
for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (this.pieces[i].getState() != PieceState.HOMEFINISHED) {
return false;
}
}
return true;
}
/**
* This method returns a PowerCard based on its Type.
*
* @param bonusCard the card Type to be matched
* @return the first PowerCard of this type
*/
public PowerCard getPowerCardByType(BonusCard bonusCard) {
for (PowerCard card : this.handCards) {
if(card.getCard().equals(bonusCard)) {
return card;
}
}
return null;
}
/**
@@ -142,12 +171,12 @@ public Statistic getPlayerStatistic() {
}
/**
* This method returns the current handCards of the player
* This method will be used to return handCards attribute of Player class.
*
* @return the handCards of the player
* @return handCards as a List of PowerCard objects.
*/
public ArrayList<BonusCard> getHandCards() {
return handCards;
public ArrayList<PowerCard> getHandCards() {
return this.handCards;
}
/**
@@ -248,4 +277,24 @@ public void setReady(boolean ready) {
public void setActive(boolean active) {
this.active = active;
}
/**
* This method sets a piece at the given index in the home area
*
* @param index the index of the node
* @param piece the piece to be set at the given index
*/
public void setPieceInHome(int index, Piece piece) {
this.homeNodes[index].setOccupant(piece);
}
/**
* The string representation of the player
*
* @return the string representation of the player
*/
@Override
public String toString() {
return "Player: " + name + " Color: " + color;
}
}

View File

@@ -1,197 +0,0 @@
package pp.mdga.game;
import com.jme3.network.serializing.Serializable;
import pp.mdga.Resources;
/**
* This class is used to represent PlayerData related to the board
*/
@Serializable
public class PlayerData {
/**
* An array of HomeNode objects representing the home nodes of the player.
*/
private HomeNode[] homeNodes;
/**
* The index of the start node for the player.
*/
private int startNodeIndex;
/**
* An array of Piece objects representing the waiting area of the player.
*/
private Piece[] waitingArea;
/**
* An array of Piece objects representing all the pieces of the player.
*/
private Piece[] pieces;
/**
* This constructor is used to create a new PlayerData object
*
* @param color the color of the player
*/
public PlayerData(Color color) {
homeNodes = new HomeNode[Resources.MAX_PIECES];
pieces = new Piece[Resources.MAX_PIECES];
waitingArea = new Piece[Resources.MAX_PIECES];
for (int i = 0; i < Resources.MAX_PIECES; i++) {
homeNodes[i] = new HomeNode();
pieces[i] = new Piece(color, PieceState.WAITING);
waitingArea[i] = pieces[i];
}
}
/**
* Constructor.
*/
private PlayerData() {
homeNodes = new HomeNode[Resources.MAX_PIECES];
waitingArea = new Piece[Resources.MAX_PIECES];
pieces = new Piece[Resources.MAX_PIECES];
}
/**
* This method will be used to check if the player is finished.
* ToDo: Currently return always false. Implement logic!
*
* @return true or false.
*/
public boolean isFinished() {
return false;
}
/**
* This method returns an Array of HomeNodes
*
* @return the array of HomeNodes
*/
public Node[] getHomeNodes() {
return homeNodes;
}
/**
* This method returns the index of the StartNode
*
* @return the index of the StartNode
*/
public int getStartNodeIndex() {
return startNodeIndex;
}
/**
* This method sets the index of the startNode.
*
* @param startNodeIndex the integer index of the startNode
*/
public void setStartNodeIndex(int startNodeIndex) {
this.startNodeIndex = startNodeIndex;
}
/**
* This method returns an array pieces representing the waiting area.
*
* @return the waiting area
*/
public Piece[] getWaitingArea() {
return waitingArea;
}
/**
* This method returns an array of pieces with all the players pieces
*
* @return the array of pieces
*/
public Piece[] getPieces() {
return pieces;
}
/**
* This method adds a piece to the waiting area
*
* @param piece the piece to be added to the waiting area
*/
public void addWaitingPiece(Piece piece) {
for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (waitingArea[i] == null) {
waitingArea[i] = piece;
return;
}
}
}
/**
* This method removes a piece from the waiting area
*
* @return the piece that was removed from the waiting area
*/
public Piece removePieceFromWaitingArea() {
for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (waitingArea[i] != null) {
Piece piece = waitingArea[i];
waitingArea[i] = null;
return piece;
}
}
return null;
}
/**
* This method sets a piece at the given index in the home area
*
* @param index the index of the node
* @param piece the piece to be set at the given index
*/
public void setPieceInHome(int index, Piece piece) {
homeNodes[index].setOccupant(piece);
}
/**
* This method will be used to return if the given piece parameter is inside the homNodes attribute of PlayerData
* class.
* If yes it will return true, otherwise false.
*
* @return true or false.
*/
public boolean homeIncludes(Piece piece) {
for (Node node : this.homeNodes) {
if (node.getOccupant() == piece) {
return true;
}
}
return false;
}
/**
* This method will be used to return the index of the given piece parameter in the homeNodes attribute of
* PlayerData class.
*
* @return index as an Integer.
*/
public int getIndexInHome(Piece piece) {
for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (homeNodes[i].getOccupant() == piece) {
return i;
}
}
return -1;
}
/**
* This method will be usd to check if the waitingArea attribute of PlayerData class is empty.
* If yes it will return false, otherwise true.
*
* @return true or false.
*/
public boolean hasPieceInWaitingArea() {
for (Piece piece : waitingArea) {
if (piece != null) {
return true;
}
}
return false;
}
}

View File

@@ -15,5 +15,5 @@ public enum ShieldState {
/**
* The shield is suppressed, when the piece is on a start node.
*/
SUPPRESSED;
SUPPRESSED
}

View File

@@ -22,6 +22,9 @@ public StartNode(Color color) {
this.color = color;
}
/**
* Default constructor for serialization.
*/
private StartNode() {
super(null);
color = Color.NONE;

View File

@@ -68,7 +68,7 @@ public void setCardsPlayed(int cardsPlayed) {
}
/**
* This method returns the count of enemyPieces Thrown during the game.
* This method returns the count of enemyPieces thrown during the game.
*
* @return the count of enemyPieces thrown
*/
@@ -77,7 +77,7 @@ public int getPiecesThrown() {
}
/**
* This method sets the new count of enemyPieces Thrown
* This method sets the new count of enemyPieces thrown
*
* @param piecesThrown the new count of pieces thrown.
*/
@@ -165,28 +165,28 @@ public void increaseCardsPlayed() {
}
/**
* This method increases the value of cardsPlayed by 1.
* This method increases the value of piecesThrown by 1.
*/
public void increasePiecesThrown() {
piecesThrown++;
}
/**
* This method increases the value of cardsPlayed by 1.
* This method increases the value of piecesBeingThrown by 1.
*/
public void increasePiecesBeingThrown() {
piecesBeingThrown++;
}
/**
* This method increases the value of cardsPlayed by 1.
* This method increases the value of diced6 by 1.
*/
public void increaseDiced6() {
diced6++;
}
/**
* This method increases the value of cardsPlayed by 1.
* This method increases the value of traveledNodes by 1.
*/
public void increaseTraveledNodes() {
traveledNodes++;
@@ -202,7 +202,7 @@ public void increaseTraveledNodes(int nodes) {
}
/**
* This method increases the value of cardsPlayed by 1.
* This method increases the value of activatedBonusNodes by 1.
*/
public void increaseActivatedBonusNodes() {
activatedBonusNodes++;

View File

@@ -0,0 +1,29 @@
package pp.mdga.game.card;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard;
import pp.mdga.visitor.Visitor;
/**
* This class represents the hidden power card of this application.
*/
@Serializable
public class HiddenCard extends PowerCard {
/**
* Constructor.
*/
public HiddenCard() {
this.card = BonusCard.HIDDEN;
}
/**
* This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object.
*
* @param visitor as the visitor which will differentiates between all types of power card types as a Visitor
* interface.
*/
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
}

View File

@@ -0,0 +1,86 @@
package pp.mdga.game.card;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard;
import pp.mdga.visitor.Visitor;
import java.util.UUID;
/**
* This abstract class represents the abstract power class which will be used to realize a visitor pattern for all
* types of different cards inside the game.
*/
@Serializable
public abstract class PowerCard {
/**
* Create PowerCard attributes.
*/
private final UUID uuid = UUID.randomUUID();
protected BonusCard card;
/**
* Constructor.
*/
public PowerCard() {
this.card = BonusCard.HIDDEN;
}
/**
* This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object.
*
* @param visitor as the visitor which will differentiates between all types of power card types as a Visitor
* interface.
*/
public abstract void accept(Visitor visitor);
/**
* This method will be used to return uuid attribute of abstract PowerCard class.
*
* @return uuid as a UUID object.
*/
public UUID getUuid() {
return this.uuid;
}
/**
* This method will be used to return card attribute of abstract PowerCard class.
*
* @return card as a BonusCard enumeration.
*/
public BonusCard getCard() {
return this.card;
}
/**
* This method will be used to create the hash code of this abstract PowerCard class.
*
* @return hashCode as an Integer.
*/
@Override
public int hashCode() {
return this.uuid.hashCode();
}
/**
* This method will be used to check if the given obj parameter is equal to this object.
* It will return false if the obj parameter is null or if the hash codes of both objects are not equal. Otherwise
* it will return true.
*
* @param obj as the object which will be compared as an Object.
* @return true or false.
*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj instanceof PowerCard) {
PowerCard card = (PowerCard) obj;
return this.hashCode() == card.hashCode();
}
return false;
}
}

View File

@@ -0,0 +1,28 @@
package pp.mdga.game.card;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard;
import pp.mdga.visitor.Visitor;
/**
* This class represents the shield power card of this application.
*/
@Serializable
public class ShieldCard extends PowerCard {
/**
* Constructor.
*/
public ShieldCard() {
this.card = BonusCard.SHIELD;
}
/**
* This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object.
*
* @param visitor as the visitor which will differentiates between all types of power card types as a Visitor
* interface.
*/
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
}

View File

@@ -0,0 +1,29 @@
package pp.mdga.game.card;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard;
import pp.mdga.visitor.Visitor;
/**
* This class represents the swap power card of this application.
*/
@Serializable
public class SwapCard extends PowerCard {
/**
* Constructor.
*/
public SwapCard() {
this.card = BonusCard.SWAP;
}
/**
* This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object.
*
* @param visitor as the visitor which will differentiates between all types of power card types as a Visitor
* interface.
*/
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
}

View File

@@ -0,0 +1,29 @@
package pp.mdga.game.card;
import com.jme3.network.serializing.Serializable;
import pp.mdga.game.BonusCard;
import pp.mdga.visitor.Visitor;
/**
* This class represents the turbo power card of this application.
*/
@Serializable
public class TurboCard extends PowerCard {
/**
* Constructor.
*/
public TurboCard() {
this.card = BonusCard.TURBO;
}
/**
* This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object.
*
* @param visitor as the visitor which will differentiates between all types of power card types as a Visitor
* interface.
*/
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
}

View File

@@ -14,16 +14,6 @@ public AnimationEndMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "AnimationEnd{}";
}
/**
* Accepts a visitor for processing this message.
*

View File

@@ -21,17 +21,17 @@ public interface ClientInterpreter {
void received(DeselectTSKMessage msg, int from);
/**
* Processes a received ForceStartGame message.
* Processes a received StartGame message.
*
* @param msg the ForceStartGame message to be processed
* @param msg the StartGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(StartGameMessage msg, int from);
/**
* Processes a received JoinServer message.
* Processes a received JoinedLobby message.
*
* @param msg the JoinServer message to be processed
* @param msg the JoinedLobby message to be processed
* @param from the connection ID from which the message was received
*/
void received(JoinedLobbyMessage msg, int from);

View File

@@ -21,4 +21,8 @@ protected ClientMessage() {
* @param from the connection ID of the sender
*/
public abstract void accept(ClientInterpreter interpreter, int from);
public String toString() {
return getClass().getSimpleName() + "{}";
}
}

View File

@@ -8,22 +8,12 @@
@Serializable
public class ClientStartGameMessage extends ClientMessage {
/**
* Constructs a new ClientStartGame instance.
* Constructor.
*/
public ClientStartGameMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ClientStartGame{}";
}
/**
* Accepts a visitor to process this message.
*

View File

@@ -3,24 +3,17 @@
import com.jme3.network.serializing.Serializable;
/**
*
* A message sent by a client to indicate that it has disconnected.
*/
@Serializable
public class DisconnectedMessage extends ClientMessage {
/**
* Constructs a new Disconnected message.
*/
public DisconnectedMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ClientStartGame{}";
}
/**
* Accepts a visitor to process this message.
*

View File

@@ -14,16 +14,6 @@ public ForceContinueGameMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ForceContinueGame{}";
}
/**
* Accepts a visitor to process this message.
*

View File

@@ -7,7 +7,9 @@
*/
@Serializable
public class JoinedLobbyMessage extends ClientMessage {
/**
* The name of the player that is joining the server.
*/
private final String name;
/**
@@ -42,7 +44,7 @@ public String getName(){
*/
@Override
public String toString() {
return "JoinServer{}";
return "JoinServer {" + "name=" + name + '}';
}
/**

View File

@@ -14,16 +14,6 @@ public LeaveGameMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LeaveGame{}";
}
/**
* Accepts a visitor to process this message.
*

View File

@@ -14,16 +14,6 @@ public LobbyNotReadyMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyNotReady{}";
}
/**
* Accepts a visitor to process this message.
*

View File

@@ -14,16 +14,6 @@ public LobbyReadyMessage() {
super();
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyReady{}";
}
/**
* Accepts a visitor to process this message.
*

Some files were not shown because too many files have changed in this diff Show More