Skip to content

Commit

Permalink
Feat: Minigames integration
Browse files Browse the repository at this point in the history
Integrated minigames with the application.
It is now possible to select a stock you want to boost in dashboard page. This will take you to the minigames section and select the stock for you.
  • Loading branch information
tommyah committed May 24, 2026
1 parent db2bcfc commit 3ab8e98
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,21 @@ public enum EventType implements EventChannel {
* @see edu.ntnu.idi.idatt2003.g40.mappe.view.ingame.InGameController
*
*/
CHANGE_INGAME_CENTER;
CHANGE_INGAME_CENTER,

/**
* Event type representing events that change the center view to
* {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.minigames.MiniGamesView},
* and selects a given stock for the minigames.
*
* <p>Primarily handled by the active
* {@link edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.minigames.MiniGamesController}
* object.</p>
*
* @see edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.dashboard.DashBoardController
*
*/
SELECT_STOCK_FOR_MINIGAME;

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ public enum DashBoardActions {
/**
* Increasing quantity of shares to buy/sell by five.
* */
INCREASE_5;
INCREASE_5,

/**
* Selecting viewed stock to boost by playing minigames.
* */
MINIGAME;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import edu.ntnu.idi.idatt2003.g40.mappe.engine.Exchange;
import edu.ntnu.idi.idatt2003.g40.mappe.model.*;
import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventData;
import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager;
import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventType;
import edu.ntnu.idi.idatt2003.g40.mappe.utils.Validator;
import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController;
import edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.WidgetEnum;
import javafx.scene.control.Button;
import javafx.scene.control.TextFormatter;
import java.math.BigDecimal;
Expand Down Expand Up @@ -180,6 +183,11 @@ protected void initInteractions() {
.add(new BigDecimal("5")).toString());
});

getViewElement().setOnAction(DashBoardActions.MINIGAME, () -> {
invoke(new EventData<>(EventType.SELECT_STOCK_FOR_MINIGAME, getViewElement().getCurrentStock()));
invoke(new EventData<>(EventType.CHANGE_INGAME_CENTER, WidgetEnum.MINIGAMES_OVERVIEW));
});

exchange.weekProperty().addListener((observable,o,n) -> {
getViewElement().updateGraph(selectedTimeRange);
populateStockList(selectedFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public final class DashBoardView extends ViewElement<HBox, DashBoardActions> {
* */
private Button sellSharesBtn;

/**
* Button to boost this stock.
* */
private Button boostStockBtn;

/**
* The selected stock symbol label.
* */
Expand Down Expand Up @@ -268,7 +273,13 @@ protected void initLayout() {
stockFullNameLabel = new Label();
ownedQuantityLabel = new Label();

stockIdentity.getChildren().addAll(selectedStockLabel, stockFullNameLabel, ownedQuantityLabel);
boostStockBtn = new Button("Boost");
stockIdentity.getChildren().addAll(
selectedStockLabel,
stockFullNameLabel,
ownedQuantityLabel,
boostStockBtn
);

priceStats = new VBox();
selectedStockPriceLabel = new Label();
Expand Down Expand Up @@ -334,6 +345,7 @@ protected void initLayout() {
registerButton(DashBoardActions.DECREASE_1, m1QtyBtn);
registerButton(DashBoardActions.INCREASE_1, p1QtyBtn);
registerButton(DashBoardActions.INCREASE_5, p5QtyBtn);
registerButton(DashBoardActions.MINIGAME, boostStockBtn);
}

private ColumnConstraints makeCol(final float w) {
Expand All @@ -349,6 +361,7 @@ protected void initStyling() {
completeSideBar.getStyleClass().add("dashboard-complete-sidebar");
sidebar.getStyleClass().add("dashboard-sidebar-content");
selectedStockLabel.getStyleClass().add("dashboard-selected-stock-pill");
boostStockBtn.getStyleClass().add("dashboard-selected-stock-pill");
selectedStockPriceLabel.getStyleClass().add("dashboard-selected-stock-pill");
shareQuantityInputField.getStyleClass().add("dashboard-qtyTextField");
chart.getStyleClass().add("dashboard-chart");
Expand Down

0 comments on commit 3ab8e98

Please sign in to comment.