Skip to content

Commit

Permalink
Docs: Updated javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyah committed May 24, 2026
1 parent a6591ad commit e3219f2
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets;

/**
* Enum used to define the various widgets for the application.
*
* <p>Primarily handled by the {@link edu.ntnu.idi.idatt2003.g40.mappe.view.ingame.InGameController}
* for changing the active section of the game.</p>
* */
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,75 @@
import javafx.animation.Timeline;
import javafx.util.Duration;

/**
* Controller for the {@link GameEngineView}.
*
* <p>Extends {@link ViewController}</p>
* */
public final class GameEngineController extends ViewController<GameEngineView> {

/**
* 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.
*
* <p>If report is not active, the player can exit without affecting the market.
* If report is active, exiting will cause effect.</p>
* */
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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -114,6 +183,14 @@ private void refreshMetrics() {
getViewElement().updateMetadataDisplay(currentScore, formattedTime, currentRank);
}

/**
* Stops the game session.
*
* <p>If showReport is true, fortune will be set.
* if not, market is unaffected.</p>
*
* @param showReport value indicating whether to show report or not.
* */
private void stopGameSession(final boolean showReport) {
if (engineLoop != null) {
engineLoop.stop();
Expand All @@ -124,6 +201,9 @@ private void stopGameSession(final boolean showReport) {
}
}

/**
* Changes widget to {@link MiniGamesView}.
* */
private void returnToOverview() {
EventData<WidgetEnum> eventData = new EventData<>(EventType.CHANGE_INGAME_CENTER, WidgetEnum.MINIGAMES_OVERVIEW);
invoke(eventData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit e3219f2

Please sign in to comment.