added further notification implemenation

This commit is contained in:
Cedric Beck
2024-11-30 00:33:10 +01:00
parent 13690cf73d
commit 07f0f55192
14 changed files with 164 additions and 60 deletions

View File

@@ -0,0 +1,32 @@
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000076fb04e70b48, pid=112363, tid=112397
#
# JRE version: OpenJDK Runtime Environment Temurin-20.0.2+9 (20.0.2+9) (build 20.0.2+9)
# Java VM: OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (20.0.2+9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C [libLLVM.so.18.1+0x1070b48] llvm::EVT::isExtendedVector() const+0x8
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/cedric/ProgProjekt/Gruppe-01/Projekte/mdga/client/core.112363)
#
# If you would like to submit a bug report, please visit:
# https://github.com/adoptium/adoptium-support/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- S U M M A R Y ------------
Command Line: -Ddebugger.agent.enable.coroutines=true -Djava.util.logging.config.file=logging.properties -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:37129 -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea pp.mdga.client.MdgaApp
Host: AMD Ryzen 5 8640HS w/ Radeon 760M Graphics, 12 cores, 14G, Manjaro Linux
Time: Fri Nov 29 22:02:46 2024 CET elapsed time: 26.893420 seconds (0d 0h 0m 26s)
--------------- T H R E A D ---------------
Current thread (0x000076fbec5e6dd0): JavaThread "jME3 Main" [_thread_in_native, id=112397, stack(0x000076fbd00fe000,0x000076fbd01fe000)]
Stack: [0x000076fbd00fe000,0x000076fbd01fe000], sp=0x000076fbd01f4ef8, free space=987k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libLLVM.so.18.1+0x1070b48] llvm::EVT::isExtendedVector() const+0x8

View File

@@ -96,10 +96,6 @@ else if(boardSelect != null) {
}
if(name.equals("Test") &&isPressed){
if(app.getView() instanceof GameView gameView){
gameView.getGuiHandler().test2();
// gameView.getGuiHandler().showDice();
// gameView.getBoardHandler().showDice(Color.AIRFORCE);
}
}
}

View File

@@ -82,13 +82,14 @@ private void handleGame(Notification notification) {
} else if (notification instanceof DiceNowNotification) {
guiHandler.showDice();
} else if (notification instanceof DicingNotification n) {
//TODO
} else if (notification instanceof DrawCardNotification n) {
//TODO ???
} else if (notification instanceof DrawCardNotification n) {
guiHandler.drawCard(n.getColor());
} else if (notification instanceof HomeMoveNotification home) {
boardHandler.moveHomePiece(home.getPieceId(), home.getHomeIndex());
guiHandler.hideText();
} else if (notification instanceof InterruptNotification) {
//TODO
//TODO ???
} else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) {
//StartMove
@@ -111,11 +112,16 @@ private void handleGame(Notification notification) {
}
} else if (notification instanceof PlayerInGameNotification n) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName(), gameView.getOwnColor() == n.getColor());
guiHandler.addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) {
} else if (notification instanceof RollDiceNotification n) {
guiHandler.rollDice(n.getEyes());
//TODO multiplicator
if(n.getColor() == gameView.getOwnColor()){
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
}
else {
if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
else guiHandler.showRolledDice(n.getEyes(), n.getColor());
}
} else if (notification instanceof SelectableCardsNotification n) {
guiHandler.setSelectableCards(n.getCards());
} else if (notification instanceof ShieldActiveNotification n) {
@@ -126,12 +132,17 @@ private void handleGame(Notification notification) {
app.enter(MdgaState.MAIN);
} else if (notification instanceof SwapPieceNotification n) {
boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
guiHandler.swap();
} else if (notification instanceof WaitMoveNotification) {
//TODO disable all hover, highlight, etc
//TODO ???
} else if (notification instanceof SelectableMoveNotification n) {
boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
} else if (notification instanceof SelectableSwapNotification n) {
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
} else if (notification instanceof SelectableShieldNotification n) {
boardHandler.outlineShield(n.getOwnPieces());
} else if (notification instanceof TurboActiveNotification){
guiHandler.turbo();
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
}

View File

@@ -431,6 +431,21 @@ public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces){
}
}
public void outlineShield(List<UUID> pieces){
selectableOwnPieces.clear();
selectableEnemyPieces.clear();
selectedOwnPiece = null;
selectedEnemyPiece = null;
for (UUID uuid : pieces){
PieceControl p = this.pieces.get(uuid);
p.highlight(false);
p.setHoverable(true);
p.setSelectable(true);
selectableOwnPieces.add(p);
}
}
//called from inputSynchronizer when a piece is selectable
public void pieceSelect(PieceControl pieceSelected) {
boolean isSelected = pieceSelected.isSelected();

View File

@@ -120,6 +120,9 @@ private ColorRGBA playerColorToColorRGBA(Color color){
};
}
public void hide(){
root.detachAllChildren();
}
}

View File

@@ -54,9 +54,9 @@ public void shutdown() {
cardLayer = null;
}
public void rollDice(int rollNum) {
public void rollDice(int rollNum, Runnable actionAfter) {
if (!(1 <= rollNum && rollNum <= 6)) throw new RuntimeException("rollNum is not in the range [1,6]");
diceControl.rollDice(rollNum);
diceControl.rollDice(rollNum, actionAfter);
}
public void showDice() {

View File

@@ -23,7 +23,7 @@ public class DiceControl extends AbstractControl {
private final Vector3f angularVelocity = new Vector3f();
private float deceleration = 0.5f;
private float timeElapsed = 0.0f;
private float rollDuration = 0.0001f;
private float rollDuration = 1f;
private static final int ANGULAR_MIN = 5;
private static final int ANGULAR_MAX = 15;
private static final int ANGULAR_SPIN = 10;
@@ -31,6 +31,7 @@ public class DiceControl extends AbstractControl {
private boolean slerp = false;
private boolean spin = false;
private final AssetManager assetManager;
private Runnable actionAfter;
public DiceControl(AssetManager assetManager){
this.assetManager = assetManager;
@@ -60,13 +61,14 @@ protected void controlUpdate(float tpf) {
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
Quaternion interpolated = spatial.getLocalRotation().clone();
interpolated.nlerp(targetRotation, lerp(timeElapsed));
interpolated.slerp(targetRotation, timeElapsed);
spatial.setLocalRotation(interpolated);
// Stop rolling once duration is complete
if (timeElapsed >= 1.0f) {
isRolling = false;
slerp = false;
actionAfter.run();
}
}
}else if(spin){
@@ -90,11 +92,11 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
}
public void rollDice(int diceNum) {
public void rollDice(int diceNum, Runnable actionAfter) {
if (isRolling) return;
spin = false;
slerp = false;
this.actionAfter = actionAfter;
angularVelocity.set(
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),

View File

@@ -31,8 +31,23 @@ public void shutdown() {
cardLayerHandler.shutdown();
}
public void rollDice(int rollNum) {
cardLayerHandler.rollDice(rollNum);
public void rollDice(int rollNum, int mult) {
cardLayerHandler.rollDice(rollNum, ()->{
if(mult == -1) actionTextHandler.ownDice(rollNum);
else actionTextHandler.ownDiceMult(rollNum, mult);
hideDice();
//TODO send Model finished
});
}
public void showRolledDiceMult(int rollNum, int mult, Color color) {
String name = playerNameHandler.getName(color);
if(mult == -1) actionTextHandler.diceNum(rollNum, name, color);
else actionTextHandler.diceNumMult(rollNum, mult, name, color);
}
public void showRolledDice(int rollNum, Color color) {
actionTextHandler.diceNum(rollNum, playerNameHandler.getName(color), color);
}
public void showDice() {
@@ -67,8 +82,8 @@ public Node getCardLayerRootNode(){
return cardLayerHandler.getCardLayer().getRootNode();
}
public void addPlayer(Color color, String name, boolean own) {
playerNameHandler.addPlayer(color, name, own);
public void addPlayer(Color color, String name) {
playerNameHandler.addPlayer(color, name, color == ownColor);
}
public void setActivePlayer(Color color) {
@@ -78,14 +93,6 @@ public void setActivePlayer(Color color) {
else actionTextHandler.activePlayer(playerNameHandler.getName(color), color);
}
public void test() {
cardLayerHandler.test();
}
public void test2() {
actionTextHandler.drawCardOwn(Color.NAVY);
}
public void shield(){
cardLayerHandler.shield();
}
@@ -97,4 +104,15 @@ public void swap(){
public void turbo(){
cardLayerHandler.turbo();
}
public void hideText(){
actionTextHandler.hide();
}
public void drawCard(Color color) {
if (ownColor == color) actionTextHandler.drawCardOwn(color);
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
}
}

View File

@@ -32,9 +32,6 @@ public GameView(MdgaApp app) {
this.boardHandler = new BoardHandler(app, fpp);
app.getViewPort().addProcessor(fpp);
FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
backFrameBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(Image.Format.Depth));
@@ -54,22 +51,6 @@ public void onEnter() {
boardHandler.init();
guiHandler.init();
continueButton.show();
// boardHandler.addPlayer(Color.AIRFORCE, test);
// boardHandler.movePieceStart(player0, 0);
// boardHandler.enableHover(player0);
// boardHandler.enableHover(player1);
// boardHandler.highlight(player0, true);
// boardHandler.outline(player0, true);
// boardHandler.outline(10);
guiHandler.test();
}
@Override

View File

@@ -15,7 +15,7 @@ public class DrawCardNotification extends Notification {
* @param color the color of the player who drew the card
* @param card the card that was drawn
*/
DrawCardNotification(Color color, BonusCard card) {
DrawCardNotification(Color color) {
this.color = color;
this.card = card;
}

View File

@@ -3,24 +3,32 @@
import pp.mdga.game.Color;
/**
* Notification that a die has been rolled.
* Notification that a dice has been rolled.
*/
public class RollDiceNotification extends Notification{
private Color color;
private int eyes;
private int moveNumber;
private boolean turbo;
private int multiplier;
/**
* Constructor.
* @param color the color of the player that rolled the die.
* @param eyes the number of eyes that were rolled.
* @param moveNumber the number of the move that was made.
*/
RollDiceNotification(Color color, int eyes, int moveNumber) {
RollDiceNotification(Color color, int eyes) {
this.color = color;
this.eyes = eyes;
this.moveNumber = moveNumber;
this.multiplier = -1;
this.turbo = false;
}
RollDiceNotification(Color color, int eyes, boolean turbo, int multiplier) {
this.color = color;
this.eyes = eyes;
this.multiplier = multiplier;
this.turbo = turbo;
}
/**
@@ -39,11 +47,11 @@ public int getEyes() {
return eyes;
}
/**
* Get the number of the move that was made.
* @return the number of the move that was made.
*/
public int getMoveNumber() {
return moveNumber;
public int getMultiplier() {
return multiplier;
}
public boolean isTurbo() {
return turbo;
}
}

View File

@@ -0,0 +1,34 @@
package pp.mdga.notification;
import java.util.List;
import java.util.UUID;
/**
* Notification for selecting pieces for swapcard.
*/
public class SelectableShieldNotification extends Notification{
/**
* List of UUIDs representing the player's own pieces available for selection.
*/
private final List<UUID> ownPieces;
/**
* Constructs a notification for selecting pieces for swapcard.
*
* @param ownPieces the list of the player's own pieces
*/
public SelectableShieldNotification(List<UUID> ownPieces) {
this.ownPieces = ownPieces;
}
/**
* Gets the list of the player's own pieces available for selection.
*
* @return a list of UUIDs representing the player's own pieces
*/
public List<UUID> getOwnPieces() {
return ownPieces;
}
}

View File

@@ -0,0 +1,4 @@
package pp.mdga.notification;
public class TurboActiveNotification extends Notification{
}