Skip to content
Open
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
24 changes: 24 additions & 0 deletions src/main/java/event/Event02.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,41 @@

import main.GameManager;

/**
* This class manages the scenes and actions for Event02
*/

public class Event02 {

GameManager gm;

/**
* Sets up Event02 with the game manager.
*
* @param gm the main game manager
*/
public Event02(GameManager gm) {

this.gm = gm;
}

/**
* Checks the first spot on the Honda.
*/
public void search1Honda() {
gm.ui.messageText.setText("Nothing sus here");
}

/**
* Checks the second spot on the Honda.
*/
public void search2Honda() {
gm.ui.messageText.setText("OH MY GYAT MY ENGINE IS MISSING");
}

/**
* Lets the player rest on the Honda and heal life.
*/
public void restHonda() {
if(gm.player.playerLife != gm.player.playerMaxLife) {
gm.ui.messageText.setText("*You rest on the hood of your car*\n(Your life has been recovered)");
Expand All @@ -29,4 +50,7 @@ public void restHonda() {

}
}
// TODO: Make sure the game manager (gm) is not null in the constructor.
// TODO: Combine repeated actions like updating player status into a helper method.
// TODO: Check that player life values are not negative to avoid errors.
}
23 changes: 23 additions & 0 deletions src/main/java/event/Event03.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,45 @@

import main.GameManager;

/**
* Handles scenes and actions for Event03.
*/
public class Event03 {

GameManager gm;

/**
* Sets up Event03 with the game manager.
*
* @param gm the main game manager
*/
public Event03(GameManager gm) {

this.gm = gm;
}

/**
* Shows the description of the Hondaur.
*/
public void lookHondaur() {
gm.ui.messageText.setText("Its a Hondaur");
}

/**
* Describes the interaction with the Hondaur.
*/
public void talkHondaur() {
gm.ui.messageText.setText("The Hondaur growls at you and revs his engine ");
}

/**
* Explains the player's attack on the Hondaur.
*/
public void attackHondaur() {
gm.ui.messageText.setText("*You start beating the shit out of the poor Hondaur*");

}

// TODO: Check that the game manager (gm) is not null when this class is created.
// TODO: Add error handling for sounds in case they are missing or invalid.
}
24 changes: 24 additions & 0 deletions src/main/java/event/Event04.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@

import main.GameManager;

/**
* Manages scenes and actions for Event04.
*/
public class Event04 {

GameManager gm;

/**
* Sets up Event04 with the game manager.
*
* @param gm the main game manager
*/
public Event04(GameManager gm) {

this.gm = gm;
}

/**
* Shows the description of Denzel.
*/
public void lookDenzel() {
gm.ui.messageText.setText("This is Denzel. (He listens to Valorant music)");
}

/**
* Lets Denzel give the player a pistol if they don't already have one.
*/
public void talkDenzel() {
if(gm.player.hasPistol == 0) {
gm.player.hasPistol = 1;
Expand All @@ -26,6 +42,10 @@ public void talkDenzel() {
gm.playSE(gm.cannotSound);
}
}

/**
* Lets the player recover life with Denzel's help.
*/
public void restDenzel() {
if(gm.player.playerLife != gm.player.playerMaxLife) {
gm.ui.messageText.setText("(Denzel has been lonely without his girlfriend)\n*Denzel runs up to you unexpectedly and gives you a hug*\n(Your life has been recovered)");
Expand All @@ -39,4 +59,8 @@ public void restDenzel() {
gm.playSE(gm.cannotSound);
}
}

// TODO: Check that the game manager (gm) is not null when the class is created.
// TODO: Create a helper method for repeated life recovery code.
// TODO: Make sure the pistol value (hasPistol) is either 0 or 1 only.
}
24 changes: 24 additions & 0 deletions src/main/java/event/Event05.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@

import main.GameManager;

/**
* Manages scenes and actions for Event05.
*/
public class Event05 {

GameManager gm;

/**
* Sets up Event05 with the game manager.
*
* @param gm the main game manager
*/
public Event05(GameManager gm) {

this.gm = gm;
}

/**
* Shows that Brian is in the Honda trunk.
*/
public void lookHondaTrunk() {
if(gm.player.hasPistol == 1){
gm.ui.messageText.setText("IS THAT BRIAN FROM MARAUDER CODED!");
Expand All @@ -18,6 +30,10 @@ public void lookHondaTrunk() {
gm.ui.messageText.setText("(You see Brian's dead body)");
}
}

/**
* Talks to the Honda trunk.
*/
public void talkHondaTrunk() {
if(gm.theodoor.currentLife==0 && gm.wheeler.currentLife==0) {
if(gm.player.hasPistol == 1){
Expand All @@ -32,6 +48,10 @@ public void talkHondaTrunk() {
gm.playSE(gm.cannotSound);
}
}

/**
* Ends Brian's misery in the Honda trunk.
*/
public void killHondaTrunk() {

if(gm.theodoor.currentLife == 0 && gm.wheeler.currentLife == 0) {
Expand All @@ -51,4 +71,8 @@ public void killHondaTrunk() {
}

}

// TODO: Add checks to ensure game objects like gm and player are valid.
// TODO: Restructure repeated conditions like checking currentLife into a helper method to make sure there's no code duplication and so readbility could be better since it makes sure the purpose of the condition is clear.
// TODO: Add a log to track when the pistol state (hasPistol) changes
}
41 changes: 39 additions & 2 deletions src/main/java/event/Event06.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,49 @@
import javafx.scene.image.ImageView;
import main.GameManager;

/**
* Handles scenes and actions for Event06.
*/
public class Event06 {
GameManager gm;
private ImageView denzel;

/**
* Sets up Event06 with the game manager.
*
* @param gm the main game manager
*/
public Event06(GameManager gm) {

this.gm = gm;
}

/**
* Resets Denzel's visibility.
*/
public void reset(){
if (denzel != null) {
denzel.setVisible(false);
}
}


/**
* Shows Denzel.
*/
public void lookDenzel(){
gm.ui.messageText.setText("Denzel shows up");
}

/**
* Talks to Denzel.
*/
public void talkDenzel(){
gm.ui.messageText.setText("I got worried for you so I ran after you");

}

/**
* Plays Valorant music to cheer up Denzel.
*/
public void playDenzel(){

if(gm.player.hasAk47 == 0) {
Expand All @@ -40,12 +62,23 @@ public void playDenzel(){

}

/**
* Shows Brandon.
*/
public void lookBrandon() {
gm.ui.messageText.setText("This is Brandon. He seems to be doing a fit check");
}

/**
* Talks to Brandon.
*/
public void talkBrandon() {
gm.ui.messageText.setText("Yo I wouldn't go in there if I were you! A monster is on the loose!");
}

/**
* Lets the player rest and recover life with Brandon's help.
*/
public void restBrandon() {
if(gm.player.playerLife != gm.player.playerMaxLife) {
gm.ui.messageText.setText("You look injured... Come here\n*Brandon gives you a warm hug*\n(You gain life)");
Expand All @@ -70,4 +103,8 @@ public void restBrandon() {
}

}

// TODO: Check if gm and Denzel are not null before using them.
// TODO: Create a method to play sounds instead of repeating the code.
// TODO: Make sure hasAk47 is valid before using it.
}
24 changes: 24 additions & 0 deletions src/main/java/event/Event07.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,37 @@

import main.GameManager;

/**
* Manages scenes and actions for Event07.
*/
public class Event07 {

GameManager gm;
public int julianLife = 2;

/**
* Sets up Event07 with the game manager.
*
* @param gm the main game manager
*/
public Event07(GameManager gm) {

this.gm = gm;
}

/**
* Shows Julian and his current condition.
*/
public void lookJulian() {
gm.ui.messageText.setText("Julian is in serious condition");
if(julianLife ==0) {
gm.ui.messageText.setText("You see Julien's lifeless body");
}
}

/**
* Talks to Julian.
*/
public void talkJulian() {
if(julianLife == 2 || julianLife == 1) {
gm.ui.messageText.setText("*Julian cries when he sees you* I don't want to die...");
Expand All @@ -26,6 +42,10 @@ public void talkJulian() {
gm.playSE(gm.cannotSound);
}
}

/**
* Comforts Julian and updates his state.
*/
public void holdJulian() {
if(julianLife == 2) {
gm.ui.messageText.setText("*You hold Julian's hand and tell him it'll be okay*\nJulian says his last words: Can you spin it one last time for me?");
Expand Down Expand Up @@ -73,4 +93,8 @@ public void thankAdrian() {
gm.ui.messageText.setText("*You thank Adrian for his great efforts*\n (Adrian will give you 10% of his profits if you avenge Julian)");

}

// TODO: Add checks for null or invalid game manager and player objects.
// TODO: Ensure Julian's life values are limited to valid states (0, 1, 2).
// TODO: Simplify repeated messages and conditions into a helper function.
}
8 changes: 7 additions & 1 deletion src/main/java/main/ActionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import javafx.event.EventHandler;

public class ActionHandler implements EventHandler<ActionEvent> {

// TODO: Add a class-level Javadoc to explain the purpose of this class
// TODO: Ensure class names and methods follow naming conventions
// TODO: Use meaningful variable names for 'yourChoice', like 'buttonText'
GameManager gm;

public ActionHandler(GameManager gm) {
Expand All @@ -16,12 +18,16 @@ public ActionHandler(GameManager gm) {

@Override
public void handle(ActionEvent e) {
// TODO: Catch exceptions to handle unexpected errors when casting or processing button actions
String yourChoice = ((javafx.scene.control.Button) e.getSource()).getText();
handleAction(yourChoice);
}

// handles the action commands
public void handleAction(String yourChoice) {
// TODO: Use a Map or more efficient structure to store button actions instead of switch-case
// TODO: Add comments for each section of switch-case to describe what each block does
// TODO: Add input validation for 'yourChoice' to avoid NullPointerExceptions
switch (yourChoice) {
// SCENE 1
case "lookJeramiah":
Expand Down
Loading