112 Commits

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

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

View File

@@ -0,0 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
<option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
<module name="Projekte.mdga.client.main" />
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="pp.mdga.client.board.outline.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -39,11 +39,7 @@ public enum Asset {
shieldCard, shieldCard,
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"), shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
dice, dice,
tankShoot("Models/tank/tankShoot_bot.j3o", "Models/tank/tank_diff.png"), missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
tankShootTop("Models/tank/tankShoot_top.j3o", "Models/tank/tank_diff.png"),
treesSmallBackground("Models/treeSmall/treesSmallBackground.j3o", "Models/treeSmall/treeSmall_diff.png", 1.2f),
treesBigBackground("Models/treeBig/treesBigBackground.j3o", "Models/treeBig/treeBig_diff.png", 1.2f),
shell
; ;
private final String modelPath; private final String modelPath;

View File

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

View File

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

View File

@@ -1,5 +1,6 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler; import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.gui.GuiHandler; import pp.mdga.client.gui.GuiHandler;
import pp.mdga.client.view.CeremonyView; import pp.mdga.client.view.CeremonyView;
@@ -85,13 +86,14 @@ private void handleGame(Notification notification) {
GuiHandler guiHandler = gameView.getGuiHandler(); GuiHandler guiHandler = gameView.getGuiHandler();
BoardHandler boardHandler = gameView.getBoardHandler(); BoardHandler boardHandler = gameView.getBoardHandler();
ModelSynchronizer modelSynchronizer = app.getModelSynchronize(); ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
Color ownColor = gameView.getOwnColor();
if (notification instanceof AcquireCardNotification n) { if (notification instanceof AcquireCardNotification n) {
guiHandler.addCardOwn(n.getBonusCard()); guiHandler.addCardOwn(n.getBonusCard());
app.getAcousticHandler().playSound(MdgaSound.BONUS);
} else if (notification instanceof ActivePlayerNotification n) { } else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor()); gameView.getGuiHandler().setActivePlayer(n.getColor());
if(n.getColor() != ownColor) boardHandler.showDice(n.getColor()); boardHandler.showDice(n.getColor());
app.getAcousticHandler().playSound(MdgaSound.UI90);
} else if (notification instanceof CeremonyNotification ceremonyNotification) { } else if (notification instanceof CeremonyNotification ceremonyNotification) {
app.enter(MdgaState.CEREMONY); app.enter(MdgaState.CEREMONY);
CeremonyView ceremonyView = (CeremonyView) app.getView(); CeremonyView ceremonyView = (CeremonyView) app.getView();
@@ -126,8 +128,8 @@ private void handleGame(Notification notification) {
} else if (notification instanceof HomeMoveNotification home) { } else if (notification instanceof HomeMoveNotification home) {
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex()); boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
guiHandler.hideText(); guiHandler.hideText();
} else if (notification instanceof InterruptNotification) { } else if (notification instanceof InterruptNotification notification1) {
gameView.enterInterrupt(); gameView.enterInterrupt(notification1.getColor());
} else if (notification instanceof MovePieceNotification n) { } else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) { if(n.isMoveStart()) {
//StartMove //StartMove
@@ -139,11 +141,11 @@ private void handleGame(Notification notification) {
} }
guiHandler.hideText(); guiHandler.hideText();
} else if (notification instanceof ThrowPieceNotification n) { } else if (notification instanceof ThrowPieceNotification n) {
boardHandler.throwPiece(n.getPieceId(), n.getThrowColor()); boardHandler.throwBombAnim(n.getPieceId());
} else if (notification instanceof NoShieldNotification n) { } else if (notification instanceof NoShieldNotification n) {
boardHandler.unshieldPiece(n.getPieceId()); boardHandler.unshieldPiece(n.getPieceId());
} else if (notification instanceof PlayCardNotification n) { } else if (notification instanceof PlayCardNotification n) {
if(n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard()); if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
else guiHandler.playCardEnemy(n.getColor(), n.getCard()); else guiHandler.playCardEnemy(n.getColor(), n.getCard());
} else if (notification instanceof PlayerInGameNotification n) { } else if (notification instanceof PlayerInGameNotification n) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList()); boardHandler.addPlayer(n.getColor(),n.getPiecesList());
@@ -152,7 +154,7 @@ private void handleGame(Notification notification) {
gameView.leaveInterrupt(); gameView.leaveInterrupt();
} else if (notification instanceof RollDiceNotification n) { } else if (notification instanceof RollDiceNotification n) {
gameView.getGuiHandler().hideText(); gameView.getGuiHandler().hideText();
if(n.getColor() == ownColor){ if(n.getColor() == gameView.getOwnColor()){
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1); guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
} }
else { else {
@@ -162,6 +164,7 @@ private void handleGame(Notification notification) {
} }
} else if (notification instanceof SelectableCardsNotification n) { } else if (notification instanceof SelectableCardsNotification n) {
guiHandler.setSelectableCards(n.getCards()); guiHandler.setSelectableCards(n.getCards());
gameView.needNoPower();
} else if (notification instanceof ShieldActiveNotification n) { } else if (notification instanceof ShieldActiveNotification n) {
boardHandler.shieldPiece(n.getPieceId()); boardHandler.shieldPiece(n.getPieceId());
} else if (notification instanceof ShieldSuppressedNotification n) { } else if (notification instanceof ShieldSuppressedNotification n) {

View File

@@ -1,47 +0,0 @@
package pp.mdga.client;
import com.jme3.math.Vector3f;
public class Util {
private Util(){}
/**
* Performs linear interpolation between two values.
*
* @param start The starting value.
* @param end The ending value.
* @param t A parameter between 0 and 1 representing the interpolation progress.
* @return The interpolated value.
*/
public static float linInt(float start, float end, float t) {
return start + t * (end - start);
}
/**
* Performs quadratic interpolation between three points.
*
* @param p1 The initial point.
* @param p2 The middle point.
* @param p3 The final point.
* @param t The interpolation parameter (0 <= t <= 1).
* @return The interpolated point.
*/
public static Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
// Quadratic interpolation: (1-t)^2 * p1 + 2 * (1-t) * t * p2 + t^2 * p3
float oneMinusT = 1 - t;
return p1.mult(oneMinusT * oneMinusT)
.add(p2.mult(2 * oneMinusT * t))
.add(p3.mult(t * t));
}
/**
* A smooth ease-in-out function for interpolation.
* It accelerates and decelerates the interpolation for a smoother effect.
*
* @param x The interpolation parameter (0 <= x <= 1).
* @return The adjusted interpolation value.
*/
public static float easeInOut(float x){
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
}
}

View File

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

View File

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

View File

@@ -35,11 +35,9 @@ enum SoundAsset {
UI90("ui90.ogg"), UI90("ui90.ogg"),
BONUS("bonus.ogg"), BONUS("bonus.ogg"),
LOSE("lose.ogg"), LOSE("lose.ogg"),
CONNECTED("connected.wav"), MISSILE("missile.ogg"),
TURRET_ROTATE("turret_rotate.ogg"), MATRIX("matrix.wav"),
TANK_SHOOT("tank_shoot.ogg") CONNECTED("connected.wav");
;
private final String path; private final String path;

View File

@@ -1,18 +0,0 @@
package pp.mdga.client.animation;
import pp.mdga.client.InitControl;
public class ActionControl extends InitControl {
private final Runnable runnable;
public ActionControl(Runnable runnable){
this.runnable = runnable;
}
protected void action(){
if(runnable == null) throw new RuntimeException("runnable is null");
else runnable.run();
}
}

View File

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

View File

@@ -1,70 +0,0 @@
package pp.mdga.client.animation;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import pp.mdga.client.InitControl;
import static pp.mdga.client.Util.linInt;
public class FadeControl extends ActionControl {
private float duration; // Duration of the fade effect
private float timeElapsed = 0;
private boolean init = false;
private float startAlpha;
private float endAlpha;
public FadeControl(float duration, float startAlpha, float endAlpha, Runnable actionAfter) {
super(actionAfter);
this.duration = duration;
this.startAlpha = startAlpha;
this.endAlpha = endAlpha;
}
public FadeControl(float duration, float startAlpha, float endAlpha) {
this(duration, startAlpha, endAlpha, null);
}
@Override
protected void initSpatial() {
init = true;
}
@Override
protected void controlUpdate(float tpf) {
if (!init) return;
timeElapsed += tpf;
float t = timeElapsed / duration; // Calculate progress (0 to 1)
if (t >= 1) {
// Fade complete
t = 1;
init = false;
spatial.removeControl(this);
action();
}
float alpha = linInt(startAlpha, endAlpha, t); // Interpolate alpha
// Update the material's alpha
if (spatial instanceof Geometry geometry) {
Material mat = geometry.getMaterial();
if (mat != null) {
ColorRGBA diffuse = (ColorRGBA) mat.getParam("Diffuse").getValue();
mat.setColor("Diffuse", new ColorRGBA(diffuse.r, diffuse.g, diffuse.b, alpha));
ColorRGBA ambient = (ColorRGBA) mat.getParam("Ambient").getValue();
mat.setColor("Ambient", new ColorRGBA(ambient.r, ambient.g, ambient.b, alpha));
// Disable shadows when the object is nearly invisible
if (alpha <= 0.1f) {
geometry.setShadowMode(RenderQueue.ShadowMode.Off);
} else {
geometry.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
}
} else throw new RuntimeException("Material is null");
} else throw new RuntimeException("Spatial is not instance of Geometry");
}
}

View File

@@ -29,7 +29,6 @@ public class JetAnimation {
private final float animationDuration; // Dauer der Animation private final float animationDuration; // Dauer der Animation
private Explosion explosion; private Explosion explosion;
private final UUID id; private final UUID id;
private Runnable actionAfter;
/** /**
* Konstruktor für die ThrowAnimation-Klasse. * Konstruktor für die ThrowAnimation-Klasse.
@@ -41,7 +40,7 @@ public class JetAnimation {
* @param curveHeight Die maximale Höhe der Flugkurve * @param curveHeight Die maximale Höhe der Flugkurve
* @param animationDuration Die Gesamtdauer der Animation in Sekunden * @param animationDuration Die Gesamtdauer der Animation in Sekunden
*/ */
public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration, Runnable actionAfter) { public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration) {
Vector3f spawnPoint = targetPoint.add(170, 50, 50); Vector3f spawnPoint = targetPoint.add(170, 50, 50);
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45)); Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
@@ -58,8 +57,7 @@ public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint,
id = uuid; id = uuid;
explosion = new Explosion(app, rootNode, nodePoint); explosion = new Explosion(app, rootNode, targetPoint);
this.actionAfter = actionAfter;
} }
/** /**
@@ -85,8 +83,6 @@ private void spawnJet() {
jetModel.setMaterial(mat); jetModel.setMaterial(mat);
rootNode.attachChild(jetModel); rootNode.attachChild(jetModel);
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
} }
/** /**
@@ -122,7 +118,10 @@ protected void controlUpdate(float tpf) {
} }
if (elapsedTime > 6.0f) { if (elapsedTime > 6.0f) {
endAnim(); GameView gameView = (GameView) app.getView();
BoardHandler boardHandler = gameView.getBoardHandler();
boardHandler.throwPieceAnim(id);
} }
} }
@@ -133,10 +132,6 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
}); });
} }
private void endAnim(){
actionAfter.run();
}
/** /**
* Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten. * Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
*/ */

View File

@@ -1,200 +0,0 @@
package pp.mdga.client.animation;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh.Type;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import pp.mdga.client.InitControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import java.util.*;
public class MatrixAnimation extends ActionControl {
private MdgaApp app;
private static final Random RANDOM = new Random();
private Vector3f radarPos;
private Runnable runnable;
private boolean init = false;
private List<ParticleEmitter> activeEmitter = new ArrayList<>();
private ParticleEmitter radarEmitter = null;
private float timeElapsed = 0f;
private enum MatrixState{
RADAR_ON,
RADAR_OFF,
MATRIX_ON,
MATRIX_OFF
}
private MatrixState state;
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable){
super(runnable);
this.app = app;
this.radarPos = radarPos;
}
@Override
protected void initSpatial() {
state = MatrixState.RADAR_ON;
timeElapsed = 0;
init = true;
radar();
}
@Override
protected void controlUpdate(float tpf) {
if(!init) return;
timeElapsed += tpf;
switch(state){
case RADAR_ON -> {
if(timeElapsed >= 2f){
state = MatrixState.RADAR_OFF;
timeElapsed = 0;
radarEmitter.setParticlesPerSec(0);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
app.getRootNode().detachChild(radarEmitter);
}
}, 3000);
}
}
case RADAR_OFF -> {
if(timeElapsed >= 0.1f){
state = MatrixState.MATRIX_ON;
timeElapsed = 0;
matrix();
}
}
case MATRIX_ON -> {
if(timeElapsed >= 3f){
state = MatrixState.MATRIX_OFF;
timeElapsed = 0;
turnOff();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
for (ParticleEmitter particleEmitter : activeEmitter){
app.getRootNode().detachChild(particleEmitter);
}
}
}, 3000);
}
}
case MATRIX_OFF -> {
if(timeElapsed >= 0.5f){
init = false;
spatial.removeControl(this);
action();
}
}
}
}
private void turnOff(){
for (ParticleEmitter particleEmitter : activeEmitter){
particleEmitter.setParticlesPerSec(0f);
}
}
private void radar(){
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/radar_beam.png"));
ParticleEmitter emitter = new ParticleEmitter("Effect", Type.Triangle, 50);
emitter.setMaterial(mat);
emitter.setImagesX(1); // columns
emitter.setImagesY(1); // rows
emitter.setSelectRandomImage(true);
emitter.setStartColor(ColorRGBA.White);
emitter.setEndColor(ColorRGBA.Black);
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, 2));
emitter.getParticleInfluencer().setVelocityVariation(0f);
emitter.setStartSize(0.1f);
emitter.setEndSize(10);
emitter.setGravity(0, 0, 0);
float life = 2.6f;
emitter.setLowLife(life);
emitter.setHighLife(life);
emitter.setLocalTranslation(radarPos.add(new Vector3f(0,0,5)));
emitter.setParticlesPerSec(1.8f);
app.getRootNode().attachChild(emitter);
radarEmitter = emitter;
}
private void matrix(){
for(int i = 0; i < 5; i++){
particleStream(
generateMatrixColor(),
generateMatrixColor(),
getRandomFloat(0,1f),
getRandomPosition(),
getRandomFloat(1,2)
);
}
}
private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vector3f pos, float spawnVar){
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/particle_cir.png"));
ParticleEmitter matrix = new ParticleEmitter("Effect", Type.Triangle, 50);
matrix.setMaterial(mat);
matrix.setImagesX(2); // columns
matrix.setImagesY(1); // rows
matrix.setSelectRandomImage(true);
matrix.setStartColor(start);
matrix.setEndColor(end);
matrix.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, -6f - speedVar));
matrix.getParticleInfluencer().setVelocityVariation(0f);
matrix.setStartSize(0.4f);
matrix.setEndSize(0.6f);
matrix.setGravity(0, 0, 2f);
matrix.setLowLife(3f);
matrix.setHighLife(3f);
matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0,0,15)));
matrix.setParticlesPerSec(spawnVar);
app.getRootNode().attachChild(matrix);
activeEmitter.add(matrix);
}
public static Vector3f getRandomPosition() {
// Generate a random angle in radians (0 to )
float angle = (float) (2 * Math.PI * RANDOM.nextDouble());
// Generate a random radius with uniform distribution
float radius = (float) Math.sqrt(RANDOM.nextDouble());
radius *= 1f;
// Convert polar coordinates to Cartesian
float x = radius * (float) Math.cos(angle);
float y = radius * (float) Math.sin(angle);
return new Vector3f(x,y,0);
}
public static float getRandomFloat(float start, float end) {
if (start > end) {
throw new IllegalArgumentException("Start must be less than or equal to end.");
}
return start + RANDOM.nextFloat() * (end - start);
}
public static ColorRGBA generateMatrixColor() {
// Red is dominant
float red = 0.8f + RANDOM.nextFloat() * 0.2f; // Red channel: 0.8 to 1.0
// Green is moderately high
float green = 0.4f + RANDOM.nextFloat() * 0.3f; // Green channel: 0.4 to 0.7
// Blue is minimal
float blue = RANDOM.nextFloat() * 0.2f; // Blue channel: 0.0 to 0.2
float alpha = 1.0f; // Fully opaque
return new ColorRGBA(red, green, blue, alpha);
}
}

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

@@ -1,8 +1,7 @@
package pp.mdga.client.animation; package pp.mdga.client.animation;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import pp.mdga.client.InitControl;
import static pp.mdga.client.Util.*;
/** /**
* A control that smoothly moves a spatial from an initial position to an end position * A control that smoothly moves a spatial from an initial position to an end position
@@ -13,16 +12,16 @@
* an ease-in-out curve to create a smooth start and stop effect. * an ease-in-out curve to create a smooth start and stop effect.
* </p> * </p>
*/ */
public class MoveControl extends ActionControl { public class MoveControl extends InitControl {
private boolean moving; private boolean moving;
private final Vector3f initPos; private final Vector3f initPos;
private final Vector3f endPos; private final Vector3f endPos;
private final Vector3f middlePos; private final Vector3f middlePos;
private final float height; private final static float HEIGHT = 2;
private final float duration; private final static float MOVE_SPEED = 1f;
private float timer = 0; private float progress = 0;
private boolean easing; private final Runnable actionAfter;
/** /**
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement. * Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
@@ -33,22 +32,15 @@ public class MoveControl extends ActionControl {
* @param actionAfter A Runnable that will be executed after the movement finishes. * @param actionAfter A Runnable that will be executed after the movement finishes.
*/ */
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
this(initPos, endPos, actionAfter, 2, 1, true);
}
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, float height, float duration, boolean easing){
super(actionAfter);
moving = false; moving = false;
this.initPos = initPos; this.initPos = initPos;
this.endPos = endPos; this.endPos = endPos;
this.height = height;
this.duration = duration;
this.easing = easing;
middlePos = new Vector3f( middlePos = new Vector3f(
(initPos.x + endPos.x) / 2, (initPos.x + endPos.x) / 2,
(initPos.y + endPos.y) / 2, (initPos.y + endPos.y) / 2,
height HEIGHT
); );
this.actionAfter = actionAfter;
} }
/** /**
@@ -58,7 +50,7 @@ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, floa
@Override @Override
protected void initSpatial() { protected void initSpatial() {
moving = true; moving = true;
timer = 0; progress = 0;
} }
/** /**
@@ -71,16 +63,10 @@ protected void initSpatial() {
@Override @Override
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
if(!moving) return; if(!moving) return;
timer += tpf; progress += tpf * MOVE_SPEED;
if(progress > 1) progress = 1;
float t = timer / duration; spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, easeInOut(progress)));
if (t >= 1) t = 1; if(progress == 1) end();
float interpolated = easing ? easeInOut(t) : t;
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, interpolated));
if(t >= 1) end();
} }
/** /**
@@ -89,11 +75,35 @@ protected void controlUpdate(float tpf) {
*/ */
private void end(){ private void end(){
moving = false; moving = false;
actionAfter.run();
spatial.removeControl(this); spatial.removeControl(this);
action();
} }
/**
* Performs quadratic interpolation between three points.
*
* @param p1 The initial point.
* @param p2 The middle point.
* @param p3 The final point.
* @param t The interpolation parameter (0 <= t <= 1).
* @return The interpolated point.
*/
private Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
// Quadratic interpolation: (1-t)^2 * p1 + 2 * (1-t) * t * p2 + t^2 * p3
float oneMinusT = 1 - t;
return p1.mult(oneMinusT * oneMinusT)
.add(p2.mult(2 * oneMinusT * t))
.add(p3.mult(t * t));
}
/**
* A smooth ease-in-out function for interpolation.
* It accelerates and decelerates the interpolation for a smoother effect.
*
* @param x The interpolation parameter (0 <= x <= 1).
* @return The adjusted interpolation value.
*/
private float easeInOut(float x){
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
}
} }

View File

@@ -1,167 +0,0 @@
package pp.mdga.client.animation;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import pp.mdga.client.Asset;
import pp.mdga.client.InitControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.TankTopControl;
import java.util.Timer;
import java.util.TimerTask;
import static com.jme3.material.Materials.LIGHTING;
import static com.jme3.material.Materials.UNSHADED;
public class ShellAnimation extends ActionControl {
private static final float FLYING_DURATION = 1.25f;
private static final float FLYING_HEIGHT = 12f;
private TankTopControl tankTopControl;
private MdgaApp app;
public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter){
super(actionAfter);
this.tankTopControl = tankTopControl;
this.app = app;
}
@Override
protected void initSpatial() {
tankTopControl.rotate(spatial.getLocalTranslation(), this::shoot);
app.getAcousticHandler().playSound(MdgaSound.TURRET_ROTATE);
app.getRootNode().attachChild(createShell());
}
private Vector3f getShootPos(){
Vector3f localOffset = new Vector3f(0, -5.4f, 2.9f);
Quaternion turretRotation = tankTopControl.getSpatial().getLocalRotation();
Vector3f transformedOffset = turretRotation.mult(localOffset);
return tankTopControl.getSpatial().getLocalTranslation().add(transformedOffset);
}
private void shoot(){
app.getAcousticHandler().playSound(MdgaSound.TANK_SHOOT);
Vector3f shootPos = getShootPos();
createEffect(
shootPos,
"Images/particle/flame.png",
2, 2,
1, 3,
1f,
0.3f, 0.7f,
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
new ColorRGBA(1f, 0f, 0f, 0f)
);
createEffect(
shootPos,
"Images/particle/vapor_cloud.png",
3, 3,
0.3f, 0.8f,
10,
0.1f, 0.35f,
new ColorRGBA(0.5f,0.5f,0.5f,0.5f),
ColorRGBA.Black
);
Spatial shell = createShell();
app.getRootNode().attachChild(shell);
shell.addControl(new ShellControl(this::hitExplosion, shootPos, spatial.getLocalTranslation(), FLYING_HEIGHT, FLYING_DURATION, app.getAssetManager()));
}
private Spatial createShell(){
Spatial model = app.getAssetManager().loadModel(Asset.shell.getModelPath());
model.scale(.16f);
model.setLocalTranslation(tankTopControl.getSpatial().getLocalTranslation());
Vector3f shootPos = tankTopControl.getSpatial().getLocalTranslation();
Vector3f targetPos = spatial.getLocalTranslation();
Vector3f direction = targetPos.subtract(shootPos).normalize();
Quaternion rotation = new Quaternion();
rotation.lookAt(direction, new Vector3f(1,0,0)); // Assuming UNIT_Y is the up vector
model.setLocalRotation(rotation);
model.rotate(FastMath.HALF_PI,0,0);
Material mat = new Material(app.getAssetManager(), LIGHTING);
mat.setBoolean("UseMaterialColors", true);
ColorRGBA color = ColorRGBA.fromRGBA255(143,117,0,255);
mat.setColor("Diffuse", color);
mat.setColor("Ambient", color);
model.setMaterial(mat);
return model;
}
private void hitExplosion(){
app.getAcousticHandler().playSound(MdgaSound.TANK_EXPLOSION);
createEffect(
spatial.getLocalTranslation().setZ(1),
"Images/particle/flame.png",
2, 2,
1, 5,
2f,
0.3f, 0.7f,
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
new ColorRGBA(1f, 0f, 0f, 0f)
);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
action();
}
}, 800);
}
private void createEffect(Vector3f shootPos,
String image,
int x, int y,
float startSize, float endSize,
float velocity,
float lowLife, float highLife,
ColorRGBA start, ColorRGBA end){
// Create a particle emitter for the explosion
ParticleEmitter explosionEmitter = new ParticleEmitter("Explosion", ParticleMesh.Type.Triangle, 100);
Material explosionMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
explosionMat.setTexture("Texture", app.getAssetManager().loadTexture(image));
explosionEmitter.setMaterial(explosionMat);
// Particle properties
explosionEmitter.setImagesX(x); // Columns in the texture
explosionEmitter.setImagesY(y); // Rows in the texture
explosionEmitter.setSelectRandomImage(true); // Randomize images for variety
explosionEmitter.setStartColor(start); // Bright yellowish orange
explosionEmitter.setEndColor(end); // Fade to transparent red
explosionEmitter.setStartSize(startSize); // Initial size
explosionEmitter.setEndSize(endSize); // Final size
explosionEmitter.setLowLife(lowLife); // Minimum lifetime of particles
explosionEmitter.setHighLife(highLife); // Maximum lifetime of particles
explosionEmitter.setGravity(0, 0, 1); // Gravity to pull particles down
explosionEmitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, velocity));
explosionEmitter.getParticleInfluencer().setVelocityVariation(1f); // Adds randomness to the initial velocity
explosionEmitter.setFacingVelocity(true); // Particles face their velocity direction
explosionEmitter.setLocalTranslation(shootPos);
explosionEmitter.setParticlesPerSec(0);
explosionEmitter.emitAllParticles();
app.getRootNode().attachChild(explosionEmitter);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
app.getRootNode().detachChild(explosionEmitter);
}
}, 1000);
}
}

View File

@@ -1,89 +0,0 @@
package pp.mdga.client.animation;
import com.jme3.asset.AssetManager;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import pp.mdga.client.InitControl;
public class ShellControl extends ActionControl {
private final Vector3f shootPos;
private final Vector3f endPos;
private final float height;
private final float duration;
private Vector3f oldPos;
private ParticleEmitter emitter;
private AssetManager assetManager;
public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager){
super(runnable);
this.shootPos = shootPos;
this.endPos = endPos;
this.height = height;
this.duration = duration;
this.assetManager = assetManager;
}
@Override
protected void initSpatial() {
spatial.addControl(new MoveControl(
shootPos,
endPos,
()->{
emitter.killAllParticles();
emitter.setParticlesPerSec(0);
emitter.removeFromParent();
spatial.removeControl(this);
spatial.removeFromParent();
action();
},
height,
duration,
false
));
oldPos = spatial.getLocalTranslation().clone();
createEmitter();
}
private void createEmitter() {
emitter = new ParticleEmitter("ShellTrail", ParticleMesh.Type.Triangle, 200);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", assetManager.loadTexture("Images/particle/line.png")); // Nutze eine schmale, linienartige Textur
emitter.setMaterial(mat);
// Comic-Style Farben
emitter.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f)); // Reinweiß
emitter.setEndColor(new ColorRGBA(1f, 1f, 1f, 0f)); // Transparent
// Partikelgröße und Lebensdauer
emitter.setStartSize(0.15f); // Startgröße
emitter.setEndSize(0.1f); // Endgröße
emitter.setLowLife(0.14f); // Sehr kurze Lebensdauer
emitter.setHighLife(0.14f);
emitter.setGravity(0, 0, 0); // Keine Gravitation
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
emitter.getParticleInfluencer().setVelocityVariation(0f); // Kein Variationsspielraum
// Hohe Dichte für eine glatte Spur
emitter.setParticlesPerSec(500);
// Zur Shell hinzufügen
spatial.getParent().attachChild(emitter);
}
@Override
protected void controlUpdate(float tpf) {
Vector3f direction = spatial.getLocalTranslation().subtract(oldPos).normalize();
if (direction.lengthSquared() > 0) {
spatial.getLocalRotation().lookAt(direction, Vector3f.UNIT_X);
spatial.rotate(FastMath.HALF_PI,0,0);
}
oldPos = spatial.getLocalTranslation().clone();
emitter.setLocalTranslation(spatial.getLocalTranslation().clone());
}
}

View File

@@ -1,9 +1,6 @@
package pp.mdga.client.board; package pp.mdga.client.board;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue;
@@ -13,7 +10,9 @@
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound; import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.animation.*; 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.client.gui.DiceControl;
import pp.mdga.game.Color; import pp.mdga.game.Color;
@@ -57,10 +56,6 @@ public class BoardHandler {
private PieceControl selectedOwnPiece; private PieceControl selectedOwnPiece;
private PieceControl selectedEnemyPiece; private PieceControl selectedEnemyPiece;
private DiceControl diceControl; private DiceControl diceControl;
//Radar Position for Matrix animation
private Vector3f radarPos;
//TankTop for shellAnimation
private TankTopControl tankTop;
/** /**
* Creates a new BoardHandler. * Creates a new BoardHandler.
@@ -153,24 +148,12 @@ private void initMap() {
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap); case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap); case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap); case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
case radar -> addRadar(assetOnMap);
case tankShoot -> addTankShoot(assetOnMap);
default -> displayAsset(assetOnMap); default -> displayAsset(assetOnMap);
} }
} }
} }
private void addTankShoot(AssetOnMap assetOnMap) {
displayAsset(assetOnMap);
tankTop = displayAndControl(new AssetOnMap(Asset.tankShootTop, assetOnMap.x(), assetOnMap.y(), assetOnMap.rot()), new TankTopControl());
}
private void addRadar(AssetOnMap assetOnMap) {
radarPos = gridToWorld(assetOnMap.x(), assetOnMap.y());
displayAsset(assetOnMap);
}
/** /**
* Converts an asset to its corresponding color. * Converts an asset to its corresponding color.
* *
@@ -204,16 +187,11 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot)); model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
model.setLocalTranslation(pos); model.setLocalTranslation(pos);
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName)); mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
mat.setBoolean("UseMaterialColors", true); // Required for Material Colors
mat.setColor("Diffuse", new ColorRGBA(1, 1, 1, 1)); // White color with full alpha
mat.setColor("Ambient", new ColorRGBA(1, 1, 1, 1)); // Ambient color with full alpha
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
model.setMaterial(mat); model.setMaterial(mat);
rootNodeBoard.attachChild(model); rootNodeBoard.attachChild(model);
return model; return model;
} }
@@ -224,7 +202,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
* @param y The y-coordinate on the grid * @param y The y-coordinate on the grid
* @return The corresponding world position * @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); return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
} }
@@ -745,52 +723,32 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
*/ */
public void throwPieceAnim(UUID uuid){ public void throwPieceAnim(UUID uuid){
pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getSpatial().addControl(new MoveControl(
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), ()->throwPiece(uuid))
()->throwPiece(uuid))
); );
} }
public void throwPiece(UUID uuid, Color throwColor){
switch(throwColor){
case ARMY -> throwShell(uuid);
case NAVY -> throwMissle(uuid);
case CYBER -> throwMatrix(uuid);
case AIRFORCE -> throwBomb(uuid);
default -> throw new RuntimeException("invalid color");
}
}
/** /**
* Animates the throwing of a piece to the next available waiting node. * Animates the throwing of a piece to the next available waiting node and plays jet animation.
* *
* @param uuid the UUID of the piece to animate * @param uuid the UUID of the piece to animate
*/ */
private void throwBomb(UUID uuid) { public void throwBombAnim(UUID uuid){
Vector3f targetPoint = pieces.get(uuid).getLocation(); Vector3f targetPoint = pieces.get(uuid).getLocation();
JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6, ()->throwPieceAnim(uuid)); JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6);
anim.start(); anim.start();
} }
private void throwMatrix(UUID uuid) { /**
//app.getAcousticHandler().playSound(MdgaSound.MATRIX); * Animates the throwing of a piece to the next available waiting node and plays ship animation.
Spatial piece = pieces.get(uuid).getSpatial(); *
piece.addControl(new MatrixAnimation(app, radarPos,()-> { * @param uuid the UUID of the piece to animate
piece.addControl(new FadeControl(1,1,0, */
() -> { public void throwMissileAnim(UUID uuid){
throwPiece(uuid); Vector3f targetPoint = pieces.get(uuid).getLocation();
piece.addControl(new FadeControl(1,0,1));
}
));
}));
}
private void throwMissle(UUID uuid) { MissileAnimation anim = new MissileAnimation(app, rootNode, uuid, targetPoint, 2);
anim.start();
}
private void throwShell(UUID uuid) {
pieces.get(uuid).getSpatial().addControl(new ShellAnimation(tankTop, app, ()-> throwPieceAnim(uuid)));
} }
/** /**

View File

@@ -102,18 +102,15 @@ public void init(Color ownColor) {
* and resets the camera position and rotation to its default state. * and resets the camera position and rotation to its default state.
*/ */
public void shutdown() { public void shutdown() {
init = false;
fpp.removeFilter(fxaaFilter);
fpp.removeFilter(ssaoFilter);
fpp.removeFilter(dlsf);
app.getRootNode().detachChild(sky);
app.getRootNode().removeLight(ambient);
app.getRootNode().removeLight(sun); app.getRootNode().removeLight(sun);
app.getRootNode().removeLight(ambient);
app.getRootNode().detachChild(sky);
// Reset the camera to its default state // Reset the camera to its default state
app.getCamera().setLocation(defaultCameraPosition); app.getCamera().setLocation(defaultCameraPosition);
app.getCamera().setRotation(defaultCameraRotation); app.getCamera().setRotation(defaultCameraRotation);
fpp.removeFilter(dlsf);
} }
/** /**

View File

@@ -109,9 +109,6 @@ private static Asset getLoadedAsset(String assetName) {
case "tank" -> Asset.tank; case "tank" -> Asset.tank;
case "treeSmall" -> Asset.treeSmall; case "treeSmall" -> Asset.treeSmall;
case "treeBig" -> Asset.treeBig; case "treeBig" -> Asset.treeBig;
case "tank_shoot" -> Asset.tankShoot;
case "treesBigBackground" -> Asset.treesBigBackground;
case "treesSmallBackground" -> Asset.treesSmallBackground;
default -> throw new IllegalStateException("Unexpected value: " + assetName); default -> throw new IllegalStateException("Unexpected value: " + assetName);
}; };
} }

View File

@@ -141,7 +141,7 @@ public void initSpatial(){
} }
public void rotateInit() { public void rotateInit() {
setRotation(initRotation); // rotate(rotation - initRotation);
} }
/** /**
@@ -278,5 +278,4 @@ public boolean isSelectable() {
public void setHoverable(boolean hoverable) { public void setHoverable(boolean hoverable) {
this.hoverable = hoverable; this.hoverable = hoverable;
} }
} }

View File

@@ -1,105 +0,0 @@
package pp.mdga.client.board;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import pp.mdga.client.InitControl;
import static pp.mdga.client.Util.linInt;
public class TankTopControl extends InitControl {
private float timer = 0; // Time elapsed
private final static float DURATION = 1.5f; // Total rotation duration in seconds
private boolean rotating = false; // Flag to track if rotation is active
private float startAngle = 0;
private float endAngle = 0;
private Runnable actionAfter = null;
@Override
protected void controlUpdate(float tpf) {
if (!rotating) return;
// Update the timer
timer += tpf;
// Calculate interpolation factor (0 to 1)
float t = timer / DURATION;
if (t >= 1) t = 1;
float curAngle = linInt(startAngle, endAngle, t);
// Interpolate the rotation
Quaternion interpolatedRotation = new Quaternion();
interpolatedRotation.fromAngleAxis((float) Math.toRadians(curAngle), Vector3f.UNIT_Z);
// Apply the interpolated rotation to the spatial
spatial.setLocalRotation(interpolatedRotation);
if(t >= 1){
rotating = false;
if(actionAfter != null) actionAfter.run();
}
}
public void rotate(Vector3f enemyPos, Runnable actionAfter) {
if (spatial == null) throw new RuntimeException("spatial is null");
startAngle = getOwnAngle();
endAngle = getEnemyAngle(enemyPos);
// Adjust endAngle to ensure the shortest path
float deltaAngle = endAngle - startAngle;
if (deltaAngle > 180) {
endAngle -= 360; // Rotate counterclockwise
} else if (deltaAngle < -180) {
endAngle += 360; // Rotate clockwise
}
timer = 0;
rotating = true;
this.actionAfter = actionAfter; // Store the action to execute after rotation
}
private float getEnemyAngle(Vector3f enemyPos){
// Direction to the enemy in the XY plane
Vector3f direction = enemyPos.subtract(spatial.getLocalTranslation());
direction.z = 0; // Project to XY plane
direction.normalizeLocal();
Vector3f reference = Vector3f.UNIT_Y.mult(-1);
// Calculate the angle between the direction vector and the reference vector
float angle = FastMath.acos(reference.dot(direction));
// Determine rotation direction using the cross product
Vector3f cross = reference.cross(direction);
if (cross.z < 0) {
angle = -angle;
}
return (float) Math.toDegrees(angle); // Return the absolute angle in degrees
}
private float getOwnAngle() {
// Tank's forward direction in the XY plane
Vector3f forward = spatial.getLocalRotation().mult(Vector3f.UNIT_Y);
forward.z = 0; // Project to XY plane
forward.normalizeLocal();
// Reference vector: Positive X-axis
Vector3f reference = Vector3f.UNIT_Y;
// Calculate the angle between the forward vector and the reference vector
float angle = FastMath.acos(reference.dot(forward));
// Determine rotation direction using the cross product
Vector3f cross = reference.cross(forward);
if (cross.z < 0) { // For Z-up, check the Z component of the cross product
angle = -angle;
}
return (float) Math.toDegrees(angle); // Return the absolute angle in radians
}
}

View File

@@ -8,18 +8,21 @@
import pp.mdga.client.button.LabelButton; import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.MenuButton; import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView; import pp.mdga.client.view.MdgaView;
import pp.mdga.game.Color;
public class InterruptDialog extends Dialog { public class InterruptDialog extends Dialog {
private ButtonRight forceButton; private ButtonRight forceButton;
private LabelButton label; private LabelButton label;
private String text = "";
public InterruptDialog(MdgaApp app, Node node) { public InterruptDialog(MdgaApp app, Node node) {
super(app, node); super(app, node);
forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1); forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
label = new LabelButton(app, node, "Warte auf Spieler...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false); label = new LabelButton(app, node, "Warte auf " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
float offset = 2.8f; float offset = 2.8f;
@@ -40,4 +43,21 @@ protected void onHide() {
forceButton.hide(); forceButton.hide();
label.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

@@ -152,4 +152,5 @@ void rollRankingResultOwn(Color color, int eye){
void diceNow(){ void diceNow(){
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0); createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
} }
} }

View File

@@ -8,7 +8,6 @@
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.ComposeFilter; import com.jme3.post.filters.ComposeFilter;
import com.jme3.post.filters.FXAAFilter;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
@@ -32,46 +31,35 @@ public class CardLayer extends AbstractAppState {
private List<Spatial> cardBuffer; private List<Spatial> cardBuffer;
private final FilterPostProcessor fpp; private final FilterPostProcessor fpp;
private final Camera overlayCam; private final Camera overlayCam;
private Texture2D backTexture; Texture2D backTexture;
private FXAAFilter fxaaFilter;
private ViewPort view;
private DirectionalLightShadowFilter dlsf;
DirectionalLight sun;
ComposeFilter compose;
public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTexture) { public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTexture) {
this.overlayCam = overlayCam; this.overlayCam = overlayCam;
this.fpp = fpp; this.fpp = fpp;
this.backTexture = backTexture; this.cardBuffer = new ArrayList<>();
cardBuffer = new ArrayList<>();
init = false; init = false;
fxaaFilter = new FXAAFilter(); this.backTexture = backTexture;
view = null;
dlsf = null;
sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(.5f, -.5f, -1));
compose = new ComposeFilter(backTexture);
root = new Node("Under gui viewport Root");
} }
@Override @Override
public void initialize(AppStateManager stateManager, Application app) { public void initialize(AppStateManager stateManager, Application app) {
this.app = app; this.app = app;
root = new Node("Under gui viewport Root");
view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam); ViewPort view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam);
view.setEnabled(true); view.setEnabled(true);
view.setClearFlags(true, true, true); view.setClearFlags(true, true, true);
view.attachScene(root); view.attachScene(root);
fpp.setFrameBufferFormat(Image.Format.RGBA8); fpp.setFrameBufferFormat(Image.Format.RGBA8);
fpp.addFilter(compose); fpp.addFilter(new ComposeFilter(backTexture));
fpp.addFilter(fxaaFilter);
DirectionalLight sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(.5f, -.5f, -1));
root.addLight(sun); root.addLight(sun);
dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3); DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
dlsf.setLight(sun); dlsf.setLight(sun);
dlsf.setEnabled(true); dlsf.setEnabled(true);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON); dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
@@ -84,15 +72,6 @@ public void initialize(AppStateManager stateManager, Application app) {
} }
public void shutdown() { public void shutdown() {
view.clearProcessors();
fpp.removeFilter(dlsf);
dlsf = null;
root.removeLight(sun);
fpp.removeFilter(fxaaFilter);
fpp.removeFilter(compose);
view.detachScene(root);
app.getRenderManager().removeMainView(view);
cardBuffer.clear(); cardBuffer.clear();
root.detachAllChildren(); root.detachAllChildren();
} }

View File

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

View File

@@ -39,15 +39,14 @@ public DiceControl(AssetManager assetManager){
@Override @Override
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
float clampedTpf = Math.min(tpf, 0.05f); // Max 50 ms per frame
if (isRolling) { if (isRolling) {
if(!slerp) { if(!slerp) {
// Apply rotational velocity to the dice // Apply rotational velocity to the dice
spinWithAngularVelocity(clampedTpf); spinWithAngularVelocity(tpf);
// Gradually reduce rotational velocity (simulate deceleration) // Gradually reduce rotational velocity (simulate deceleration)
angularVelocity.subtractLocal( angularVelocity.subtractLocal(
angularVelocity.mult(deceleration * clampedTpf) angularVelocity.mult(deceleration * tpf)
); );
// Stop rolling when angular velocity is close to zero // Stop rolling when angular velocity is close to zero
@@ -56,7 +55,7 @@ protected void controlUpdate(float tpf) {
} }
} }
else { else {
timeElapsed += clampedTpf * rollDuration; timeElapsed += tpf * rollDuration;
if (timeElapsed > 1.0f) timeElapsed = 1.0f; if (timeElapsed > 1.0f) timeElapsed = 1.0f;
@@ -72,7 +71,7 @@ protected void controlUpdate(float tpf) {
} }
} }
}else if(spin){ }else if(spin){
spinWithAngularVelocity(clampedTpf); spinWithAngularVelocity(tpf);
} }
} }

View File

@@ -3,7 +3,6 @@
import com.jme3.asset.AssetManager; import com.jme3.asset.AssetManager;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.FXAAFilter;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
@@ -55,6 +54,7 @@ public void select(Spatial model, ColorRGBA color, int width) {
} }
private void hideOutlineFilterEffect(Spatial model) { private void hideOutlineFilterEffect(Spatial model) {
// app.enqueue(() -> {
outlineFilter.setEnabled(false); outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false); outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter); fpp.removeFilter(outlineFilter);
@@ -62,14 +62,18 @@ private void hideOutlineFilterEffect(Spatial model) {
outlineViewport.clearProcessors(); outlineViewport.clearProcessors();
renderManager.removePreView(outlineViewport); renderManager.removePreView(outlineViewport);
outlineViewport = null; outlineViewport = null;
// return null;
// });
} }
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) { private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
// app.enqueue(() -> {
outlineViewport = renderManager.createPreView("outlineViewport", cam); outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager); FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
OutlinePreFilter outlinePreFilter = new OutlinePreFilter(); OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
outlineFpp.addFilter(outlinePreFilter); outlineFpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model); outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp); outlineViewport.addProcessor(outlineFpp);
@@ -78,5 +82,7 @@ private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color)
outlineFilter.setOutlineWidth(width); outlineFilter.setOutlineWidth(width);
fpp.addFilter(outlineFilter); fpp.addFilter(outlineFilter);
// return null;
// });
} }
} }

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -1,6 +1,4 @@
world 0,0 90 world 0,0 90
treesBigBackground 0,0 90
treesSmallBackground 0,0 90
#Marine Pos #Marine Pos
@@ -58,8 +56,7 @@ big_tent -10,-9 130
big_tent 9,-10 225 big_tent 9,-10 225
radar 0,10 -20 radar 0,10 -20
tank -1,-10 135 tank -1,-10 135
#tank 0,-18 180 tank 0,-18 180
tank_shoot 0,-18 180
tank 3,-18 180 tank 3,-18 180
tank -3,-18 180 tank -3,-18 180
@@ -273,4 +270,3 @@ 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: 13 MiB

After

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 MiB

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.gameState; package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates; import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState; import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState; 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.DieMessage;
import pp.mdga.message.server.RankingResponseMessage; import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage; 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 RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic); private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
private final Intro intro = new Intro(this, logic);
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) { public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.parent = (GameState) parent; 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 @Override
public void enter() { public void enter() {
this.setState(this.rollRankingDiceState); this.setState(this.rollRankingDiceState);
@@ -46,6 +70,11 @@ public void selectDice() {
state.selectDice(); state.selectDice();
} }
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
state.received(msg); state.received(msg);
@@ -61,19 +90,8 @@ public void received(RankingResponseMessage msg){
state.received(msg); state.received(msg);
} }
public RollRankingDiceState getRollRankingDice() { @Override
return rollRankingDiceState; public void received(ActivePlayerMessage msg){
} state.received(msg);
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
public DetermineStartPlayerStates getState(){
return state;
}
public GameState getParent() {
return parent;
} }
} }

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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
@@ -12,39 +12,45 @@
import pp.mdga.notification.SwapPieceNotification; import pp.mdga.notification.SwapPieceNotification;
import pp.mdga.notification.ThrowPieceNotification; import pp.mdga.notification.ThrowPieceNotification;
import java.util.UUID;
public abstract class GameStates extends ClientState { public abstract class GameStates extends ClientState {
public GameStates(ClientState parent, ClientGameLogic logic) { public GameStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
protected void handlePowerCard(PlayCardMessage msg){ protected void handlePowerCard(PlayCardMessage msg) {
if (msg.getCard().equals(BonusCard.TURBO)){ if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
logic.getGame().setDiceModifier(msg.getDiceModifier()); logic.getGame().setDiceModifier(msg.getDiceModifier());
} else if (msg.getCard().equals(BonusCard.SHIELD)){ } else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) {
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) { handleShield(msg.getPieces().get(0).getUuid());
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
} else { } else {
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE); Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid())); Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
}
} else {
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece); int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid())); logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece); logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
} }
logic.getGame().getDiscardPile().add(logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard())); logic.getGame().getDiscardPile().add(msg.getCard());
} }
protected void throwPiece(Piece piece){ protected void throwPiece(Piece piece) {
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); logic.getGame().getBoard().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.addNotification(new ThrowPieceNotification(piece.getUuid()));
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown(); logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
logic.getGame().getGameStatistics().increasePiecesBeingThrown(); logic.getGame().getGameStatistics().increasePiecesBeingThrown();
piece.setState(PieceState.WAITING); 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; 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 { public class SpectatorState extends GameStates {
@@ -27,15 +30,15 @@ public void exit() {
} }
@Override @Override
public void received(CeremonyMessage msg){ public void received(CeremonyMessage msg) {
logic.setState(logic.getCeremony()); logic.setState(logic.getCeremony());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
logic.getGame().setDiceEyes(msg.getDiceEye()); //logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); // 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().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();
} }
@@ -43,8 +46,8 @@ public void received(DieMessage msg){
} }
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
handlePowerCard(msg); handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed(); logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -52,26 +55,26 @@ public void received(PlayCardMessage msg){
} }
@Override @Override
public void received(ActivePlayerMessage msg){ public void received(ActivePlayerMessage msg) {
logic.addNotification(new ActivePlayerNotification(msg.getColor())); logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor()); logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()){ if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant(); 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 { } else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant()); throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().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.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else { } 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.client.gameState.turnState.ChoosePieceState; import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gameState.turnState.MovePieceState; import pp.mdga.client.gamestate.turnstate.MovePieceState;
import pp.mdga.client.gameState.turnState.PlayPowerCardState; import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState; import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gameState.turnState.RollDiceState; import pp.mdga.client.gamestate.turnstate.RollDiceState;
import pp.mdga.client.gameState.turnState.TurnStates; import pp.mdga.client.gamestate.turnstate.TurnStates;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
@@ -108,7 +108,7 @@ public void received(DiceAgainMessage msg){
} }
@Override @Override
public void received(PossibleCardMessage msg){ public void received(PossibleCardsMessage msg){
state.received(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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; 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.message.server.*;
import pp.mdga.notification.*; import pp.mdga.notification.*;
@@ -27,21 +28,21 @@ public void exit() {
} }
@Override @Override
public void received(CeremonyMessage msg){ public void received(CeremonyMessage msg) {
logic.setState(logic.getCeremony()); logic.setState(logic.getCeremony());
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
logic.addNotification(new DiceNowNotification()); logic.addNotification(new DiceNowNotification());
parent.setState(parent.getTurn()); parent.setState(parent.getTurn());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
if(msg.getDiceEye() == 6){ if (msg.getDiceEye() == 6) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();
} }
@@ -49,8 +50,8 @@ public void received(DieMessage msg){
} }
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
handlePowerCard(msg); handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
logic.getGame().getGameStatistics().increaseCardsPlayed(); logic.getGame().getGameStatistics().increaseCardsPlayed();
@@ -58,21 +59,21 @@ public void received(PlayCardMessage msg){
} }
@Override @Override
public void received(ActivePlayerMessage msg){ public void received(ActivePlayerMessage msg) {
logic.addNotification(new ActivePlayerNotification(msg.getColor())); logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor()); logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()){ if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant(); 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);
for(int i = msg.getTargetIndex() + 1; i < 4; i++){ for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){ if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
pieceToMove.setState(PieceState.HOME); pieceToMove.setState(PieceState.HOME);
break; break;
} }
@@ -84,7 +85,7 @@ public void received(MoveMessage msg){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().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.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else { } 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates; import pp.mdga.client.gamestate.GameStates;
public abstract class DetermineStartPlayerStates extends GameStates { public abstract class DetermineStartPlayerStates extends GameStates {
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage; import pp.mdga.message.server.DieMessage;
import pp.mdga.notification.DiceNowNotification; import pp.mdga.notification.DiceNowNotification;
@@ -28,13 +28,12 @@ public void exit() {
@Override @Override
public void selectDice(){ public void selectDice(){
System.out.println("selectDice");
logic.send(new RequestDieMessage()); logic.send(new RequestDieMessage());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
parent.setState(parent.getWaitRanking()); 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState; import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gameState.turnState.choosePieceState.*; import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.AnimationEndMessage;
import pp.mdga.message.server.*; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.AnimationEndMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.PlayCardNotification; import pp.mdga.notification.PlayCardNotification;
@@ -20,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
handlePowerCard(playCardMessage); handlePowerCard(playCardMessage);
} }

View File

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

View File

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

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates; import pp.mdga.client.gamestate.GameStates;
public abstract class TurnStates extends GameStates { public abstract class TurnStates extends GameStates {
public TurnStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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 abstract class ChoosePieceStates extends TurnStates {
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.message.server.StartPieceMessage; import pp.mdga.message.server.StartPieceMessage;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.SelectableMoveNotification; import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.WaitMoveNotification; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; 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; this.possiblePieces = possiblePieces;
} }
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece) {
ArrayList<Piece> pieces = new ArrayList<>();
if(possiblePieces.contains(piece)){ if(possiblePieces.contains(piece)){
logic.send(new SelectedPiecesMessage(piece.getUuid())); pieces.add(piece);
logic.send(new SelectedPiecesMessage(pieces));
} }
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if(msg.isHomeMove()){ if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); 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 { } else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant()); 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
public class StartPieceState extends ChoosePieceStates { public class StartPieceState extends ChoosePieceStates {
private final ChoosePieceState parent; private final ChoosePieceState parent;
@@ -30,8 +32,10 @@ public void exit() {
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){ 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.Piece;
import pp.mdga.game.PieceState; import pp.mdga.game.PieceState;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
import java.util.List;
public class WaitingPieceState extends ChoosePieceStates { public class WaitingPieceState extends ChoosePieceStates {
private final ChoosePieceState parent; private final ChoosePieceState parent;
@@ -29,8 +32,10 @@ public void exit() {
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece){
ArrayList<Piece> pieces = new ArrayList<>();
if(moveablePiece.equals(piece)){ 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.BonusCard;
import pp.mdga.game.card.*;
import pp.mdga.message.client.NoPowerCardMessage; import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.SelectCardMessage; import pp.mdga.message.client.SelectCardMessage;
import pp.mdga.message.server.DiceNowMessage; import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PlayCardMessage; 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.message.server.PossiblePieceMessage;
import pp.mdga.notification.SelectableCardsNotification; import pp.mdga.notification.SelectableCardsNotification;
@@ -21,7 +22,7 @@
public class ChoosePowerCardState extends PowerCardStates { public class ChoosePowerCardState extends PowerCardStates {
private final PowerCardState parent; private final PowerCardState parent;
private ArrayList<BonusCard> possibleCards; private ArrayList<PowerCard> possibleCards = new ArrayList<>();
/** /**
* Constructor * Constructor
@@ -38,8 +39,6 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
*/ */
@Override @Override
public void enter() { public void enter() {
possibleCards = new ArrayList<>();
//TODO: logic.send(new RequestPossibleCardsMessage());
} }
/** /**
@@ -47,7 +46,7 @@ public void enter() {
*/ */
@Override @Override
public void exit() { public void exit() {
possibleCards = null; possibleCards = new ArrayList<>();
} }
/** /**
@@ -55,9 +54,15 @@ public void exit() {
* @param msg possible cards message * @param msg possible cards message
*/ */
@Override @Override
public void received(PossibleCardMessage msg){ public void received(PossibleCardsMessage msg){
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards(); possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards();
logic.addNotification(new SelectableCardsNotification(possibleCards)); 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 @Override
public void selectCard(BonusCard card){ public void selectCard(BonusCard card){
if(card != null){ if(card != null){
logic.send(new SelectCardMessage(card)); logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card)));
} else { } else {
logic.send(new NoPowerCardMessage()); logic.send(new NoPowerCardMessage());
} }
@@ -79,10 +84,9 @@ public void selectCard(BonusCard card){
*/ */
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg){
if(msg.getCard().equals(BonusCard.TURBO)){ if(msg.getCard().getCard().equals(BonusCard.TURBO)){
logic.getGame().setDiceModifier(msg.getDiceModifier()); parent.getParent().getPlayPowerCard().setPlayCard(msg);
} else { parent.getParent().setState(parent.getParent().getPlayPowerCard());
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
} }
} }

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.ClientGameLogic;
import pp.mdga.client.ClientState; 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 abstract class PowerCardStates extends TurnStates {
public PowerCardStates(ClientState parent, ClientGameLogic logic) { 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; 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.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

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

View File

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

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