mirror of
				https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
				synced 2025-11-04 04:46:03 +01:00 
			
		
		
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			96a78ee61b
			...
			e98e17f6d7
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					e98e17f6d7 | ||
| 
						 | 
					e337303408 | ||
| 
						 | 
					97619fe662 | ||
| 
						 | 
					246566a211 | 
@@ -67,7 +67,7 @@ public class BoardAppState extends MonopolyAppState {
 | 
			
		||||
     */
 | 
			
		||||
    private PopUpManager popUpManager;;
 | 
			
		||||
 | 
			
		||||
    private Vector3f currentTarget = new Vector3f(-10f,0,-10f);
 | 
			
		||||
    private Vector3f currentTarget = new Vector3f(0f,0,0f);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initializes the state by setting up the sky, lights, and other visual components.
 | 
			
		||||
@@ -99,7 +99,6 @@ public class BoardAppState extends MonopolyAppState {
 | 
			
		||||
        setupScene();
 | 
			
		||||
        if (bobTheBuilder == null) {
 | 
			
		||||
            bobTheBuilder = new BobTheBuilder(getApp(), sceneNode);
 | 
			
		||||
            System.out.println("LISTENER IS REGISTEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
 | 
			
		||||
            getGameLogic().addListener(bobTheBuilder);
 | 
			
		||||
        }
 | 
			
		||||
        getApp().getRootNode().attachChild(viewNode);
 | 
			
		||||
@@ -123,7 +122,7 @@ public class BoardAppState extends MonopolyAppState {
 | 
			
		||||
        final float x = mx - cos;
 | 
			
		||||
        final float y = my - sin;
 | 
			
		||||
        final Camera camera = getApp().getCamera();
 | 
			
		||||
        camera.setLocation(new Vector3f(0,30,0));
 | 
			
		||||
        camera.setLocation(new Vector3f(30,20,0));
 | 
			
		||||
        camera.lookAt(new Vector3f(getCurrentTarget()),
 | 
			
		||||
                                    Vector3f.UNIT_Y);
 | 
			
		||||
        camera.update();
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ public class BobTheBuilder extends GameBoardSynchronizer {
 | 
			
		||||
 | 
			
		||||
        // Setze die Rotation basierend auf der Feld-ID
 | 
			
		||||
        node.setLocalRotation(figure.getRot().toQuaternion());
 | 
			
		||||
        node.addControl(new  FigureControl(spatial, figure, app));
 | 
			
		||||
        node.addControl(new  FigureControl(node, figure, app));
 | 
			
		||||
        return node;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,25 +1,29 @@
 | 
			
		||||
package pp.monopoly.client.gui;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.FastMath;
 | 
			
		||||
import com.jme3.math.Quaternion;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.renderer.RenderManager;
 | 
			
		||||
import com.jme3.renderer.ViewPort;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.control.AbstractControl;
 | 
			
		||||
 | 
			
		||||
import pp.monopoly.client.MonopolyApp;
 | 
			
		||||
import pp.monopoly.game.client.ClientGameLogic;
 | 
			
		||||
import pp.monopoly.model.Figure;
 | 
			
		||||
import pp.monopoly.notification.GameEventListener;
 | 
			
		||||
import pp.monopoly.notification.UpdatePlayerView;
 | 
			
		||||
 | 
			
		||||
import java.lang.System.Logger;
 | 
			
		||||
import java.lang.System.Logger.Level;
 | 
			
		||||
import java.util.LinkedList;
 | 
			
		||||
import java.util.Queue;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class FigureControl extends AbstractControl implements GameEventListener {
 | 
			
		||||
 | 
			
		||||
    private static final Logger LOGGER = System.getLogger(FigureControl.class.getName());
 | 
			
		||||
    private final Figure figure;
 | 
			
		||||
    private final Spatial spatial;
 | 
			
		||||
    private final Node spatial;
 | 
			
		||||
    private final MonopolyApp app;
 | 
			
		||||
    private Queue<Vector3f> path; // Path to follow
 | 
			
		||||
    private Vector3f currentTarget;
 | 
			
		||||
@@ -29,7 +33,7 @@ public class FigureControl extends AbstractControl implements GameEventListener
 | 
			
		||||
    private float delayElapsed = 0f; // Zeit, die seit dem Start der Verzögerung vergangen ist
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public FigureControl(Spatial spatial, Figure figure, MonopolyApp app) {
 | 
			
		||||
    public FigureControl(Node spatial, Figure figure, MonopolyApp app) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.figure = figure;
 | 
			
		||||
        this.spatial = spatial;
 | 
			
		||||
@@ -46,14 +50,14 @@ public class FigureControl extends AbstractControl implements GameEventListener
 | 
			
		||||
                return; // Warte, bis die Verzögerung abgeschlossen ist
 | 
			
		||||
            }
 | 
			
		||||
            delayTime = 0; // Verzögerung abgeschlossen
 | 
			
		||||
            System.out.println("Delay completed. Starting animation...");
 | 
			
		||||
            LOGGER.log(Level.DEBUG, "Delay completed. Starting animation...");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (currentTarget == null && !path.isEmpty()) {
 | 
			
		||||
            // Hole das nächste Ziel aus dem Pfad
 | 
			
		||||
            currentTarget = path.poll();
 | 
			
		||||
            animationTime = 0f;
 | 
			
		||||
            System.out.println("Next target: " + currentTarget);
 | 
			
		||||
            LOGGER.log(Level.DEBUG, "Next target: {0}", currentTarget);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (currentTarget != null) {
 | 
			
		||||
@@ -75,18 +79,19 @@ public class FigureControl extends AbstractControl implements GameEventListener
 | 
			
		||||
                spatial.setLocalTranslation(currentTarget);
 | 
			
		||||
                figure.moveTo(currentTarget); // Synchronisiere die interne Position
 | 
			
		||||
                currentTarget = null; // Setze Ziel zurück
 | 
			
		||||
                System.out.println("Target reached.");
 | 
			
		||||
 | 
			
		||||
                LOGGER.log(Level.DEBUG, "Target reached. Remaining path: {0}", path.size());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Beispiel: Berechnung des nächsten Feldes
 | 
			
		||||
private int nextField() {
 | 
			
		||||
    int currentField = figure.getCurrentFieldID();
 | 
			
		||||
    return (currentField + 1) % 40; // Weiter zum nächsten Feld
 | 
			
		||||
}
 | 
			
		||||
    // Beispiel: Berechnung des nächsten Feldes
 | 
			
		||||
    private int nextField() {
 | 
			
		||||
        int currentField = figure.getCurrentFieldID();
 | 
			
		||||
        return (currentField + 1) % 40; // Weiter zum nächsten Feld
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
@@ -96,33 +101,35 @@ private int nextField() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPath(int startField, int endField) {
 | 
			
		||||
        System.out.println("setPath called with startField: " + startField + ", endField: " + endField);
 | 
			
		||||
        LOGGER.log(Level.TRACE, "setPath called with startField: {0} to endField {1}", startField, endField);
 | 
			
		||||
        path.clear();
 | 
			
		||||
        for (int fieldId = startField; fieldId != endField; fieldId = (fieldId + 1) % 40) {
 | 
			
		||||
            Vector3f position = figure.calculateFieldPosition(fieldId);
 | 
			
		||||
            System.out.println("Adding position to path: " + position);
 | 
			
		||||
            LOGGER.log(Level.DEBUG, "Adding postition to path: {0}", position);
 | 
			
		||||
            path.add(position);
 | 
			
		||||
        }
 | 
			
		||||
        Vector3f finalPosition = figure.calculateFieldPosition(endField);
 | 
			
		||||
        path.add(finalPosition);
 | 
			
		||||
        System.out.println("Final position added to path: " + finalPosition);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Final position added to path: {0}", finalPosition);
 | 
			
		||||
        
 | 
			
		||||
        System.out.println("Path size: " + path.size());
 | 
			
		||||
        
 | 
			
		||||
        LOGGER.log(Level.TRACE, "Path size: {0}", path.size());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void receivedEvent(UpdatePlayerView event) {
 | 
			
		||||
        System.out.println("Event received: " + event);
 | 
			
		||||
        LOGGER.log(Level.TRACE, "receivedEvent called with event: {0}", event);
 | 
			
		||||
        
 | 
			
		||||
        int newPos = app.getGameLogic().getPlayerHandler().getPlayerById(figure.getId()).getFieldID();
 | 
			
		||||
        int currentField = figure.getCurrentFieldID();
 | 
			
		||||
 | 
			
		||||
        if (currentField == newPos) {
 | 
			
		||||
            System.out.println("Figure is already at the correct position. No path set.");
 | 
			
		||||
            LOGGER.log(Level.DEBUG, "No movement required. Current field: {0}, New field: {1}", currentField, newPos);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        System.out.println("Movement required. Current field: " + currentField + ", New field: " + newPos);
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Movement required. Current field: {0}, New field: {1}", currentField, newPos);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        setPath(currentField, newPos);
 | 
			
		||||
        delayTime = 3f; // Verzögerung zurücksetzen
 | 
			
		||||
 
 | 
			
		||||
@@ -325,7 +325,6 @@ public class LobbyMenu extends Dialog {
 | 
			
		||||
            figure = selector.getSelectedItem();
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("FIGUR:::::"+figure);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -381,7 +381,7 @@ public class Toolbar extends Dialog implements GameEventListener {
 | 
			
		||||
                    showFinalDiceResult(latestDiceRollEvent);
 | 
			
		||||
                }
 | 
			
		||||
            } catch (InterruptedException e) {
 | 
			
		||||
                System.err.println("Dice animation interrupted: " + e.getMessage());
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
        }).start();
 | 
			
		||||
    }
 | 
			
		||||
@@ -527,7 +527,6 @@ public class Toolbar extends Dialog implements GameEventListener {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void receivedEvent(ButtonStatusEvent event) {
 | 
			
		||||
        System.out.println("Button status event received: " + event.buttonsEnabled()+ "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG");
 | 
			
		||||
        boolean enabled = event.buttonsEnabled();
 | 
			
		||||
        canRollDice = enabled;
 | 
			
		||||
        tradeButton.setEnabled(enabled);
 | 
			
		||||
 
 | 
			
		||||
@@ -910,7 +910,6 @@
 | 
			
		||||
         }
 | 
			
		||||
         sliderhorsetup();
 | 
			
		||||
         adjustothercolumnmodel();
 | 
			
		||||
         //     System.out.println("Columns available: " +availableColumns);
 | 
			
		||||
     }
 | 
			
		||||
 
 | 
			
		||||
     @StyleAttribute(value="visibleColumns")
 | 
			
		||||
@@ -923,7 +922,6 @@
 | 
			
		||||
         sliderhorsetup();
 | 
			
		||||
         grid.refreshGrid();
 | 
			
		||||
         refreshSelector();
 | 
			
		||||
         //  System.out.println("Columns visble: " +grid.getVisibleColumns());
 | 
			
		||||
     }
 | 
			
		||||
 
 | 
			
		||||
     // Column Operations
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,6 @@ public class BuildingPropertyCard extends Dialog {
 | 
			
		||||
        Button quitButton = buildingPropertyContainer.addChild(new Button("Beenden", new ElementId("button")));
 | 
			
		||||
        quitButton.setFontSize(32);
 | 
			
		||||
        quitButton.addClickCommands(s -> ifTopDialog( () -> {
 | 
			
		||||
            System.err.println("Button does something?");
 | 
			
		||||
            app.getGameLogic().playSound(Sound.BUTTON);
 | 
			
		||||
            close();
 | 
			
		||||
        }));
 | 
			
		||||
 
 | 
			
		||||
@@ -119,13 +119,7 @@ public class SellHouse extends Dialog {
 | 
			
		||||
        confirmButton.addClickCommands(s -> ifTopDialog( () -> {
 | 
			
		||||
            app.getGameLogic().playSound(Sound.BUTTON);
 | 
			
		||||
            AlterProperty msg = new AlterProperty("SellHouse");
 | 
			
		||||
            for (String string : selectedProperties) {
 | 
			
		||||
                System.out.println(string);
 | 
			
		||||
            }
 | 
			
		||||
            msg.setProperties(selectedProperties.stream().map(p -> app.getGameLogic().getBoardManager().getFieldByName(p).getId()).map(p -> (Integer) p).collect(Collectors.toSet()));
 | 
			
		||||
            for (Integer integer : msg.getProperties()) {
 | 
			
		||||
                System.out.println("ID des verkaufs: "+integer);
 | 
			
		||||
            }
 | 
			
		||||
            app.getGameLogic().send(msg);
 | 
			
		||||
            close();
 | 
			
		||||
        }));
 | 
			
		||||
 
 | 
			
		||||
@@ -253,7 +253,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayerStatusUpdate msg) {
 | 
			
		||||
        playerHandler = msg.getPlayerHandler();
 | 
			
		||||
        System.out.println("Update Player");
 | 
			
		||||
        LOGGER.log(Level.TRACE, "Update Player View triggerd with message: {0}", msg);
 | 
			
		||||
        notifyListeners(new UpdatePlayerView());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -317,7 +317,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(BuildInfo msg) {
 | 
			
		||||
        System.out.println("TRIGGER BUILD INFO");
 | 
			
		||||
        if (msg.isAdded()) {
 | 
			
		||||
            BuildingProperty property = ((BuildingProperty)boardManager.getFieldAtIndex(msg.getId()));
 | 
			
		||||
            if (property.getHotel() == 1 ) {
 | 
			
		||||
 
 | 
			
		||||
@@ -168,7 +168,6 @@ public class ServerGameLogic implements ClientInterpreter {
 | 
			
		||||
            PropertyField property = (PropertyField) boardManager.getFieldAtIndex(player.getFieldID()); // Assuming player position for property
 | 
			
		||||
            
 | 
			
		||||
            player.buyProperty(property);
 | 
			
		||||
            System.out.println("Properties:" +player.getProperties().toString());
 | 
			
		||||
            LOGGER.log(Level.INFO, "Player {0} bought property {1}", player.getName(), property.getName());
 | 
			
		||||
        }
 | 
			
		||||
        updateAllPlayers();
 | 
			
		||||
 
 | 
			
		||||
@@ -150,7 +150,7 @@ public class Figure implements Item{
 | 
			
		||||
        float zOffset = new Random().nextFloat();
 | 
			
		||||
 | 
			
		||||
        //TODO adjust y pos
 | 
			
		||||
        return new Vector3f(baseX , 1, baseZ );
 | 
			
		||||
        return new Vector3f(baseX , 0, baseZ );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getCurrentFieldID() {
 | 
			
		||||
@@ -158,7 +158,6 @@ public class Figure implements Item{
 | 
			
		||||
        for (int fieldID = 0; fieldID < 40; fieldID++) {
 | 
			
		||||
            Vector3f fieldPosition = calculateFieldPosition(fieldID);
 | 
			
		||||
            if (pos.distance(fieldPosition) < 0.1f) { // Toleranz für Positionsvergleich
 | 
			
		||||
                System.out.println("Current field ID: " + fieldID);
 | 
			
		||||
                return fieldID;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -274,6 +274,7 @@ public class DeckHelper{
 | 
			
		||||
        private void dienstreiseLourd(Player player) {
 | 
			
		||||
            player.pay(1000);
 | 
			
		||||
            player.getHandler().getLogic().received(new EndTurn(), player.getId());
 | 
			
		||||
            player.getHandler().getLogic().send(player, new NotificationMessage("aussetzen"));
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        private void blutspendenSonderurlaub(Player player) {
 | 
			
		||||
@@ -298,6 +299,7 @@ public class DeckHelper{
 | 
			
		||||
    
 | 
			
		||||
        private void partyEskaliert(Player player) {
 | 
			
		||||
            player.getHandler().getLogic().received(new EndTurn(), player.getId());
 | 
			
		||||
            player.getHandler().getLogic().send(player, new NotificationMessage("aussetzen"));
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        private void vpEinstandsparty(Player player) {
 | 
			
		||||
@@ -310,6 +312,7 @@ public class DeckHelper{
 | 
			
		||||
    
 | 
			
		||||
        private void bergmarsch(Player player) {
 | 
			
		||||
            player.getHandler().getLogic().received(new EndTurn(), player.getId());
 | 
			
		||||
            player.getHandler().getLogic().send(player, new NotificationMessage("aussetzen"));
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        private void jodelEispenis(Player player) {
 | 
			
		||||
 
 | 
			
		||||
@@ -801,8 +801,6 @@ public class ServerGameLogicTest {
 | 
			
		||||
 | 
			
		||||
        player.buyProperty(property);
 | 
			
		||||
 | 
			
		||||
        System.out.println("Player Balance: " + player.getAccountBalance());
 | 
			
		||||
        System.out.println("Player Properties: " + player.getProperties());
 | 
			
		||||
        assertEquals(14000, player.getAccountBalance());
 | 
			
		||||
        assertTrue(player.getProperties().contains(property.getId()));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user