From e3219f2b02267188181f94688b8564a0cacb124b Mon Sep 17 00:00:00 2001 From: = Date: Sun, 24 May 2026 14:44:54 +0200 Subject: [PATCH] Docs: Updated javadocs --- .../g40/mappe/view/widgets/WidgetEnum.java | 29 +++++++ .../minigames/GameEngineController.java | 80 +++++++++++++++++++ .../widgets/minigames/GameEngineView.java | 6 -- 3 files changed, 109 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/WidgetEnum.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/WidgetEnum.java index 5efcbb0..9bf85ac 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/WidgetEnum.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/WidgetEnum.java @@ -1,10 +1,39 @@ package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets; +/** + * Enum used to define the various widgets for the application. + * + *

Primarily handled by the {@link edu.ntnu.idi.idatt2003.g40.mappe.view.ingame.InGameController} + * for changing the active section of the game.

+ * */ public enum WidgetEnum { + /** + * {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.dashboard.DashBoardView}. + * */ DASHBOARD, + + /** + * {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.market.MarketView}. + * */ MARKET, + + /** + * {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.minigames.MiniGamesView}. + * */ MINIGAMES_OVERVIEW, + + /** + * {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.minigames.GameEngineView}. + * */ MINIGAMES_ENGINE, + + /** + * {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.stats.StatsView}. + * */ STATS, + + /** + * {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.transactions.TransactionsView}. + * */ TRANSACTIONS } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineController.java index 92a9a22..58912c3 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineController.java @@ -10,19 +10,75 @@ import javafx.animation.Timeline; import javafx.util.Duration; +/** + * Controller for the {@link GameEngineView}. + * + *

Extends {@link ViewController}

+ * */ public final class GameEngineController extends ViewController { + /** + * Current score. + * */ private int currentScore = 0; + + /** + * Current frame for animation loop. + * */ private int frameCounter = 0; + + /** + * Current seconds remaining before minigame + * is over. + * */ private int secondsRemaining = 60; + + /** + * Current rank the player has for this minigame. + * */ private char currentRank = 'E'; + + /** + * String shown to describe the effect of the game, + * based on rank given during report. + * */ private String rankEffectString; + + /** + * The amount of fortune to apply to the chosen stock, + * based on rank gotten. + * */ private double fortuneToSet; + + /** + * Active {@link GameGimmick} implementation. + * */ private GameGimmick activeGimmick; + + /** + * {@link Timeline} object functioning as an animation. + * */ private Timeline engineLoop; + + /** + * Chosen stock to set fortune to based on game results (rank). + * */ private Stock chosenStock; + + /** + * Whether the report is active or not. + * + *

If report is not active, the player can exit without affecting the market. + * If report is active, exiting will cause effect.

+ * */ private boolean reportActive = false; + /** + * Constructor. + * + * @param viewElement the associated {@link GameEngineView}. + * @param chosenStock the chosen {@link Stock} object. + * */ public GameEngineController(final GameEngineView viewElement, final EventManager eventManager, final Stock chosenStock) throws IllegalArgumentException { @@ -52,6 +108,11 @@ protected void initInteractions() { getViewElement().setOnAction(MiniGamesActions.INGAME_RETURN, this::returnToOverview); } + /** + * Launches a given {@link GameGimmick} session. + * + * @param gimmick the gimmick to launch. + * */ public void launchGimmickSession(final GameGimmick gimmick) { activeGimmick = gimmick; currentScore = 0; @@ -70,10 +131,18 @@ public void launchGimmickSession(final GameGimmick gimmick) { engineLoop.play(); } + /** + * Setter method for chosen stock. + * + * @param newStock the new {@link Stock} object to set. + * */ public void setChosenStock(final Stock newStock) { chosenStock = newStock; } + /** + * Refreshes the metrics shown and updates appropriate values. + * */ private void refreshMetrics() { int hours = secondsRemaining / 3600; int minutes = (secondsRemaining % 3600) / 60; @@ -114,6 +183,14 @@ private void refreshMetrics() { getViewElement().updateMetadataDisplay(currentScore, formattedTime, currentRank); } + /** + * Stops the game session. + * + *

If showReport is true, fortune will be set. + * if not, market is unaffected.

+ * + * @param showReport value indicating whether to show report or not. + * */ private void stopGameSession(final boolean showReport) { if (engineLoop != null) { engineLoop.stop(); @@ -124,6 +201,9 @@ private void stopGameSession(final boolean showReport) { } } + /** + * Changes widget to {@link MiniGamesView}. + * */ private void returnToOverview() { EventData eventData = new EventData<>(EventType.CHANGE_INGAME_CENTER, WidgetEnum.MINIGAMES_OVERVIEW); invoke(eventData); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineView.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineView.java index 379d6f7..4a9a710 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/minigames/GameEngineView.java @@ -120,12 +120,6 @@ public void showGameReport(final char rank, rankResultLabel = new Label("Final Rank: " + rank); rankResultLabel.getStyleClass().add("gameEngine-report-rank-result"); - /*String effectText = isPositive - ? "Performance impact: Positive change for " + stockSymbol + " next week! 📈" - : "Performance impact: Negative change for " + stockSymbol + " next week... 📉"; - - - stockEffectLabel.setStyle("-fx-font-size: 18px; -fx-text-fill: " + (isPositive ? "green;" : "red;"));*/ stockEffectLabel = new Label(effect); stockEffectLabel.getStyleClass().add("gameEngine-report-effect");