218 Commits

Author SHA1 Message Date
Hanno Fleischer
5a9f7a8118 added AnimationEndMessages to 'RollDiceState', 'MovePieceState' and 'PlayPowerCardState' 2024-12-06 18:45:14 +01:00
Hanno Fleischer
2e1fe3c050 fixed a missing method call ind TurnState and removed debug sout statements ind 'RollDiceMessage' 2024-12-06 15:19:04 +01:00
Hanno Fleischer
308b592b65 Merge branch 'development' into 'dev/model'
Development merge

See merge request progproj/gruppen-ht24/Gruppe-01!36
2024-12-06 09:55:19 +00:00
Felix Koppe
c4e7fb1d41 Fix logic in modelSyncronizer 2024-12-06 10:54:02 +01:00
Felix Koppe
aacc0440b3 Update .gitignore 2024-12-06 10:33:13 +01:00
Hanno Fleischer
43c0e3bcc7 Merge branch 'development' into 'dev/model'
Development

See merge request progproj/gruppen-ht24/Gruppe-01!35
2024-12-06 09:09:29 +00:00
Felix Koppe
95635f5fb7 Fix ownColor in gameView 2024-12-06 09:59:28 +01:00
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
Daniel Grigencha
4904b32ea3 Updated 'ChoosePieceState' class.
Updated the 'ChoosePieceState' class by adding the 'RequestMoveMessage' handling to it.
2024-12-06 08:58:51 +01:00
Daniel Grigencha
b00219c4fb Updated 'PlayPowerCardState' class.
Updated the 'PlayPowerCardState' class by adding the 'AnimationEndMessage' handling to it.
2024-12-06 08:58:01 +01:00
Daniel Grigencha
12cf5f3e71 Updated 'PowerCardState' class.
Updated the 'PowerCardState' class by adding the 'SelectedPiecesMessage' handling to it.
2024-12-06 08:57:08 +01:00
Daniel Grigencha
77b0207214 Updated 'TurnState' class.
Updated the 'TurnState' class by adding the 'SelectedPiecesMessage', 'NoPowerCardMessage', 'RequestDieMessage' and 'ReuqestMoveMessage' handling to it.
2024-12-06 08:56:21 +01:00
Daniel Grigencha
a18165bc02 Updated 'Game' class.
Updated the 'Game' class by commenting out the creation of turbo and shield cards. This is only for testing purposes.
2024-12-06 08:55:01 +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
Cedric Beck
f3816cb2a5 added particle_cir.png 2024-12-05 17:49:56 +01:00
Cedric Beck
997c4c589e removed setOwnColor 2024-12-05 17:23:15 +01:00
Cedric Beck
d14a0aef86 fixed ownColor sync problem 2024-12-05 17:22:37 +01:00
Felix Koppe
ac5d7ed74b Add sounds 2024-12-05 17:11:07 +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
Felix Koppe
4a7c23708c Add jetAnimation 2024-12-05 16:21:13 +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
Felix Koppe
0e6a2499b7 Fix fullscreen issue 2024-12-04 18:38:35 +01:00
Hanno Fleischer
354cdc0a9c added Intro state and its logic 2024-12-04 17:03:57 +01:00
Felix Koppe
00d86c5c10 Improve ceremonyView 2024-12-04 15:33:34 +01:00
Felix Koppe
990e476753 Add Q/E rotation 2024-12-04 15:27:33 +01:00
Felix Koppe
71fc08a05c Add interrupt 2024-12-04 15:11:31 +01:00
Cedric Beck
9e1ca584c7 Merge branch 'development' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development 2024-12-04 13:56:08 +01:00
Cedric Beck
9199fbffd8 removed tests, fixed null exception in CardLayer 2024-12-04 13:56:03 +01:00
Felix Koppe
5c71531277 Merge branch 'development' into dev/client_koppe2 2024-12-04 13:43:33 +01:00
Felix Koppe
6f7c5346d2 Merge commit 2024-12-04 13:34:14 +01:00
Felix Koppe
ef1ce63db6 Try to make server stop on leave 2024-12-04 13:33:39 +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
Cedric Beck
44ef21e6af added handCard Num to playerName display + added remove card in guiHandler 2024-12-04 11:38:35 +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
Felix Koppe
11d6dd4500 Improve video dialog 2024-12-04 10:00:41 +01:00
Felix Koppe
d71f824ca6 Add fullscreen option 2024-12-04 09:41:08 +01:00
Felix Koppe
8e6cb27662 Fix lobbyView ready behavior on tskChange 2024-12-04 07:53:18 +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
Hanno Fleischer
7053b163e5 adjusted LobbyState in the client to use the correct Data 2024-12-03 18:19:55 +01:00
Hanno Fleischer
81cb2f33ff adjusted all constuctors of nodes so that if someone creates a node the piece will be null and the option for a constuctor without arguments is still given for serialization purposes 2024-12-03 17:56:39 +01:00
Hanno Fleischer
69865bb504 added the playeringamenotification to be created from the right dataset 2024-12-03 16:48:08 +01:00
Felix Koppe
db50986f3f Fix serialisation issue 2024-12-03 15:38:13 +01:00
Felix Koppe
a0a088a0c4 Fix minor error in notification processing 2024-12-03 15:00:00 +01:00
Cedric Beck
c4d11ff961 added window title 2024-12-03 09:15:14 +01:00
Daniel Grigencha
bb51976127 Updated 'Node' class.
Updated the 'Node' class by overload the 'isOccupied' method in it.
2024-12-03 04:57:30 +01:00
Daniel Grigencha
0db1f08f3c Updated abstract 'GameAutomatonState' class.
Updated the abstract 'GameAutomatonState' class by adding the 'getGameAutomaton' method to it.
2024-12-03 04:49:16 +01:00
Daniel Grigencha
336f1ec316 Updated 'Resources' class.
Updated the 'Resources' class by adding the 'MAX_EYES' constant to it.
2024-12-03 04:29:16 +01:00
Daniel Grigencha
a1e687912a Updated abstract 'TurnAutomatonState' class.
Updated the abstract 'TurnAutomatonState' class by adding the 'getTurnAutomaton' method to it.
2024-12-03 04:09:35 +01:00
Daniel Grigencha
2248d044c1 Updated 'AnimationState' class.
Updated the 'AnimationState' class by updating the content inside the 'received(AnimationEndMessage msg, int from) method in it.
2024-12-03 03:41:58 +01:00
Daniel Grigencha
79bf1c16e8 Updated 'Game' class.
Updated the 'Game' class by adding the 'getActivePlayerId' method to it.
2024-12-03 03:40:24 +01:00
Daniel Grigencha
3353a890d3 Updated 'Game' class.
Updated the 'Game' class by adding the 'getPlayerIdByColor' method to it.
2024-12-03 03:36:22 +01:00
Daniel Grigencha
a012402a85 Updated abstract 'TurnAutomatonState' class.
Updated the abstract 'TurnAutomatonState' class by updating the JavaDoc text of the constructor.
2024-12-03 02:15:10 +01:00
Daniel Grigencha
5aaf8d4850 Updated 'TurnState' class.
Updated the 'TurnState' class by setting the start state in it.
2024-12-03 01:31:22 +01:00
Daniel Grigencha
35ab777f04 Updated 'DetermineStartPlayerState' class.
Updated the 'DetermineStartPlayerState' class by fixing the logic inside the received(RequestDieMessage msg, int from)' method in it.
2024-12-03 01:30:39 +01:00
Daniel Grigencha
c707abc465 Updated 'Die' class.
Updated the 'Die' class by adding another constructor for test cases to it.
2024-12-03 01:04:02 +01:00
Daniel Grigencha
2a84e7cf65 Updated 'Player' class.
Updated the 'Player' class by moving all content of 'PlayerData' class in 'Player' class.
2024-12-03 00:51:45 +01:00
Daniel Grigencha
3a02edb944 Updated 'PlayerData' class.
Updated the 'PlayerData' class by updating the 'Piece' creation inside the constructor.
2024-12-03 00:50:53 +01:00
Daniel Grigencha
1870d4fe0e Updated 'ShieldState' enumeration.
Updated the 'ShieldState' enumeration by removing unused methods from it.
2024-12-03 00:49:09 +01:00
Daniel Grigencha
5cf9746931 Updated 'PieceState' enumeration.
Updated the 'PieceState' enumeration by removing unused methods from it.
2024-12-03 00:48:39 +01:00
Daniel Grigencha
5b9bc7aa36 Updated 'Piece' class.
Updated the 'Piece' class by removing the unused 'id' parameter from the constructor.
2024-12-03 00:38:24 +01:00
Daniel Grigencha
abe66aff5d Updated 'LobbyState' class.
Updated 'LobbyState' class by removed unused imports in it.
2024-12-03 00:37:24 +01:00
Fleischer Hanno
eea566cc8b added the logic for server shutdown 2024-12-02 23:25:54 +01:00
Daniel Grigencha
bd07a44607 Merge branch 'development' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development 2024-12-02 23:24:02 +01:00
Daniel Grigencha
1f64676d31 Updated 'MdgaServer' class.
Updated the 'MdgaServer' class by adding the 'shutdown' message to it.
2024-12-02 23:23:56 +01:00
Daniel Grigencha
838f59b9aa Updated 'ServerState' class.
Updated the 'ServerState' class by filling the 'received(LeaveGameMessage msg, int from)' in it.
2024-12-02 23:22:45 +01:00
Daniel Grigencha
002a42be38 Updated 'LobbyState' class.
Updated the 'LobbyState' class by removing the 'received(LeaveGameMessage msg, int from)' from it.
2024-12-02 23:21:42 +01:00
Daniel Grigencha
a1d10521ac Updated 'ServerSener' interface.
Updated the 'ServerSender' interface by adding the 'shutdown' method to it.
2024-12-02 23:14:29 +01:00
Fleischer Hanno
4e6a272e7a added that when the client is in the game state and recieves the ceremony message it always changes to ceremony state 2024-12-02 23:08:56 +01:00
Daniel Grigencha
516848a67e Merge branch 'development' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development 2024-12-02 23:06:49 +01:00
Daniel Grigencha
659d69d3eb Updated 'GameState' class.
Updated the 'GameState' class by sending a broadcast message after a player left the game and only one player is remaining.
2024-12-02 23:06:44 +01:00
Daniel Grigencha
fb6cbeaaf5 Updated 'ServerStartGameMessage' class.
Updated the 'ServerStartGameMessage' class by adding the 'board' attribute and its getter method to it.
2024-12-02 23:00:39 +01:00
Cedric Beck
25f750c8b6 Merge branch 'development' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development 2024-12-02 22:58:58 +01:00
Cedric Beck
3f49b432c4 added SSAO and FXAA 2024-12-02 22:58:52 +01:00
Daniel Grigencha
252c37ae9a Updated 'LobbyState' class.
Updated the 'LobbyState' class by sending the 'ServerStartGameMessage' with a 'Board' object.
2024-12-02 22:58:46 +01:00
Fleischer Hanno
4566d4c9a8 Merge remote-tracking branch 'origin/development' into development 2024-12-02 22:46:12 +01:00
Fleischer Hanno
e9ba888651 changed the logic so that the isHost is not decided by the client and instead by the server 2024-12-02 22:45:44 +01:00
Cedric Beck
cbbb98037b Merge branch 'development' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development 2024-12-02 22:43:16 +01:00
Cedric Beck
aa651ec62f added trees 2024-12-02 22:43:03 +01:00
Daniel Grigencha
e163b87cc4 Updated 'MdgaServer' class.
Updated the 'MdgaServer' class by updating the logic inside the 'connectionAdded' method in it.
2024-12-02 22:41:17 +01:00
Daniel Grigencha
1eb24b7a66 Updated 'MdgaServer' class.
Updated the 'MdgaServer' class by updating the logic inside the 'connectionAdded' method in it.
2024-12-02 22:37:46 +01:00
Daniel Grigencha
492f7422f5 Updated 'LobbyAcceptMessage' class.
Updated the 'LobbyAcceptMessage' class by adding the 'host' attribute and its getter method to it.
2024-12-02 22:36:48 +01:00
Daniel Grigencha
27f8af70f5 Updated 'Game' class.
Updated the 'Game' class by setting the default value of 'host' attribute. In Addition, the 'isHost' method was added.
2024-12-02 22:34:45 +01:00
Fleischer Hanno
5910fcc701 added the client logic to receive the LobbyAccept and LobbyDeny message 2024-12-02 21:52:07 +01:00
Felix Koppe
e94ed1e019 Fix syntax error 2024-12-02 21:51:09 +01:00
Felix Koppe
7d54a906dd Add some more names 2024-12-02 21:48:23 +01:00
Felix Koppe
5ae65921bf Add more random names 2024-12-02 21:42:12 +01:00
Daniel Grigencha
468e4005dc Updated 'LobbyState' class.
Updated the 'LobbyState' class by sending a broadcast update the new ready state of the client.
2024-12-02 21:23:53 +01:00
Daniel Grigencha
72321eab9a Updated 'LobbyState' class.
Updated the 'LobbyState' class by updating all received methods in it.
2024-12-02 21:22:49 +01:00
Daniel Grigencha
951c92d890 Merge branch 'development' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development 2024-12-02 21:12:03 +01:00
Felix Koppe
e87eb569c2 Add showInfo to MdgaView 2024-12-02 21:16:50 +01:00
Felix Koppe
baa967ecfc Merge commit 2024-12-02 21:12:56 +01:00
Felix Koppe
8d39d61c71 Add infoNotification 2024-12-02 21:12:43 +01:00
Daniel Grigencha
7fcee3cac0 Updated 'MdgaServer' class.
Updated the 'MdgaServer' class by register the 'IncorrectRequestMessage' class to the serializer.
2024-12-02 21:11:59 +01:00
Daniel Grigencha
06d4b322e7 Merge branch 'development' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development 2024-12-02 21:04:41 +01:00
Daniel Grigencha
1cf14f65bb Updated 'MdgaServer' class.
Updated the 'MdgaServer' class by updating the 'connectionAdded' method in it. In Addition, the JavaDoc text for this method was addded.
2024-12-02 21:04:36 +01:00
Fleischer Hanno
ebb9f839c7 added JavaDocs in Resources.java 2024-12-02 20:58:00 +01:00
Daniel Grigencha
3eef4b2a02 Updated 'PlayerData' class.
Updated the 'PlayerData' class by replacing the magic constants with the 'Resources' class. In Addition, some JavaDoc texts were updated.
2024-12-02 20:56:59 +01:00
Daniel Grigencha
c1fa679261 Updated 'Resources' class.
Updated the 'Resources' class by adding the 'MAX_PIECES' constant to it.
2024-12-02 20:45:07 +01:00
Daniel Grigencha
c48f924ead Updated 'Resources' class.
Updated the 'Resources' class by adding the 'MAX_PLAYERS' constant to it.
2024-12-02 20:43:47 +01:00
Fleischer Hanno
73859d8c81 added methods for getting Boolean, String, Double and int 2024-12-02 20:34:52 +01:00
Felix Koppe
1918aa80ff Merge commit 2024-12-02 20:33:36 +01:00
Felix Koppe
d062b9dabc Add forceStartGameButton to host in lobby 2024-12-02 20:32:46 +01:00
Fleischer Hanno
7ddcdc3f48 added the first error.messages and adjusted 2024-12-02 20:24:17 +01:00
Fleischer Hanno
2cefc2c293 Merge remote-tracking branch 'origin/development' into development 2024-12-02 20:19:44 +01:00
Daniel Grigencha
c4304ae99a Updated 'Game' class.
Updated the 'Game' class by removing the 'allReady' attribute in it. In Addtion, the 'areAllReady' method was added.
2024-12-02 20:19:13 +01:00
Fleischer Hanno
005df94114 added Resources calss to access teh properties 2024-12-02 19:55:18 +01:00
Daniel Grigencha
44f893ccef Updated 'Game' class.
Updated the 'Game' class by setting the 'die' attribute correctly inside the constructor.
2024-12-02 19:45:11 +01:00
Daniel Grigencha
0d9a922f55 Removed 'PlayerDataMessage' and 'StartBriefingMessage'. 2024-12-02 19:16:01 +01:00
Daniel Grigencha
289158cf35 Updated 'MdgaServer' class.
Updated the 'MdgaServer' class by removing the 'PlayerDataMessage' and 'StartBriefingMessage' from the serializer.
2024-12-02 19:14:11 +01:00
Fleischer Hanno
0a0762b6c9 removed all instances of PlayerDataMEssage and StartBriefingMessage 2024-12-02 19:07:58 +01:00
Fleischer Hanno
90a21087df added logic for incorrectRequest message and removed messages playerdata and startbriefing and created javadocs 2024-12-02 19:02:00 +01:00
Daniel Grigencha
294ecdc56f Updated 'IncorrectRequestMessage' class.
Updated the 'IncorrectRequestMessage' class by updating the content inside the 'accept' method in it.
2024-12-02 19:00:21 +01:00
Daniel Grigencha
347ed152b8 Added 'IncorrectRequestMessage' class.
Added the 'IncorrectRequestMessage' class to this project. It will be used to send the client an incorrect request message to show they did something wrong.
2024-12-02 18:58:15 +01:00
Daniel Grigencha
3daafde9f1 Updated 'ServerInterpreter' class.
Updated the 'ServerInterpreter' class by adding the 'received(IncorrectRequestMessage msg)' method to it.
2024-12-02 18:50:42 +01:00
Daniel Grigencha
09fda6b167 Updated 'Game' class.
Updated the 'Game' class by adding the 'isColorTaken' method to it.
2024-12-02 18:18:04 +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
197 changed files with 10814 additions and 1941 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
.run/
.gradle
build/
#!gradle/wrapper/gradle-wrapper.jar

View File

@@ -16,4 +16,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>

View File

@@ -30,15 +30,16 @@ public enum Asset {
tank,
world(1.2f),
shieldRing("Models/shieldRing/shieldRing.j3o", null),
treeSmall,
treeBig,
treeSmall(1.2f),
treeBig(1.2f),
turboCard,
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.j3o"),
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.png"),
swapCard,
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.j3o"),
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
shieldCard,
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.j3o"),
dice
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
dice,
missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
;
private final String modelPath;

View File

@@ -27,6 +27,7 @@
import pp.mdga.notification.SelectableCardsNotification;
import java.util.List;
import java.util.UUID;
public class InputSynchronizer {
@@ -39,6 +40,11 @@ public class InputSynchronizer {
private CardControl hoverCard;
private PieceControl hoverPiece;
private boolean clickAllowed = true;
private boolean isRotateLeft = false;
private boolean isRotateRight = false;
/**
* Constructor initializes the InputSynchronizer with the application context.
* Sets up input mappings and listeners for user interactions.
@@ -54,6 +60,18 @@ public class InputSynchronizer {
setupInput();
}
public void update(float tpf) {
if(isRotateLeft && isRotateRight) {
return;
}
if(isRotateLeft) {
rotationAngle += 180 * tpf;
}
if(isRotateRight) {
rotationAngle -= 180 * tpf;
}
}
/**
* Configures input mappings for various actions and binds them to listeners.
*/
@@ -61,22 +79,22 @@ private void setupInput() {
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_Q));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_E));
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
inputManager.addMapping("MouseVertical", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new MouseAxisTrigger(MouseInput.AXIS_Y, true)); //Mouse Up Down movement
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Test");
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Left", "Right", "Test");
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
}
private boolean test = false;
UUID p = null;
/**
* Handles action-based input events such as key presses and mouse clicks.
*/
@@ -93,6 +111,10 @@ public void onAction(String name, boolean isPressed, float tpf) {
rightMousePressed = isPressed;
}
if(name.equals("Click") && isPressed) {
if(!clickAllowed) {
return;
}
if (app.getView() instanceof GameView gameView) {
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
@@ -121,13 +143,40 @@ else if(boardSelect != null) {
}
if(name.equals("Test") &&isPressed){
if (name.equals("Left")) {
isRotateLeft = !isRotateLeft;
}
if (name.equals("Right")) {
isRotateRight = !isRotateRight;
}
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);
} else {
gameView.getBoardHandler().throwMissileAnim(p);
//gameView.getBoardHandler().movePieceStartAnim(p,0);
}
// gameView.getGuiHandler().rollRankingResult(Color.AIRFORCE, 1);
// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
gameView.getGuiHandler().showDice();
// gameView.getGuiHandler().showDice();
// UUID p1 = UUID.randomUUID();
// gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p1,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
// gameView.getBoardHandler().movePieceStartAnim(p1,0);
//gameView.getGuiHandler().drawCard(Color.ARMY);
//gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
//gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD);
}
}
}
@@ -302,4 +351,12 @@ public void setRotation(float rotationAngle){
public int getScroll() {
return scrollValue;
}
public void setClickAllowed(boolean allowed) {
clickAllowed = allowed;
}
public boolean isClickAllowed() {
return clickAllowed;
}
}

View File

@@ -1,13 +1,19 @@
package pp.mdga.client;
import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import com.simsilica.lemur.GuiGlobals;
import com.sun.tools.javac.Main;
import pp.mdga.client.acoustic.AcousticHandler;
import com.jme3.system.AppSettings;
import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.view.*;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.prefs.Preferences;
@@ -39,19 +45,19 @@ public class MdgaApp extends SimpleApplication {
private MdgaState state = null;
/** Scale for rendering images. */
private float imageScale = prefs.getInt("scale", 1);
private final float imageScale = prefs.getInt("scale", 1);
/** The main menu view. */
private MdgaView mainView;
private MainView mainView;
/** The lobby view. */
private MdgaView lobbyView;
private LobbyView lobbyView;
/** The game view. */
private MdgaView gameView;
private GameView gameView;
/** The ceremony view. */
private MdgaView ceremonyView;
private CeremonyView ceremonyView;
/** The client game logic. */
private final ClientGameLogic clientGameLogic;
@@ -60,7 +66,7 @@ public class MdgaApp extends SimpleApplication {
private ServerConnection networkConnection;
private MdgaApp() {
public MdgaApp() {
networkConnection = new NetworkSupport(this);
this.clientGameLogic = new ClientGameLogic(networkConnection);
}
@@ -74,15 +80,30 @@ private MdgaApp() {
public static void main(String[] args) {
AppSettings settings = new AppSettings(true);
settings.setSamples(128);
settings.setWidth(prefs.getInt("width", 1280));
settings.setHeight(prefs.getInt("height", 720));
if(prefs.getBoolean("fullscreen", false)) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = (int) screenSize.getWidth();
int screenHeight = (int) screenSize.getHeight();
settings.setResolution(screenWidth, screenHeight);
settings.setFullscreen(true);
} else {
settings.setWidth(prefs.getInt("width", 1280));
settings.setHeight(prefs.getInt("height", 720));
}
settings.setCenterWindow(true);
settings.setVSync(false);
settings.setTitle("MDGA");
settings.setVSync(true);
MdgaApp app = new MdgaApp();
app.setSettings(settings);
app.setShowSettings(false);
app.setPauseOnLostFocus(false);
app.setDisplayStatView(false);
app.start();
}
@@ -120,6 +141,7 @@ public void simpleUpdate(float tpf) {
view.update(tpf);
acousticHandler.update();
notificationSynchronizer.update();
inputSynchronizer.update(tpf);
}
/**
@@ -245,30 +267,60 @@ public ServerConnection getNetworkSupport(){
return networkConnection;
}
public void updateResolution(int width, int height, float imageFactor) {
prefs.putInt("width", width);
prefs.putInt("height", height);
prefs.putFloat("scale", imageFactor);
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
if(isFullscreen) {
int baseWidth = 1280;
int baseHeight = 720;
float baseAspectRatio = (float) baseWidth / baseHeight;
float newAspectRatio = (float) width / height;
try {
restartApp();
} catch (Exception e) {
//nothing
float scaleFactor = Math.max((float) width / baseWidth, (float) height / baseHeight);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = (int) screenSize.getWidth();
int screenHeight = (int) screenSize.getHeight();
settings.setResolution(screenWidth, screenHeight);
settings.setFullscreen(true);
prefs.putFloat("scale", scaleFactor);
prefs.putBoolean("fullscreen", true);
} else {
prefs.putInt("width", width);
prefs.putInt("height", height);
prefs.putFloat("scale", imageFactor);
prefs.putBoolean("fullscreen", false);
}
}
public static void restartApp() throws IOException {
String javaBin = System.getProperty("java.home") + "/bin/java";
String classPath = System.getProperty("java.class.path");
String className = System.getProperty("sun.java.command");
public static void restartApp() {
try {
String javaBin = System.getProperty("java.home") + "/bin/java";
String classPath = System.getProperty("java.class.path");
String className = System.getProperty("sun.java.command");
ProcessBuilder builder = new ProcessBuilder(
javaBin, "-cp", classPath, className
);
ProcessBuilder builder = new ProcessBuilder(
javaBin, "-cp", classPath, className
);
builder.start();
builder.start();
System.exit(0);
System.exit(0);
} catch (Exception e) {
throw new RuntimeException("restart failed");
}
}
public void afterGameCleanup() {
MainView main = (MainView) mainView;
main.getJoinDialog().disconnect();
main.getHostDialog().shutdownServer();
ceremonyView.afterGameCleanup();
}
public GameView getGameView(){
return gameView;
}
}

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();
}
}
@@ -87,20 +88,23 @@ public void confirm() {
GameView gameView = (GameView) app.getView();
if(a != null && b != null) {
selectPiece(a);
selectPiece(b);
app.getGameLogic().selectPiece(a);
app.getGameLogic().selectPiece(b);
gameView.getBoardHandler().clearSelectable();
} else if (a != null) {
selectPiece(a);
app.getGameLogic().selectPiece(a);
gameView.getBoardHandler().clearSelectable();
} else if (card != null){
selectCard(card);
gameView.getGuiHandler().clearSelectableCards();
} else {
throw new RuntimeException("nothing to confirm");
if(null == card) {
app.getGameLogic().selectCard(null);
} else {
app.getGameLogic().selectCard(card);
gameView.getGuiHandler().clearSelectableCards();
}
}
gameView.noConfirm();
gameView.noNoPower();
}
public void selectTsk(Color color) {
@@ -145,4 +149,8 @@ public void enter(MdgaState state) {
public void setSwap(boolean swap){
this.swap = swap;
}
public void force() {
}
}

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;
@@ -19,39 +20,44 @@ public class NotificationSynchronizer {
this.app = app;
}
public void addTestNotification(Notification n) {
notifications.add(n);
handleGame(n);
}
public void update() {
Notification n = app.getGameLogic().getNotification();
if(n != null) {
switch (app.getState()) {
case MAIN:
handleMain(n);
break;
case LOBBY:
handleLobby(n);
break;
case GAME:
handleGame(n);
break;
case CEREMONY:
handleCeremony(n);
break;
case NONE:
throw new RuntimeException("no notification expected: " + n.toString());
while (n != null) {
if(n instanceof InfoNotification infoNotification) {
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
return;
}
if(n != null) {
switch (app.getState()) {
case MAIN:
handleMain(n);
break;
case LOBBY:
handleLobby(n);
break;
case GAME:
handleGame(n);
break;
case CEREMONY:
handleCeremony(n);
break;
case NONE:
throw new RuntimeException("no notification expected: " + n.getClass().getName());
}
}
n = app.getGameLogic().getNotification();
}
}
private void handleMain(Notification notification) {
if (notification instanceof LobbyDialogNotification) {
app.enter(MdgaState.LOBBY);
} else if (notification instanceof StartDialogNotification) {
//nothing
} else {
throw new RuntimeException("notification not expected: ");
throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName());
}
}
@@ -61,16 +67,17 @@ private void handleLobby(Notification notification) {
if (notification instanceof TskSelectNotification n) {
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
} else if (notification instanceof StartDialogNotification) {
app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else if (notification instanceof TskUnselectNotification n) {
lobbyView.setTaken(n.getColor(), false, false, null);
} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady());
} else if (notification instanceof GameNotification n) {
app.getGameView().setOwnColor(n.getOwnColor());
app.enter(MdgaState.GAME);
((GameView) app.getView()).setOwnColor(n.getOwnColor());
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
throw new RuntimeException("notification not expected in lobby: " + notification.getClass().getName());
}
}
@@ -81,10 +88,12 @@ private void handleGame(Notification notification) {
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
if (notification instanceof AcquireCardNotification n) {
guiHandler.addCard(n.getBonusCard());
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();
@@ -119,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) {
app.enter(MdgaState.LOBBY);
} else if (notification instanceof InterruptNotification notification1) {
gameView.enterInterrupt(notification1.getColor());
} else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) {
//StartMove
@@ -132,21 +141,17 @@ private void handleGame(Notification notification) {
}
guiHandler.hideText();
} else if (notification instanceof ThrowPieceNotification n) {
boardHandler.throwPieceAnim(n.getPieceId());
boardHandler.throwBombAnim(n.getPieceId());
} else if (notification instanceof NoShieldNotification n) {
boardHandler.unshieldPiece(n.getPieceId());
} else if (notification instanceof PlayCardNotification n) {
switch(n.getCard()){
case SWAP -> guiHandler.swap();
case TURBO -> guiHandler.turbo();
case SHIELD -> guiHandler.shield();
default -> throw new RuntimeException("invalid card");
}
if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
} else if (notification instanceof PlayerInGameNotification n) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) {
//TODO
gameView.leaveInterrupt();
} else if (notification instanceof RollDiceNotification n) {
gameView.getGuiHandler().hideText();
if(n.getColor() == gameView.getOwnColor()){
@@ -159,11 +164,13 @@ 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) {
boardHandler.suppressShield(n.getPieceId());
} else if (notification instanceof StartDialogNotification) {
app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else if (notification instanceof SwapPieceNotification n) {
// boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
@@ -184,15 +191,16 @@ private void handleGame(Notification notification) {
} else if (notification instanceof FinishNotification n){
guiHandler.finish(n.getColorFinished());
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
throw new RuntimeException("notification not expected in game: " + notification.getClass().getName());
}
}
private void handleCeremony(Notification notification) {
if (notification instanceof StartDialogNotification) {
app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
throw new RuntimeException("notification not expected in ceremony: " + notification.getClass().getName());
}
}
}

View File

@@ -109,6 +109,29 @@ public void playSound(MdgaSound sound) {
case LEAVE:
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_SOUND2, 0.6f, 0.0f));
break;
case JET:
assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
break;
case EXPLOSION:
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));
break;
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

@@ -31,4 +31,11 @@ public enum MdgaSound {
OTHER_CONNECTED,
NOT_READY,
LEAVE,
JET,
EXPLOSION,
LOSE,
BONUS,
UI90,
MISSILE,
MATRIX,
}

View File

@@ -28,6 +28,15 @@ enum SoundAsset {
POWERUP("powerup.wav"),
ROBOT_READY("robotReady.wav"),
UNIT_READY("unitReady.wav"),
JET("jet-overhead.wav"),
EXPLOSION_1("exp.ogg"),
EXPLOSION_2("exp2.ogg"),
THUNDER("thunder.ogg"),
UI90("ui90.ogg"),
BONUS("bonus.ogg"),
LOSE("lose.ogg"),
MISSILE("missile.ogg"),
MATRIX("matrix.wav"),
CONNECTED("connected.wav");
private final String path;

View File

@@ -0,0 +1,125 @@
package pp.mdga.client.animation;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh.Type;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
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 {
private final Node rootNode;
private final MdgaApp app;
private final Vector3f location;
private ParticleEmitter fire;
private ParticleEmitter smoke;
private boolean triggered = false;
private final Material mat;
/**
* Konstruktor für die Explosion.
*
* @param app Die Hauptanwendung.
* @param rootNode Der Root-Knoten, an den die Explosion angefügt wird.
* @param location Der Ort der Explosion in World-Koordinaten.
*/
public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
this.app = app;
this.rootNode = rootNode;
this.location = location;
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
}
/**
* Initialisiert den Partikel-Emitter für die Explosion.
*/
private void initializeEmitter() {
fire = new ParticleEmitter("Effect", Type.Triangle,50);
fire.setMaterial(mat);
fire.setStartColor(ColorRGBA.Yellow);
fire.setEndColor(ColorRGBA.Red);
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
fire.getParticleInfluencer().setVelocityVariation(0.4f);
fire.setStartSize(0.1f);
fire.setEndSize(0.8f);
fire.setGravity(0, 0, -0.1f);
fire.setLowLife(0.5f);
fire.setHighLife(2.2f);
fire.setParticlesPerSec(0);
fire.setLocalTranslation(location);
smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
smoke.setMaterial(mat);
smoke.setImagesX(2);
smoke.setImagesY(2);
smoke.setStartColor(ColorRGBA.DarkGray);
smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.7f));
smoke.getParticleInfluencer().setVelocityVariation(0.5f);
smoke.setStartSize(0.2f);
smoke.setEndSize(0.5f);
smoke.setGravity(0, 0, -0.3f);
smoke.setLowLife(1.2f);
smoke.setHighLife(5.5f);
smoke.setParticlesPerSec(0);
smoke.setLocalTranslation(location);
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
}
/**
* Löst die Explosion aus.
*/
public void trigger() {
if (!triggered) {
triggered = true;
initializeEmitter();
}
rootNode.attachChild(fire);
fire.emitAllParticles();
fire.addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
if (elapsedTime > 10f) {
rootNode.detachChild(fire);
fire.removeControl(this);
}
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
});
rootNode.attachChild(smoke);
smoke.emitAllParticles();
smoke.addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
if (elapsedTime > 10f) {
rootNode.detachChild(smoke);
smoke.removeControl(this);
}
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
});
}
}

View File

@@ -0,0 +1,173 @@
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 pp.mdga.client.view.GameView;
import java.util.UUID;
public class JetAnimation {
private final MdgaApp app; // Referenz auf die Hauptanwendung
private final Node rootNode; // Root-Knoten, an dem die Animation hängt
private Spatial jetModel; // Das Model des "jet"
private final Vector3f spawnPoint; // Spawnpunkt des Jets
private final Vector3f nodePoint; // Punkt des überflogenen Knotens
private final Vector3f despawnPoint; // Punkt, an dem der Jet despawnt
private final float curveHeight; // Maximale Höhe der Kurve
private final float animationDuration; // Dauer der Animation
private Explosion explosion;
private final UUID id;
/**
* Konstruktor für die ThrowAnimation-Klasse.
*
* @param app Die Hauptanwendung
* @param rootNode Der Root-Knoten, an dem der Jet angefügt wird
* @param uuid Die UUID des pieces
* @param targetPoint Der Punkt, an dem der Jet spawnt
* @param curveHeight Die maximale Höhe der Flugkurve
* @param animationDuration Die Gesamtdauer der Animation in Sekunden
*/
public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration) {
Vector3f spawnPoint = targetPoint.add(170, 50, 50);
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
Vector3f despawnPoint = targetPoint.add(-100, -100, 40);
this.app = app;
this.rootNode = rootNode;
this.spawnPoint = spawnPoint;
this.nodePoint = controlPoint;
this.despawnPoint = despawnPoint;
this.curveHeight = curveHeight;
this.animationDuration = animationDuration;
id = uuid;
explosion = new Explosion(app, rootNode, targetPoint);
}
/**
* Startet die Animation.
*/
public void start() {
app.getAcousticHandler().playSound(MdgaSound.JET);
spawnJet();
animateJet();
}
/**
* Spawnt den Jet an der spezifizierten Position.
*/
private void spawnJet() {
jetModel = app.getAssetManager().loadModel(Asset.jet.getModelPath());
jetModel.setLocalTranslation(spawnPoint);
jetModel.scale(Asset.jet.getSize());
jetModel.rotate(FastMath.HALF_PI, 0, 0);
jetModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.jet.getDiffPath()));
jetModel.setMaterial(mat);
rootNode.attachChild(jetModel);
}
/**
* Animiert den Jet entlang einer Kurve und lässt ihn anschließend verschwinden.
*/
private void animateJet() {
Vector3f controlPoint1 = spawnPoint.add(0, curveHeight, 0);
Vector3f controlPoint2 = nodePoint.add(0, curveHeight, 0);
BezierCurve3f curve = new BezierCurve3f(spawnPoint, controlPoint1, controlPoint2, despawnPoint);
app.getRootNode().addControl(new AbstractControl() {
private float elapsedTime = 0;
@Override
protected void controlUpdate(float tpf) {
elapsedTime += tpf;
float progress = elapsedTime / animationDuration;
if(elapsedTime > 4.2f) {
explosion.trigger();
}
if (progress > 1) {
rootNode.detachChild(jetModel);
this.spatial.removeControl(this);
} else {
Vector3f currentPos = curve.interpolate(progress);
Vector3f direction = curve.interpolateDerivative(progress).normalizeLocal();
jetModel.setLocalTranslation(currentPos);
jetModel.lookAt(currentPos.add(direction), Vector3f.UNIT_Z);
jetModel.rotate(-FastMath.HALF_PI, 0, (float) Math.toRadians(-25));
}
if (elapsedTime > 6.0f) {
GameView gameView = (GameView) app.getView();
BoardHandler boardHandler = gameView.getBoardHandler();
boardHandler.throwPieceAnim(id);
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// Wird hier nicht benötigt
}
});
}
/**
* Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
*/
private static class BezierCurve3f {
private final Vector3f p0, p1, p2, p3;
public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
this.p0 = p0;
this.p1 = p1;
this.p2 = p2;
this.p3 = p3;
}
public Vector3f interpolate(float t) {
float u = 1 - t;
float tt = t * t;
float uu = u * u;
float uuu = uu * u;
float ttt = tt * t;
Vector3f point = p0.mult(uuu);
point = point.add(p1.mult(3 * uu * t));
point = point.add(p2.mult(3 * u * tt));
point = point.add(p3.mult(ttt));
return point;
}
public Vector3f interpolateDerivative(float t) {
float u = 1 - t;
float tt = t * t;
Vector3f derivative = p0.mult(-3 * u * u);
derivative = derivative.add(p1.mult(3 * u * u - 6 * u * t));
derivative = derivative.add(p2.mult(6 * u * t - 3 * tt));
derivative = derivative.add(p3.mult(3 * tt));
return derivative;
}
}
}

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

@@ -9,10 +9,12 @@
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.animation.MissileAnimation;
import pp.mdga.client.animation.MoveControl;
import pp.mdga.client.animation.JetAnimation;
import pp.mdga.client.gui.DiceControl;
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import java.util.*;
@@ -200,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);
}
@@ -443,6 +445,7 @@ private void throwPiece(UUID uuid){
// Synchronisation oder Animation
pieceControl.rotateInit();
app.getAcousticHandler().playSound(MdgaSound.LOSE);
app.getModelSynchronize().animationEnd();
}
@@ -720,10 +723,32 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
*/
public void throwPieceAnim(UUID uuid){
pieces.get(uuid).getSpatial().addControl(new MoveControl(
pieces.get(uuid).getLocation(),
getNextWaitingNode(pieceColor.get(uuid)).getLocation(),
()->throwPiece(uuid)
));
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), ()->throwPiece(uuid))
);
}
/**
* 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
*/
public void throwBombAnim(UUID uuid){
Vector3f targetPoint = pieces.get(uuid).getLocation();
JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6);
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();
}
/**

View File

@@ -7,6 +7,8 @@
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.FXAAFilter;
import com.jme3.post.ssao.SSAOFilter;
import com.jme3.scene.Spatial;
import com.jme3.shadow.DirectionalLightShadowFilter;
import com.jme3.shadow.EdgeFilteringMode;
@@ -37,6 +39,8 @@ public class CameraHandler {
private Color ownColor;
private boolean init;
private boolean initRot;
private SSAOFilter ssaoFilter;
private FXAAFilter fxaaFilter;
/**
* Constructor for the CameraHandler. Initializes the camera settings and lighting.
@@ -65,6 +69,9 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
dlsf.setEnabled(true);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
dlsf.setShadowIntensity(0.7f);
ssaoFilter = new SSAOFilter(6, 10f, 0.33f, 0.61f);
// ssaoFilter = new SSAOFilter();
fxaaFilter = new FXAAFilter();
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);
@@ -82,6 +89,8 @@ public void init(Color ownColor) {
app.getRootNode().addLight(ambient);
app.getRootNode().attachChild(sky);
fpp.addFilter(dlsf);
fpp.addFilter(ssaoFilter);
fpp.addFilter(fxaaFilter);
init = true;
initRot = true;
this.ownColor = ownColor;

View File

@@ -107,8 +107,8 @@ private static Asset getLoadedAsset(String assetName) {
case "radar" -> Asset.radar;
case "ship" -> Asset.ship;
case "tank" -> Asset.tank;
case "tree_small" -> Asset.treeSmall;
case "tree_big" -> Asset.treeBig;
case "treeSmall" -> Asset.treeSmall;
case "treeBig" -> Asset.treeBig;
default -> throw new IllegalStateException("Unexpected value: " + assetName);
};
}

View File

@@ -1,4 +1,63 @@
package pp.mdga.client.dialog;
public class InterruptDialog {
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.ButtonRight;
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 " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
float offset = 2.8f;
label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
}
@Override
protected void onShow() {
if(app.getGameLogic().isHost()) {
forceButton.show();
}
label.show();
}
@Override
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

@@ -92,4 +92,16 @@ public void resetPort() {
public void connectToServer() {
connectServer();
}
public void disconnect() {
NetworkSupport network = getNetwork();
if (network != null) {
try {
network.disconnect();
} catch (Exception e) {
System.err.println("Error while disconnecting: " + e.getMessage());
}
}
}
}

View File

@@ -14,6 +14,8 @@ public abstract class NetworkDialog extends Dialog {
private String hostname;
private int portNumber;
private Future<Object> connectionFuture;
private MdgaServer serverInstance;
private Thread serverThread;
public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
super(app, node);
@@ -28,7 +30,6 @@ public void setPortNumber(int portNumber) {
this.portNumber = portNumber;
}
protected Object initNetwork() {
try {
this.network.initNetwork(this.hostname, this.portNumber);
@@ -39,25 +40,49 @@ protected Object initNetwork() {
}
protected void connectServer() {
try {
connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
} catch (NumberFormatException var2) {
throw new NumberFormatException("Port must be a number");
}
}
protected void startServer() {
(new Thread(() -> {
serverThread = new Thread(() -> {
try {
MdgaServer mdgaServer = new MdgaServer(portNumber);
mdgaServer.run();
serverInstance = new MdgaServer(portNumber);
serverInstance.run();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
})).start();
serverThread.start();
}
public void shutdownServer() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.err.println("Thread was interrupted: " + e.getMessage());
}
if (serverInstance != null) {
serverInstance.shutdown();
serverInstance = null;
}
if (serverThread != null && serverThread.isAlive()) {
serverThread.interrupt();
try {
serverThread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
serverThread = null;
}
}
public void update(float delta) {
@@ -65,14 +90,14 @@ public void update(float delta) {
try {
this.connectionFuture.get();
} catch (ExecutionException ignored) {
// todo: implement
// TODO: implement
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
public NetworkSupport getNetwork(){
public NetworkSupport getNetwork() {
return network;
}
}

View File

@@ -177,6 +177,109 @@ public String getName() {
"CarryPro",
"ProBaiter",
"GameWarden",
"KartoffelKönig",
"SaufenderWolf",
"WurstGriller",
"Flitzekacke",
"BratwurstBub",
"Hoppeldoppels",
"BananenMensch",
"KlopapierGuru",
"SchnitzelKing",
"NerdNomade",
"Dönertänzer",
"GlitzerGurke",
"SchinkenShrek",
"KäseKalle",
"SchokoSchnecke",
"KeksKämpfer",
"QuarkPiraten",
"Müslimonster",
"KnuddelNase",
"FantaFighter",
"SchnapsSaurier",
"Wackelpudding",
"ZitronenZock",
"FettWurst",
"PlüschPanda",
"Zuckerschnur",
"FluffiKopf",
"DonutDöner",
"VollpfostenX",
"Schraubenschlüssel",
"Witzepumper",
"ToastTraum",
"FroschFighter",
"KrümelTiger",
"RegenWolke",
"PuddingPower",
"KoffeinKrieger",
"SpeckSchlumpf",
"SuperSuppe",
"BierBärchen",
"FischBär",
"Flauschi",
"Schokomonster",
"ChaosKäse",
"FlitzLappen",
"WurstWombat",
"KrümelMensch",
"PuddingBär",
"ZickZack",
"Schwabel",
"Fluffi",
"RülpsFrosch",
"PommesPapa",
"QuarkBär",
"KnusperKönig",
"ToastBrot",
"Ploppster",
"Schleimschwein",
"Äpfelchen",
"Knallbonbon",
"KaffeeKopf",
"WackelWurst",
"RennKeks",
"BröselBub",
"ZockerBrot",
"BierWurm",
"StinkFlummi",
"SchlumpfKing",
"PurzelBär",
"FlinkFluff",
"PloppPudel",
"Schnorchel",
"FliegenKopf",
"PixelPommes",
"SchwipsWürst",
"WutzBär",
"KnuddelKeks",
"FantaFlumm",
"ZockerKäse",
"LachHäufchen",
"GurkenGuru",
"PonySchnitzel",
"NudelNinja",
"VulkanKeks",
"WasserToast",
"MenschSalat",
"KampfKohlenhydrate",
"SockenZirkus",
"SchwimmBärchen",
"TanzenderDachgepäckträger",
"PizzamarktMensch",
"ZahnarztZocker",
"RollerCoasterTester",
"WaschmaschinenPilot",
"WitzigeZwiebel",
"Pillenschlucker",
"ZwiebelReiter",
"HüpfenderKaktus",
"KochenderAsteroid",
"ChaosKarotte",
"WolkenFurz",
"SchnitzelPartikel",
"WackelBiene",
};
Random random = new Random();

View File

@@ -3,13 +3,20 @@
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView;
import java.util.prefs.Preferences;
public class VideoSettingsDialog extends Dialog {
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
private ButtonRight fullscreenButton;
private MenuButton backButton;
private ButtonRight restartButton;
private ButtonLeft hdButton9;
private ButtonLeft fullHdButton9;
@@ -29,20 +36,24 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
// MenuButton für verschiedene Auflösungen erstellen
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f), "hd 16:9", 10);
fullHdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1920, 1080, 2.25f), "full hd 16:9", 10);
wqhdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(2560, 1440, 4.0f), "wqhd 16:9", 10);
restartButton = new ButtonRight(app, node, MdgaApp::restartApp, "Neustart", 1);
fullscreenButton = new ButtonRight(app, node, () -> updateResolution(0, 0, 0, true), "Vollbild", 1);
hdButton9 = new ButtonLeft(app, node, () -> updateResolution(1280, 720, 1.0f, false), "hd 16:9", 10);
fullHdButton9 = new ButtonLeft(app, node, () -> updateResolution(1920, 1080, 2.25f, false), "full hd 16:9", 10);
wqhdButton9 = new ButtonLeft(app, node, () -> updateResolution(2560, 1440, 4.0f, false), "wqhd 16:9", 10);
hdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1280, 800, 1.0f), "hd 16:10", 10);
fullHdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1920, 1200, 2.25f), "full hd 16:10", 10);
wqhdButton10 = new ButtonRight(app, node, () -> app.updateResolution(2560, 1600, 4.0f), "wqhd 16:10", 10);
hdButton10 = new ButtonRight(app, node, () -> updateResolution(1280, 800, 1.0f, false), "hd 16:10", 10);
fullHdButton10 = new ButtonRight(app, node, () -> updateResolution(1920, 1200, 2.25f, false), "full hd 16:10", 10);
wqhdButton10 = new ButtonRight(app, node, () -> updateResolution(2560, 1600, 4.0f, false), "wqhd 16:10", 10);
float offset = 2.8f;
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
hdButton10.setPos(new Vector2f(hdButton10.getPos().x, MenuButton.VERTICAL - offset));
fullscreenButton.setPos(new Vector2f(fullscreenButton.getPos().x, MenuButton.VERTICAL - offset));
offset += 1.5f;
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
@@ -68,6 +79,7 @@ protected void onShow() {
fullHdButton10.show();
wqhdButton10.show();
fullscreenButton.show();
backButton.show();
}
@@ -83,7 +95,9 @@ protected void onHide() {
fullHdButton10.hide();
wqhdButton10.hide();
fullscreenButton.hide();
backButton.hide();
restartButton.hide();
}
public void update() {
@@ -91,4 +105,12 @@ public void update() {
return;
}
}
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
if(width != prefs.getInt("width", 1280) || height != prefs.getInt("height", 720) || isFullscreen != prefs.getBoolean("fullscreen", false)) {
restartButton.show();
}
app.updateResolution(width, height, imageFactor, isFullscreen);
}
}

View File

@@ -60,7 +60,7 @@ private Node createNum(){
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Black);
circle.setMaterial(mat);
root.attachChild(circle);
// root.attachChild(circle);
BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt");
num = new BitmapText(guiFont);
num.setSize(0.3f);

View File

@@ -94,7 +94,8 @@ public void update(float tpf) {
}
public void addSpatial(Spatial card) {
cardBuffer.add(card);
if(root == null) cardBuffer.add(card);
else root.attachChild(card);
}
public void deleteSpatial(Spatial spatial) {

View File

@@ -85,6 +85,19 @@ public void addCard(BonusCard card) {
bonusCardControlMap.get(card).setNumCard(newNum);
}
public void removeCard(BonusCard card){
if(bonusCardControlMap.containsKey(card)){
bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1);
if(bonusCardIntegerMap.get(card) <= 0){
cardLayer.deleteSpatial(bonusCardControlMap.get(card).getRoot());
bonusCardIntegerMap.remove(card);
bonusCardControlMap.remove(card);
}
}
}
public void clearSelectableCards() {
for (CardControl control : selectableCards) {
control.setSelectable(false);
@@ -118,6 +131,8 @@ public void selectCard(CardControl cardControl) {
cardControl.select();
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
}
app.getModelSynchronize().selectCard(cardSelect);
}
public Camera getCardLayerCamera() {

View File

@@ -74,8 +74,31 @@ public void hideDice() {
cardLayerHandler.hideDice();
}
public void addCard(BonusCard card) {
//add own handCard
public void addCardOwn(BonusCard card) {
cardLayerHandler.addCard(card);
playerNameHandler.addCard(ownColor);
actionTextHandler.drawCardOwn(ownColor);
}
public void playCardOwn(BonusCard card){
getEffectByCard(card);
cardLayerHandler.removeCard(card);
playerNameHandler.removeCard(ownColor);
}
public void playCardEnemy(Color color, BonusCard card) {
getEffectByCard(card);
playerNameHandler.removeCard(color);
}
private void getEffectByCard(BonusCard bonus){
switch(bonus){
case SWAP -> swap();
case TURBO -> turbo();
case SHIELD -> shield();
default -> throw new RuntimeException("invalid card");
}
}
public void clearSelectableCards() {
@@ -125,9 +148,11 @@ public void hideText(){
actionTextHandler.hide();
}
//addCard Enemy (DrawCardNotification)
public void drawCard(Color color) {
if (ownColor == color) actionTextHandler.drawCardOwn(color);
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
//Color != ownColor
actionTextHandler.drawCard(playerNameHandler.getName(color), color);
playerNameHandler.addCard(color);
}
public void finish(Color color){
@@ -141,4 +166,6 @@ public void rollRankingResult(Color color, int eye){
}
}

View File

@@ -4,23 +4,27 @@
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
import com.jme3.ui.Picture;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
public class PlayerNameHandler {
private final BitmapFont playerFont;
private final Node playerNameNode;
private final List<Color> playerOrder;
private final Map<Color, String> colorNameMap;
private final Map<Color, Integer> colorCardMap;
private final AppSettings appSettings;
private final AssetManager assetManager;
private Color ownColor;
@@ -43,6 +47,7 @@ public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings ap
playerNameNode = new Node("player name node");
playerOrder = new ArrayList<>();
colorNameMap = new HashMap<>();
colorCardMap = new HashMap<>();
this.appSettings = appSettings;
this.assetManager = assetManager;
}
@@ -64,13 +69,38 @@ private void drawPlayers(){
if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
Node nameParent = new Node("nameParent");
nameParent.attachChild(createName(colorNameMap.get(color), i == 0, color == ownColor));
nameParent.attachChild(createColor(color));
BitmapText name = createName(colorNameMap.get(color), i == 0, color == ownColor);
nameParent.attachChild(name);
if(colorCardMap.getOrDefault(color, 0) > 0){
Picture pic = createHandCard(name.getLineWidth());
nameParent.attachChild(pic);
nameParent.attachChild(createCardNum(colorCardMap.get(color), pic.getWidth(), pic.getLocalTranslation().getX()));
}
nameParent.setLocalTranslation(50,appSettings.getWindowHeight()-PADDING_TOP- MARGIN_NAMES *i,0);
playerNameNode.attachChild(nameParent);
}
}
private Spatial createCardNum(int num, float lastWidth, float lastX ) {
BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45
hudText.setSize(TEXT_SIZE);
hudText.setColor(NORMAL_COLOR);
hudText.setText(String.valueOf(num));
hudText.setLocalTranslation(lastX + lastWidth + 20,hudText.getHeight()/2, 0);
return hudText;
}
private Picture createHandCard(float width) {
Picture pic = new Picture("HUD Picture");
pic.setImage(assetManager, "./Images/handcard.png", true);
pic.setWidth(IMAGE_SIZE);
pic.setHeight(IMAGE_SIZE);
pic.setPosition(-pic.getWidth()/2 + width + PADDING_LEFT * 2 ,-pic.getHeight()/2);
return pic;
}
private String imagePath(Color color){
String root = "./Images/name_pictures/";
return switch(color){
@@ -93,7 +123,7 @@ private Spatial createColor(Color color) {
private Spatial createName(String name, boolean first, boolean own){
private BitmapText createName(String name, boolean first, boolean own){
BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45
hudText.setSize(TEXT_SIZE);
@@ -124,5 +154,18 @@ public String getName(Color color){
return colorNameMap.get(color);
}
public void addCard(Color color){
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) + 1);
drawPlayers();
}
public void removeCard(Color color){
if(colorCardMap.containsKey(color)){
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) - 1);
if(colorCardMap.get(color) <= 0) colorCardMap.remove(color);
}
drawPlayers();
}
}

View File

@@ -3,7 +3,9 @@
import com.jme3.network.*;
import com.jme3.network.serializing.Serializer;
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;
@@ -123,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);
@@ -135,6 +137,7 @@ private void initializeSerializables() {
Serializer.registerClass(UpdateReadyMessage.class);
Serializer.registerClass(UpdateTSKMessage.class);
Serializer.registerClass(WaitPieceMessage.class);
Serializer.registerClass(IncorrectRequestMessage.class);
Serializer.registerClass(Player.class);
Serializer.registerClass(Statistic.class);
Serializer.registerClass(Board.class);
@@ -142,10 +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(PlayerDataMessage.class);
Serializer.registerClass(StartBriefingMessage.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() {
@@ -198,12 +208,31 @@ private void messageReceived(HostedConnection source, ClientMessage message) {
pendingMessages.add(new ReceivedMessage(message, source.getId()));
}
/**
* This method will be used to handle all connections which are connected to the server.
* It will check if the maximum number of connected clients are already reached. If yes it will send a
* LobbyDenyMessage to the given hostedConnection parameter and close it, otherwise it will send a
* LobbyAcceptMessage to the given hostedConnection parameter. In Addition, if the number of connected clients is
* equal to 1 it will set the host of the game to the id of the given hostedConnection parameter.
*
* @param server as the server which is contains all connections as a Server object.
* @param hostedConnection as the connection which is added to the server as a HostedConnection object.
*/
@Override
public void connectionAdded(Server server, HostedConnection hostedConnection) {
System.out.println("new connection " + hostedConnection); //NON-NLS
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
if (this.myServer.getConnections().size() == 1) {
this.logic.getGame().setHost(hostedConnection.getId());
if (this.myServer.getConnections().size() > Resources.MAX_PLAYERS) {
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyDenyMessage());
hostedConnection.close("");
} else {
if (hostedConnection.getAddress().contains("127.0.0.1") && this.logic.getGame().getHost() == -1) {
this.logic.getGame().setHost(hostedConnection.getId());
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage(hostedConnection.getId()));
} else {
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage());
}
}
}
@@ -278,4 +307,21 @@ public void broadcast(ServerMessage message) {
public void disconnectClient(int id) {
this.myServer.getConnection(id).close("");
}
/**
* This method will be used to shut down the server.
* It will iterate threw all connections of myServer attribute and check if they are equal to null. If not they will
* be closed. After that the myServer attribute will be closed and this program will be exited with the exit code 0.
*/
@Override
public void shutdown() {
for (HostedConnection client : this.myServer.getConnections()) {
if (client != null) {
client.close("Host closed the server.");
}
}
this.myServer.close();
this.exit(0);
}
}

View File

@@ -206,11 +206,19 @@ public void addCeremonyParticipant(Color color, int pos, String name) {
ceremonyButtons.add(button);
if(state.equals(SubState.AWARD_CEREMONY)) {
button.hide();
button.show();
}
}
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
ceremonyDialog.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
ceremonyDialog.hide();
ceremonyDialog.show();
}
public void afterGameCleanup() {
ceremonyDialog.prepare();
}
}

View File

@@ -1,31 +1,16 @@
package pp.mdga.client.view;
import com.jme3.post.FilterPostProcessor;
import pp.mdga.client.MdgaState;
import com.jme3.scene.Node;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.board.CameraHandler;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.dialog.InterruptDialog;
import pp.mdga.client.gui.GuiHandler;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.GameNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayerInGameNotification;
import pp.mdga.notification.RollDiceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.SelectableSwapNotification;
import pp.mdga.notification.ShieldActiveNotification;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class GameView extends MdgaView {
private BoardHandler boardHandler;
@@ -35,28 +20,38 @@ public class GameView extends MdgaView {
private ButtonLeft leaveButton;
private ButtonRight confirmButton;
private ButtonRight noPowerButton;
private Color ownColor = null;
private InterruptDialog interruptDialog;
private FilterPostProcessor fpp;
private Node guiHandlerNode = new Node();
public GameView(MdgaApp app) {
super(app);
leaveButton = new ButtonLeft(app, overlayNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
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());
this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, rootNode, fpp);
guiHandler = new GuiHandler(app, guiNode);
guiHandler = new GuiHandler(app, guiHandlerNode);
guiNode.attachChild(guiHandlerNode);
}
@Override
public void onEnter() {
setOwnColor(Color.AIRFORCE);
camera.init(ownColor);
boardHandler.init();
guiHandler.init(ownColor);
@@ -64,13 +59,6 @@ public void onEnter() {
app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START);
// guiHandler.addPlayer(Color.AIRFORCE, "Cedric");
// guiHandler.addPlayer(Color.ARMY, "Ben");
// guiHandler.addPlayer(Color.CYBER, "Felix");
// guiHandler.addPlayer(Color.NAVY, "Daniel");
}
@Override
@@ -81,6 +69,7 @@ public void onLeave() {
confirmButton.hide();
noPowerButton.hide();
app.getViewPort().removeProcessor(fpp);
}
@@ -125,10 +114,45 @@ public Color getOwnColor() {
}
public void needConfirm() {
noPowerButton.hide();
confirmButton.show();
}
public void noConfirm() {
confirmButton.hide();
}
public void needNoPower() {
confirmButton.hide();
noPowerButton.show();
}
public void noNoPower() {
noPowerButton.show();
}
public void enterInterrupt(Color color) {
enterOverlay(Overlay.INTERRUPT);
guiNode.detachChild(guiHandlerNode);
app.getGuiNode().attachChild(guiNode);
app.getInputSynchronize().setClickAllowed(false);
interruptDialog.setColor(color);
interruptDialog.show();
}
public void leaveInterrupt() {
leaveOverlay(Overlay.INTERRUPT);
app.getGuiNode().detachChild(guiNode);
guiNode.attachChild(guiHandlerNode);
app.getInputSynchronize().setClickAllowed(true);
app.getAcousticHandler().playSound(MdgaSound.START);
interruptDialog.hide();
}
}

View File

@@ -18,6 +18,7 @@
import pp.mdga.client.button.LobbyButton;
import pp.mdga.client.button.SettingsButton;
import pp.mdga.game.Color;
import pp.mdga.message.client.StartGameMessage;
import pp.mdga.notification.GameNotification;
public class LobbyView extends MdgaView {
@@ -25,6 +26,7 @@ public class LobbyView extends MdgaView {
private ButtonLeft leaveButton;
private ButtonRight readyButton;
private ButtonRight startButton;
private LobbyButton cyberButton;
private LobbyButton airforceButton;
@@ -42,6 +44,7 @@ public LobbyView(MdgaApp app) {
leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1);
readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 1);
startButton = new ButtonRight(app, guiNode, () -> app.getGameLogic().selectStart(), "Starten", 7);
cyberButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.CYBER), Color.CYBER);
airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
@@ -61,6 +64,10 @@ public void onEnter() {
leaveButton.show();
readyButton.show();
if(app.getGameLogic().isHost()) {
startButton.show();
}
cyberButton.show();
airforceButton.show();
armyButton.show();
@@ -95,6 +102,7 @@ public void onEnter() {
public void onLeave() {
leaveButton.hide();
readyButton.hide();
startButton.hide();
airforceButton.hide();
armyButton.hide();
@@ -223,6 +231,10 @@ private void toggleTsk(Color color) {
break;
}
if(isReady) {
setReady(own, false);
}
switch (taken) {
case NOT:
app.getModelSynchronize().selectTsk(color);

View File

@@ -7,9 +7,6 @@
import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.dialog.StartDialog;
import java.net.Inet4Address;
import java.net.UnknownHostException;
public class MainView extends MdgaView {
private enum SubState {
HOST,
@@ -63,12 +60,12 @@ public void onUpdate(float tpf) {
@Override
protected void onEnterOverlay(Overlay overlay) {
guiNode.detachChild(background);
overlayNode.attachChild(background);
settingsNode.attachChild(background);
}
@Override
protected void onLeaveOverlay(Overlay overlay) {
overlayNode.detachChild(background);
settingsNode.detachChild(background);
guiNode.attachChild(background);
}
@@ -96,6 +93,7 @@ private void mainMenu() {
private void tryHost() {
int port = 0;
String text = hostDialog.getPort();
app.getGameLogic().selectHost("");
try {
port = Integer.parseInt(text);
@@ -108,10 +106,6 @@ private void tryHost() {
} catch (InterruptedException ignored) {
}
hostDialog.connectServerAsClient();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setHost(port);
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return;
@@ -127,6 +121,7 @@ private void tryJoin() {
int port = 0;
String ip = joinDialog.getIpt();
String portText = joinDialog.getPort();
app.getGameLogic().selectJoin("");
try {
// Validate the port
@@ -140,11 +135,6 @@ private void tryJoin() {
app.getModelSynchronize().setName(startDialog.getName());
joinDialog.setHostname(ip);
joinDialog.connectToServer();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setJoin(ip, port);
return;
}
} catch (IllegalArgumentException e) {
@@ -234,5 +224,13 @@ public void back() {
break;
}
}
public JoinDialog getJoinDialog() {
return joinDialog;
}
public HostDialog getHostDialog() {
return hostDialog;
}
}

View File

@@ -2,9 +2,12 @@
import com.jme3.asset.TextureKey;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Quad;
import com.jme3.system.NanoTimer;
import com.jme3.texture.Texture;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
@@ -22,7 +25,7 @@ public enum Overlay {
protected MdgaApp app;
protected Node rootNode = new Node("View Root");
protected Node guiNode = new Node("View Root GUI");
protected Node overlayNode = new Node("View Root Overlay");
protected Node settingsNode = new Node("View Root Overlay");
private SettingsButton settingsButton;
@@ -30,15 +33,18 @@ public enum Overlay {
private VideoSettingsDialog videoSettingsDialog;
private AudioSettingsDialog audioSettingsDialog;
protected LabelButton infoLabel = null;
protected NanoTimer infoTimer = new NanoTimer();
private int settingsDepth = 0;
public MdgaView(MdgaApp app) {
this.app = app;
settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
settingsDialog = new SettingsDialog(app, overlayNode, this);
videoSettingsDialog = new VideoSettingsDialog(app, overlayNode, this);
audioSettingsDialog = new AudioSettingsDialog(app, overlayNode, this);
settingsDialog = new SettingsDialog(app, settingsNode, this);
videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this);
audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this);
}
public void enter() {
@@ -80,6 +86,11 @@ public void update(float tpf) {
videoSettingsDialog.update();
audioSettingsDialog.update();
if (null != infoLabel && infoTimer.getTimeInSeconds() > 5) {
infoLabel.hide();
infoLabel = null;
}
onUpdate(tpf);
}
@@ -113,7 +124,7 @@ protected Geometry createBackground(String texturePath) {
public void enterSettings() {
enterOverlay(Overlay.SETTINGS);
app.getGuiNode().attachChild(overlayNode);
app.getGuiNode().attachChild(settingsNode);
settingsDialog.show();
@@ -123,7 +134,7 @@ public void enterSettings() {
public void leaveSettings() {
leaveOverlay(Overlay.SETTINGS);
app.getGuiNode().detachChild(overlayNode);
app.getGuiNode().detachChild(settingsNode);
settingsDialog.hide();
@@ -193,4 +204,24 @@ public void pressForward() {
ceremonyView.forward();
}
}
public void showInfo(String error, boolean isError) {
infoTimer.reset();
if(null != infoLabel) {
infoLabel.hide();
}
infoLabel = new LabelButton(app, guiNode, error, new Vector2f(5.5f, 2), new Vector2f(0.5f, AbstractButton.VERTICAL - 0.5f), false);
ColorRGBA color;
if(isError) {
color = ColorRGBA.Red.clone();
} else {
color = ColorRGBA.Green.clone();
}
infoLabel.setColor(ColorRGBA.Black, color);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -1,7 +1,5 @@
world 0,0 90
#tree_small 1,1 0
#tree_big 0,0 0
#Marine Pos
marine 4,-5 270
@@ -131,3 +129,144 @@ node_home_blue 4,0 0
node_home_blue 3,0 0
node_home_blue 2,0 0
node_home_blue 1,0 0
# Randomly Distributed Trees within Radius 12 to 40
treeSmall 10,15 180
treeBig -15,12 45
treeSmall -8,-22 270
treeBig 22,8 90
treeSmall -18,-10 135
treeBig 9,24 300
treeSmall 17,-9 60
treeBig -20,5 330
treeSmall -14,18 200
treeBig 25,-7 120
treeBig -12,-18 150
treeSmall 19,-16 45
treeBig 7,10 90
treeBig -19,-9 270
treeSmall 21,4 110
treeBig -11,17 300
treeSmall 3,-21 360
treeSmall -23,14 100
treeBig 4,26 330
treeSmall 12,13 270
treeBig -18,8 45
treeBig 11,-10 135
treeSmall 16,5 180
treeBig -13,-17 330
treeSmall -2,14 270
#treeBig 7,9 300
treeSmall 23,-10 240
treeBig -6,18 180
treeSmall 5,27 270
treeBig 14,-11 60
treeSmall 9,-16 180
treeBig -12,22 240
treeBig 18,7 360
treeSmall -24,-4 200
treeBig -8,21 300
treeSmall 12,-19 120
treeBig 6,-12 180
treeSmall -11,10 75
treeBig 9,6 270
treeSmall 8,-14 150
treeBig 3,18 30
treeSmall 17,13 100
treeBig -9,20 90
treeBig 6,-22 330
treeSmall -20,7 45
treeBig 21,11 150
treeSmall 15,-18 270
treeBig -3,-12 200
treeBig 12,-28 330
treeSmall -17,-7 120
treeBig -10,9 300
treeSmall 2,-14 240
treeBig 24,2 360
treeSmall 4,-13 300
treeBig -19,20 90
#treeSmall -11,5 45
treeBig 15,9 180
treeSmall -6,10 240
treeBig 3,15 30
treeSmall 9,-19 150
treeBig -21,-4 330
treeSmall 19,11 270
treeSmall 12,24 110
treeBig -13,15 45
treeSmall 7,-15 240
treeBig 26,-8 300
treeSmall -16,14 120
treeBig 14,18 360
treeSmall 8,21 100
treeBig -8,-18 240
treeSmall 9,15 180
treeBig 10,-20 270
treeSmall 2,27 90
treeBig 18,12 300
treeSmall -10,-14 150
treeBig -15,16 330
treeSmall -9,19 45
treeBig 17,-14 120
treeSmall 5,-25 180
treeBig 7,23 30
treeSmall -14,-12 200
treeBig 6,-16 300
treeSmall -20,-8 100
treeBig 4,11 240
treeSmall 24,-15 90
treeSmall -19,-19 360
treeBig 20,8 45
treeSmall 3,22 270
treeBig 13,-9 180
treeSmall -11,18 150
treeBig -17,-4 300
treeSmall 5,-14 240
treeBig 9,17 330
treeSmall 15,13 90
treeBig -21,18 30
treeSmall 6,20 100
treeBig -16,22 180
treeSmall -5,18 360
treeBig 22,11 45
treeSmall 10,-23 240
treeBig -10,-16 300
treeSmall -17,14 120
treeBig 20,4 150
treeSmall 11,-22 180
treeBig -24,-11 200
treeSmall 14,17 150
treeBig -8,-12 300
treeSmall 7,-18 100
treeBig -5,16 330
treeSmall 16,-14 200
treeBig 18,-8 90
treeSmall -23,-9 45
treeBig 24,10 300
treeSmall -4,19 180
treeBig 12,-5 330
treeSmall -19,16 100
treeBig 14,20 150
treeSmall 9,12 180
treeBig -22,8 60
treeSmall 6,18 360
treeBig 25,-9 45
treeBig -10,12 240
treeSmall 19,-17 100
treeSmall -13,19 90
treeSmall 16,-12 120
treeBig 22,-6 45
treeSmall -18,15 200
treeBig 14,-10 300
treeBig 6,10 330
treeSmall 17,18 90
treeBig -20,4 180
treeBig 19,-16 300
treeSmall -15,9 270
treeBig 12,22 360

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

View File

@@ -0,0 +1,79 @@
package pp.mdga;
import java.util.ResourceBundle;
/**
* Provides access to the resource bundle of the game.
*
* @see #BUNDLE
*/
public class Resources {
/**
* Create Resources constants.
*/
public static final int MAX_PLAYERS = 4;
public static final int MAX_PIECES = 4;
public static final int MAX_EYES = 6;
/**
* The resource bundle for the MDGA game.
*/
public static final ResourceBundle BUNDLE = ResourceBundle.getBundle("mdga"); //NON-NLS
/**
* Gets a string for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static String stringLookup(String key) {
return BUNDLE.getString(key);
}
/**
* Gets a int for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static int intLookup(String key) {
return Integer.parseInt(BUNDLE.getString(key));
}
/**
* Gets a boolean for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static boolean boolLookup(String key) {
return Boolean.parseBoolean(BUNDLE.getString(key));
}
/**
* Gets a double for the given key from the resource bundle in {@linkplain #BUNDLE}.
*
* @param key the key for the desired string
* @return the string for the given key
* @throws NullPointerException if {@code key} is {@code null}
* @throws java.util.MissingResourceException if no object for the given key can be found
* @throws ClassCastException if the object found for the given key is not a string
*/
public static double doubleLookup(String key) {
return Double.parseDouble(BUNDLE.getString(key));
}
/**
* Private constructor to prevent instantiation.
*/
private Resources() { /* do not instantiate */ }
}

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 {
@@ -12,21 +11,38 @@ public class CeremonyState extends ClientState {
private final PodiumState podiumState = new PodiumState(this, logic);
private final StatisticsState statisticsState = new StatisticsState(this, logic);
/**
* Creates a new CeremonyState
*
* @param parent the parent state
* @param logic the game logic
*/
public CeremonyState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
/**
* Enters the new state machine
*/
@Override
public void enter() {
setState(podiumState);
logic.addNotification(createCeremonyNotification());
}
/**
* exits this state
*/
@Override
public void exit() {
currentState.exit();
}
/**
* This method is used to set a new SubState
*
* @param state the state to be set
*/
public void setState(CeremonyStates state){
if(this.currentState != null){
this.currentState.exit();
@@ -35,14 +51,29 @@ public void setState(CeremonyStates state){
currentState = state;
}
/**
* This method get the PodiumState
*
* @return the PodiumState
*/
public PodiumState getPodiumState(){
return podiumState;
}
/**
* This method get the StatisticsState
*
* @return the StatisticsState
*/
public StatisticsState getStatisticsState(){
return statisticsState;
}
/**
* This method is used to get the current State
*
* @return the current State
*/
public CeremonyStates getState(){
return currentState;
}

View File

@@ -1,18 +1,23 @@
package pp.mdga.client;
import pp.mdga.Resources;
import pp.mdga.game.BonusCard;
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;
/**
* The ClientGameLogic class is the main class for the client side of the game.
* It is responsible for handling the game logic on the client side.
*/
public class ClientGameLogic implements ServerInterpreter {
static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName());
@@ -21,6 +26,8 @@ public class ClientGameLogic implements ServerInterpreter {
private ClientState state;
private final ArrayList<Notification> notifications = new ArrayList<>();
private boolean isHost;
private int ownPlayerID;
private String ownPlayerName;
private final DialogsState dialogsState = new DialogsState(null, this);
private final GameState gameState = new GameState(null, this);
@@ -28,6 +35,11 @@ public class ClientGameLogic implements ServerInterpreter {
private final InterruptState interruptState = new InterruptState(null, this);
private final SettingsState settingsState = new SettingsState(null, this);
/**
* Creates a new ClientGameLogic
*
* @param clientSender the client sender
*/
public ClientGameLogic(ClientSender clientSender) {
this.game = new Game();
this.clientSender = clientSender;
@@ -35,15 +47,26 @@ public ClientGameLogic(ClientSender clientSender) {
state = dialogsState;
}
public void send(ClientMessage msg){
/**
* This method is used to send a message to the server
*
* @param msg the message to be sent
*/
public void send(ClientMessage msg) {
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
clientSender.send(msg);
}
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)){
/**
* 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 (var player : this.game.getPlayers().values()) {
for (Piece piece : player.getPieces()) {
if (piece.getUuid().equals(pieceId)) {
return piece;
}
}
@@ -51,289 +74,610 @@ private Piece getPiece(UUID pieceId){
return null;
}
public ClientSender getClientSender(){
/**
* This method returns the clientSender
*
* @return the clientSender
*/
public ClientSender getClientSender() {
return clientSender;
}
public Game getGame(){
/**
* This method is used to get the ownPlayerId
*
* @return the ownPlayerId
*/
public int getOwnPlayerId() {
return ownPlayerID;
}
/**
* This method is used to get the ownPlayerName
*
* @return the ownPlayerName
*/
public String getOwnPlayerName() {
return ownPlayerName;
}
/**
* This method is used to set the ownPlayerName
*
* @param ownPlayerName the ownPlayerName to be set
*/
public void setOwnPlayerName(String ownPlayerName) {
this.ownPlayerName = ownPlayerName;
}
/**
* This method is used to set the ownPlayerId
*
* @param ownPlayerId the ownPlayerId to be set
*/
public void setOwnPlayerId(int ownPlayerId) {
this.ownPlayerID = ownPlayerId;
}
/**
* This method returns the game
*
* @return the game
*/
public Game getGame() {
return game;
}
public ClientState getState(){
/**
* This method returns the current State
*
* @return the current State
*/
public ClientState getState() {
return state;
}
public boolean isHost(){
/**
* This method returns if the client is a host
*
* @return if the client is a host
*/
public boolean isHost() {
return isHost;
}
public int getCalculatedMoves(){
return game.getDiceEyes() * game.getDiceModifier();
/**
* This method returns the steps you can calculate steps
*
* @return the calculated moves as int
*/
public int getCalculatedMoves() {
return 0;
}
public void setHost(boolean isHost){
/**
* This method sets if the player is a host
*
* @param isHost the boolean value
*/
public void setHost(boolean isHost) {
this.isHost = isHost;
}
/**
* This method calls the method received of the state
*
* @param msg the ActivePlayer message received
*/
@Override
public void received(ActivePlayerMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the AnyPiece message received
*/
@Override
public void received(AnyPieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Briefing message received
*/
@Override
public void received(BriefingMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Ceremony message received
*/
@Override
public void received(CeremonyMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Dice message received
*/
@Override
public void received(DieMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the DiceAgain message received
*/
@Override
public void received(DiceAgainMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the DiceNow message received
*/
@Override
public void received(DiceNowMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the EndOfGame message received
*/
@Override
public void received(EndOfTurnMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the GameOver message received
*/
@Override
public void received(LobbyAcceptMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the LobbyDeny message received
*/
@Override
public void received(LobbyDenyMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the LobbyPlayerJoin message received
*/
@Override
public void received(LobbyPlayerJoinedMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the LobbyPlayerLeave message received
*/
@Override
public void received(LobbyPlayerLeaveMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the MoveMessage message received
*/
@Override
public void received(MoveMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the NoTurn message received
*/
@Override
public void received(NoTurnMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PauseGame message received
*/
@Override
public void received(PauseGameMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PlayCard message received
*/
@Override
public void received(PlayCardMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PossibleCard message received
*/
@Override
public void received(PossibleCardMessage msg) {
public void received(PossibleCardsMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the PossiblePiece message received
*/
@Override
public void received(PossiblePieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the RankingResponse message received
*/
@Override
public void received(RankingResponseMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the RankingRollAgain message received
*/
@Override
public void received(RankingRollAgainMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the ReconnectBriefing message received
*/
@Override
public void received(ReconnectBriefingMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the ResumeGame message received
*/
@Override
public void received(ResumeGameMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the ServerStartGame message received
*/
@Override
public void received(ServerStartGameMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the SelectTSK message received.
*/
@Override
public void received(ShutdownMessage msg) {state.received(msg);}
@Override
public void received(StartBriefingMessage msg) {
state.received(msg);
public void received(ShutdownMessage msg) {
addNotification(new InfoNotification(Resources.stringLookup("server.shutdown")));
addNotification(new StartDialogNotification());
setState(dialogsState);
}
/**
* Handles a IncorrectRequest message received from the server.
*
* @param msg the IncorrectRequest message received.
*/
@Override
public void received(PlayerDataMessage msg) {
state.received(msg);
public void received(IncorrectRequestMessage msg) {
addNotification(new InfoNotification(Resources.stringLookup("incorrect.request." + msg.getId())));
}
/**
* This method calls the method received of the state
*
* @param msg the StartPiece message received
*/
@Override
public void received(StartPieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the UpdateReady message received
*/
@Override
public void received(UpdateReadyMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the UpdateTSK message received
*/
@Override
public void received(UpdateTSKMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the WaitPiece message received
*/
@Override
public void received(WaitPieceMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the Spectator message received.
*/
@Override
public void received(SpectatorMessage msg) {
state.received(msg);
}
/**
* This method calls the method received of the state
*
* @param msg the SelectPiece message received.
*/
@Override
public void received(SelectPieceMessage msg) {
state.received(msg);
}
public void selectPiece(UUID pieceId){
/**
* This method calls the method selectPiece
*
* @param pieceId the pieceID
*/
public void selectPiece(UUID pieceId) {
state.selectPiece(getPiece(pieceId));
}
public void selectNext(){
/**
* This method call the method selectNExt of the state
*/
public void selectNext() {
state.selectNext();
}
public void selectCard(BonusCard card){
/**
* This method calls the method selectCard of the state
*
* @param card the BonusCard to selected
*/
public void selectCard(BonusCard card) {
state.selectCard(card);
}
public void selectTsk(Color color){
/**
* This method call the method selectTsk of the state
*
* @param color the Color to be selected
*/
public void selectTsk(Color color) {
state.selectTSK(color);
}
public void deselectTSK(Color color){
/**
* The method calls the method deselectTsk of the state
*
* @param color the color to be deselcted
*/
public void deselectTSK(Color color) {
state.deselectTSK(color);
}
public void selectDice(){
/**
* This method calls the selectDice method of the state
*/
public void selectDice() {
state.selectDice();
}
public void selectName(String name){
/**
* This method calls the selectName method of the state
*
* @param name the name to be set
*/
public void selectName(String name) {
state.setName(name);
}
public void selectReady(boolean ready){
if(ready){
/**
* This method calls a method of the state base on the parameter value
*
* @param ready the value if this method should ready or unready
*/
public void selectReady(boolean ready) {
if (ready) {
state.selectReady();
} else {
state.selectUnready();
}
}
public void selectHost(String name){
/**
* This method calls the selectHost method of the state
*
* @param name the name of the player hosting
*/
public void selectHost(String name) {
state.selectHost(name);
}
public void selectLeave(){
/**
* This method calls the selectLeave method of the state
*/
public void selectLeave() {
state.selectLeave();
}
public void selectJoin(String ip){
/**
* This method calls the selectJoin method of the state
*
* @param ip the ip to cennect to
*/
public void selectJoin(String ip) {
state.selectJoin(ip);
}
public void selectAnimationEnd(){
/**
* This method calls the selectAnimationEnd method of the state
*/
public void selectAnimationEnd() {
state.selectAnimationEnd();
}
public void selectStart(){
/**
* This method calls the selectStart method of the state
*/
public void selectStart() {
state.selectStart();
}
public void selectResume(){
/**
* This method calls the selectResume method of the state
*/
public void selectResume() {
state.selectResume();
}
public void setState(ClientState state){
/**
* This method is used to transition between states
*
* @param state the new state
*/
public void setState(ClientState state) {
this.state.exit();
state.enter();
this.state = state;
}
public void enterInterrupt(){
/**
* This method is used to enter the interrupt state and save the previous state
*/
public void enterInterrupt() {
interruptState.enter();
interruptState.setPreviousState(state);
this.state = interruptState;
}
public GameState getGameState(){
/**
* This method is used to get the GameState
*
* @return the GameState
*/
public GameState getGameState() {
return gameState;
}
public CeremonyState getCeremony(){
/**
* This method is used to get the CeremonyState
*
* @return the CeremonyState
*/
public CeremonyState getCeremony() {
return ceremonyState;
}
public InterruptState getInterrupt(){
/**
* This method is used to get the InterruptState
*
* @return the InterruptState
*/
public InterruptState getInterrupt() {
return interruptState;
}
public DialogsState getDialogs(){
/**
* This method is used to get the DialogsState
*
* @return the DialogsState
*/
public DialogsState getDialogs() {
return dialogsState;
}
public SettingsState getSettings(){
/**
* This method is used to get the SettingsState
*
* @return the SettingsState
*/
public SettingsState getSettings() {
return settingsState;
}
public Notification getNotification(){
if(!notifications.isEmpty()){
/**
* This method is used to get the next notification
*
* @return the next notification
*/
public Notification getNotification() {
if (!notifications.isEmpty()) {
return notifications.remove(0);
} else {
return null;
}
}
public void addNotification(Notification notification){
/**
* This method is used to add a notification
*
* @param notification the notification to be added
*/
public void addNotification(Notification notification) {
notifications.add(notification);
}

View File

@@ -37,159 +37,155 @@ public String toString(){
@Override
public void received(ActivePlayerMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(AnyPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(BriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(CeremonyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(DieMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(DiceAgainMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(DiceNowMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(EndOfTurnMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(LobbyAcceptMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(LobbyDenyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(LobbyPlayerJoinedMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(LobbyPlayerLeaveMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(MoveMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(NoTurnMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(PauseGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(PlayCardMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(PossibleCardMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
public void received(PossibleCardsMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(PossiblePieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(RankingResponseMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(RankingRollAgainMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(ReconnectBriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(ResumeGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(ServerStartGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);}
public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());}
@Override
public void received(StartPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(UpdateReadyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(UpdateTSKMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(SpectatorMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(SelectPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(WaitPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
@Override
public void received(StartBriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
public void received(PlayerDataMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
public void received(IncorrectRequestMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
}
public void selectPiece(Piece piece) {
@@ -252,6 +248,11 @@ public void selectResume(){
LOGGER.log(Level.DEBUG, "Resume not allowed");
}
/**
* This method is used to create a CeremonyNotification
*
* @return the created CeremonyNotification
*/
protected CeremonyNotification createCeremonyNotification(){
CeremonyNotification notification = new CeremonyNotification();
for (var player : logic.getGame().getPlayers().entrySet()){

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.*;
@@ -11,30 +11,41 @@ public class DialogsState extends ClientState {
private DialogStates currentState;
private int ownPlayerID;
private String ownPlayerName;
private final LobbyState lobbyState = new LobbyState(this, logic);
private final NetworkDialogState networkDialogState = new NetworkDialogState(this, logic);
private final StartDialogState startDialogState = new StartDialogState(this, logic);
/**
* Creates a new DialogsState
*
* @param parent the parent state
* @param logic the game logic
*/
public DialogsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
/**
* exits this state
*/
@Override
public void exit(){
currentState.exit();
}
/**
* Enters the new state machine
*/
@Override
public void enter(){
setState(startDialogState);
ownPlayerID = 0;
ownPlayerName = null;
}
/**
* This method is used to set a new SubState
*
* @param newState the state to be set
*/
public void setState(DialogStates newState){
if(currentState != null){
currentState.exit();
@@ -43,114 +54,188 @@ public void setState(DialogStates newState){
currentState = newState;
}
public int getOwnPlayerId() {
return ownPlayerID;
}
public String getOwnPlayerName() {
return ownPlayerName;
}
public void setOwnPlayerName(String ownPlayerName) {
this.ownPlayerName = ownPlayerName;
}
public void setOwnPlayerId(int ownPlayerId) {
this.ownPlayerID = ownPlayerId;
}
/**
* This method is used to get the lobbyState
*
* @return the lobbyState
*/
public LobbyState getLobby() {
return lobbyState;
}
/**
* This method is used to get the networkDialogState
*
* @return the networkDialogState
*/
public NetworkDialogState getNetworkDialog() {
return networkDialogState;
}
/**
* This method is used to get the startDialogState
*
* @return the startDialogState
*/
public StartDialogState getStartDialog() {
return startDialogState;
}
/**
* This method is used to call the selectLeave method of the current state
*/
@Override
public void selectLeave(){
currentState.selectLeave();
}
/**
* This method is used to call the selectName method of the current state
*
* @param name the name to be set
*/
@Override
public void setName(String name){
currentState.setName(name);
}
/**
* This method is used to call the selectTSK method of the current state
*
* @param color the color to be set
*/
@Override
public void selectTSK(Color color){
currentState.selectTSK(color);
}
/**
* This method is used to call the deselectTSK method of the current state
*
* @param color the color to be deselected
*/
@Override
public void deselectTSK(Color color){
currentState.deselectTSK(color);
}
/**
* This method is used to call the selectReady method of the current state
*/
@Override
public void selectReady(){
currentState.selectReady();
}
/**
* This method is used to call the selectUnready method of the current state
*/
@Override
public void selectUnready(){
currentState.selectUnready();
}
/**
* This method is used to call the selectStart method of the current state
*/
@Override
public void selectStart(){
currentState.selectStart();
}
/**
* This method is used to call the selectJoin method of the current state
*
* @param string the string to be set
*/
@Override
public void selectJoin(String string){
currentState.selectJoin(string);
}
/**
* This method is used to call the selectHost method of the current state
*
* @param name the name to be set
*/
@Override
public void selectHost(String name){
currentState.selectHost(name);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyPlayerJoin message received
*/
@Override
public void received(LobbyPlayerJoinedMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyPlayerLeave message received
*/
@Override
public void received(LobbyPlayerLeaveMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the UpdateTSKMessage message received
*/
@Override
public void received(UpdateTSKMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the UpdateReady message received
*/
@Override
public void received(UpdateReadyMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the ServerStartGame message received
*/
@Override
public void received(ServerStartGameMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyAccept message received
*/
@Override
public void received(PlayerDataMessage msg){
public void received(LobbyAcceptMessage msg){
currentState.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the LobbyDeny message received
*/
@Override
public void received(StartBriefingMessage msg){
public void received(LobbyDenyMessage msg){
currentState.received(msg);
}
/**
* This method is used to get the current state
*/
public DialogStates getState() {
return currentState;
}

View File

@@ -1,10 +1,12 @@
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;
import pp.mdga.message.server.*;
import pp.mdga.notification.InterruptNotification;
import pp.mdga.notification.StartDialogNotification;
public class GameState extends ClientState {
@@ -58,132 +60,271 @@ public void setState(GameStates newState){
state = newState;
}
/**
* This method is used to call the selectAnimationEnd method of the current state
*/
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
/**
* This method is used to call the selectDice method of the current state
*/
@Override
public void selectDice(){
state.selectDice();
}
/**
* This method is used to call the selectPiece method of the current state
*
* @param piece the piece to be selected
*/
@Override
public void selectPiece(Piece piece){
state.selectPiece(piece);
}
/**
* This method is used to call the selectCard method of the current state
*
* @param card the card to be selected
*/
@Override
public void selectCard(BonusCard card){
state.selectCard(card);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(PauseGameMessage msg){
logic.enterInterrupt();
logic.addNotification(new InterruptNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor()));
}
@Override
public void selectLeave(){
logic.send(new LeaveGameMessage());
logic.addNotification(new StartDialogNotification());
logic.setState(logic.getDialogs());
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(DieMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(RankingRollAgainMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(RankingResponseMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(SelectPieceMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(WaitPieceMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(StartPieceMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(NoTurnMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(MoveMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(CeremonyMessage msg){
state.received(msg);
logic.addNotification(createCeremonyNotification());
logic.setState(logic.getCeremony());
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(EndOfTurnMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(SpectatorMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(DiceAgainMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(PossibleCardMessage msg){
public void received(PossibleCardsMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(PlayCardMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(DiceNowMessage msg){
state.received(msg);
}
/**
* This method is used to call the received method of the current state
*
* @param msg the message to be received
*/
@Override
public void received(ActivePlayerMessage msg){
state.received(msg);
}
/**
* This method returns the current state
*
* @return the current state
*/
public GameStates getState(){
return state;
}
/**
* This method returns the AnimationState
*
* @return the AnimationState
*/
public AnimationState getAnimation() {
return animationState;
}
/**
* This method returns the DetermineStartPlayerState
*
* @return the DetermineStartPlayerState
*/
public DetermineStartPlayerState getDetermineStartPlayer() {
return determineStartPlayerState;
}
/**
* This method returns the SpectatorState
*
* @return the SpectatorState
*/
public SpectatorState getSpectator() {
return spectatorState;
}
/**
* This method returns the TurnState
*
* @return the TurnState
*/
public TurnState getTurn() {
return turnState;
}
/**
* This method returns the WaitingState
*
* @return the WaitingState
*/
public WaitingState getWaiting() {
return waitingState;
}

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 {
@@ -49,14 +49,23 @@ public SettingStates getState(){
return currentState;
}
/**
* Returns the main settings state
*/
public MainSettingsState getMainSettingsState(){
return mainSettingsState;
}
/**
* Returns the audio settings state
*/
public AudioSettingsState getAudioSettingsState(){
return audioSettingsState;
}
/**
* Returns the video settings state
*/
public VideoSettingsState getVideoSettingsState(){
return videoSettingsState;
}

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,34 +0,0 @@
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.DialogsState;
import pp.mdga.notification.LobbyDialogNotification;
public class NetworkDialogState extends DialogStates {
private final DialogsState parent;
public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}
public void selectJoin(String IP) {
parent.setState(parent.getLobby());
logic.addNotification(new LobbyDialogNotification());
}
}

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,18 +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.PlayerDataMessage;
import pp.mdga.message.server.ServerStartGameMessage;
import pp.mdga.message.server.StartBriefingMessage;
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 {
@@ -30,7 +26,7 @@ public LobbyState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.send(new JoinedLobbyMessage(parent.getOwnPlayerName()));
logic.send(new JoinedLobbyMessage(logic.getOwnPlayerName()));
}
@Override
@@ -60,61 +56,58 @@ public void selectReady() {
}
@Override
public void selectUnready(){
public void selectUnready() {
logic.send(new LobbyNotReadyMessage());
}
@Override
public void selectStart(){
if(logic.isHost() && logic.getGame().allReady()){
logic.send(new StartGameMessage(false));
} else if(logic.isHost() && !logic.getGame().allReady()) {
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(StartBriefingMessage msg){
logic.getGame().setBoard(msg.getBoard());
}
public void received(PlayerDataMessage msg){
logic.getGame().getBoard().addPlayerData(msg.getColor(), msg.getPlayerData());
}
@Override
public void received(ServerStartGameMessage msg){
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(parent.getOwnPlayerId()).getColor()));
for (Map.Entry<Color, PlayerData> entry : logic.getGame().getBoard().getPlayerData().entrySet()) {
List<UUID> pieceList = new ArrayList<>();
for(Piece piece : entry.getValue().getPieces()){
System.out.println(piece.getUuid());
pieceList.add(piece.getUuid());
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.addNotification(new PlayerInGameNotification(entry.getKey(), pieceList , logic.getGame().getPlayerByColor(entry.getKey()).getName()));
}
logic.getGame().setBoard(msg.getBoard());
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
for (var player : logic.getGame().getPlayers().values()) {
List<UUID> pieces = new ArrayList<>();
for (Piece piece : player.getPieces()) {
pieces.add(piece.getUuid());
}
logic.addNotification(new PlayerInGameNotification(player.getColor(), pieces, player.getName()));
}
logic.setState(logic.getGameState());
}
@Override
public void received(LobbyPlayerJoinedMessage msg){
if(msg.getPlayer().getName().equals(parent.getOwnPlayerName())){
parent.setOwnPlayerId(msg.getId());
public void received(LobbyPlayerJoinedMessage msg) {
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
logic.setOwnPlayerId(msg.getId());
}
if (msg.isHost() && msg.getId() == parent.getOwnPlayerId()){
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
logic.setHost(true);
}
logic.addNotification(new TskSelectNotification(msg.getPlayer().getColor(), msg.getPlayer().getName(), msg.getPlayer().getName().equals(parent.getOwnPlayerName())));
logic.addNotification(new TskSelectNotification(msg.getPlayer().getColor(), msg.getPlayer().getName(), msg.getPlayer().getName().equals(logic.getOwnPlayerName())));
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
}
@Override
public void received(UpdateTSKMessage msg){
if(msg.isTaken()) {
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), parent.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()));
}
@@ -123,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

@@ -0,0 +1,72 @@
package pp.mdga.client.dialogstate;
import pp.mdga.Resources;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.DialogsState;
import pp.mdga.message.server.LobbyAcceptMessage;
import pp.mdga.message.server.LobbyDenyMessage;
import pp.mdga.notification.InfoNotification;
import pp.mdga.notification.LobbyDialogNotification;
public class NetworkDialogState extends DialogStates {
private final DialogsState parent;
/**
* Constructor for the NetworkDialogState
* @param parent the parent state
* @param logic the logic
*/
public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
/**
* Enter the state
*/
@Override
public void enter() {
LOGGER.log(System.Logger.Level.INFO, "Entered {0}", this);
}
/**
* Exit the state
*/
@Override
public void exit() {
}
/**
* Select the leave option
*/
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}
/**
* This method is called when the server accepts the client into the lobby
*
* @param msg the LobbyAcceptMessage
*/
@Override
public void received(LobbyAcceptMessage msg) {
logic.getGame().setHost(msg.getHost());
logic.setHost(logic.getGame().isHost());
parent.setState(parent.getLobby());
logic.addNotification(new LobbyDialogNotification());
}
/**
* This method is called when the server denies the client into the lobby
*
* @param msg the LobbyDenyMessage
*/
@Override
public void received(LobbyDenyMessage msg) {
logic.addNotification(new InfoNotification(Resources.stringLookup("lobby.deny.join")));
parent.setState(parent.getStartDialog());
}
}

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;
@@ -8,41 +8,44 @@ public class StartDialogState extends DialogStates {
private final DialogsState parent;
/**
* Constructor for the StartDialogState
* @param parent the parent state
* @param logic the logic
*/
public StartDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
/**
* Enter the state
*/
@Override
public void enter() {
}
/**
* Exit the state
*/
@Override
public void exit() {
}
@Override
public void selectJoin(String name) {
parent.setOwnPlayerName(name);
parent.setState(parent.getNetworkDialog());
logic.setHost(false);
}
@Override
public void selectHost(String name) {
parent.setOwnPlayerName(name);
parent.setState(parent.getLobby());
logic.setHost(true);
}
/**
* Set the name
*
* @param name the name
*/
@Override
public void setName(String name) {
logic.setOwnPlayerName(name);
parent.setState(parent.getNetworkDialog());
parent.setOwnPlayerName(name);
}
/**
* Select the leave option
*/
@Override
public void selectLeave() {
parent.exit();

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,40 +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().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.*;
@@ -47,6 +47,11 @@ public void setState(TurnStates state){
this.state = state;
}
@Override
public void selectDice(){
state.selectDice();
}
@Override
public void selectPiece(Piece piece){
state.selectPiece(piece);
@@ -108,7 +113,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.getDialogs().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.*;
@@ -46,7 +46,7 @@ public void received(SpectatorMessage msg){
}
@Override
public void received(DiceAgainMessage msg){
public void received(DiceNowMessage msg){
parent.setState(parent.getRollDice());
}

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);
}
@@ -35,7 +35,7 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
@Override
public void selectAnimationEnd(){
parent.setState(parent.getRollDice());
logic.send(new AnimationEndMessage());
parent.setState(parent.getRollDice());
}
}

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,14 @@
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.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 +21,7 @@ public RollDiceState(ClientState parent, ClientGameLogic logic) {
@Override
public void enter() {
logic.addNotification(new DiceNowNotification());
}
@Override
@@ -29,11 +33,27 @@ public TurnState getParent() {
return parent;
}
@Override
public void selectDice(){
logic.send(new RequestDieMessage());
}
@Override
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
parent.setState(parent.getChoosePiece());
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),false));
}
@Override
public void selectAnimationEnd(){
logic.send(new AnimationEndMessage());
}
// @Override
// public void received(ChoosePieceStateMessage msg){
// parent.setState(parent.getChoosePiece());
// }
@Override
public void received(NoTurnMessage msg){
parent.getParent().setState(parent.getParent().getWaiting());

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,56 +2,88 @@
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();
infield[i] = new Node(null);
}
}
}
/**
* 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(){
super();
/**
* Constructor.
*/
BonusNode() {
super(null);
}
}

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