Skip to content

Einar/deployment #143

Merged
merged 2 commits into from
May 25, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -60,14 +65,65 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Millions</mainClass>
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Launcher</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.12.0</version>
</plugin>

<!-- Fat JAR builder -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Launcher</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>

<!-- .dmg packager -->
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<name>Millions</name>
<appVersion>1.0.0</appVersion>
<vendor>edu.ntnu.idi.idatt2003.gruppe42</vendor>
<input>target</input>
<destination>target/dist</destination>
<mainJar>Millions-1.0-SNAPSHOT.jar</mainJar>
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Launcher</mainClass>
<type>DMG</type>
<icon>src/main/resources/images/app_icon.icns</icon>
<javaOptions>
<option>-Dfile.encoding=UTF-8</option>
</javaOptions>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Launcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package edu.ntnu.idi.idatt2003.gruppe42;

public class Launcher {
public static void main(String[] args) {
Millions.launch(Millions.class, args);
}
}
9 changes: 5 additions & 4 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
import edu.ntnu.idi.idatt2003.gruppe42.view.views.DesktopView;
import edu.ntnu.idi.idatt2003.gruppe42.view.views.StartView;
import java.nio.file.Path;

import java.io.InputStream;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
Expand Down Expand Up @@ -63,17 +64,17 @@ public void start(final Stage stage) {
*
* @param username the player name
* @param difficulty selected game difficulty
* @param userSelectedPath path to stock data file
* @param stocksStream path to stock data file
* @param popupsController controller managing popups
*/
public void initGame(final String username, final Difficulty difficulty,
Path userSelectedPath, PopupsController popupsController) {
InputStream stocksStream, PopupsController popupsController) {
player = GameFactory.createPlayer(username, difficulty);
gameController = new GameController();
gameController.startGame();

desktopViewController = new DesktopViewController(player, gameController,
userSelectedPath, popupsController);
stocksStream, popupsController);
desktopViewController.setOnGameOver(this::resetGame);
desktopView = desktopViewController.getDesktopView();
scene.setRoot(desktopView.getRoot());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/Audio.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
public enum Audio {

// Sound effects
OPEN_APP("/Audio/open_app.wav", true),
CLOSE_APP("/Audio/close_app.wav", true),
CLOCK("/Audio/clock.wav", true),
OPEN_APP("/audio/open_app.wav", true),
CLOSE_APP("/audio/close_app.wav", true),
CLOCK("/audio/clock.wav", true),

// Background music
WORK_THEME("/Audio/work_theme.mp3", false),
WEEKEND_THEME("/Audio/weekend_theme.mp3", false);
WORK_THEME("/audio/work_theme.mp3", false),
WEEKEND_THEME("/audio/weekend_theme.mp3", false);

private final String path;
private final boolean isSfx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private AudioManager() {
}
}

// Keep background music volume in sync with master × 0.5 (bg is quieter)
// Keep background music volume in sync with master × 0.5 (bg should be quieter for UX)
masterVolume.addListener((obs, ov, nv) -> {
if (bgPlayer != null) {
bgPlayer.setVolume(nv.doubleValue() * 0.5);
Expand Down Expand Up @@ -80,7 +80,6 @@ public void playSfx(final Audio audio) {
Clip clip = AudioSystem.getClip();
clip.open(stream);

// Apply volume via MASTER_GAIN
if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
FloatControl gain = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
float db = volumeToDb(volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import edu.ntnu.idi.idatt2003.gruppe42.model.StockFileHandler;
import edu.ntnu.idi.idatt2003.gruppe42.model.exceptions.StockFileParseException;
import java.io.IOException;
import java.nio.file.Path;
import java.io.InputStream;
import java.util.List;

/**
Expand All @@ -18,12 +18,12 @@ public final class MarketController {
/**
* Creates a new market controller and loads stock data from a file.
*
* @param path the path to the stock data file
* @param stocksStream the path to the stock data file
*/
public MarketController(Path path) {
public MarketController(InputStream stocksStream) {
this.stockResolution = 120;
try {
exchange = new Exchange(StockFileHandler.readFromFile(path));
exchange = new Exchange(StockFileHandler.readFromFile(stocksStream));
startMarket();
System.out.println("Market loaded");
} catch (IOException exception) {
Expand Down
Loading