Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Comments

feat: Add PowerUp class#5

Merged
thnhmai06 merged 2 commits intoCodeStormOOP:mainfrom
thnhmai06:main
Sep 30, 2025
Merged

feat: Add PowerUp class#5
thnhmai06 merged 2 commits intoCodeStormOOP:mainfrom
thnhmai06:main

Conversation

@thnhmai06
Copy link
Member

No description provided.

- Introduced PowerUp class to manage special effects and abilities for game objects (provides lazy-update functionality).
- Updated build.gradle to include JavaFX plugin and specified version.
- Modified project configuration files for compatibility with new features.
- Corrected the description of PowerUps to use plural form for consistency.
- Improved clarity in the apply and unapply method descriptions (automatically used when power up becomes active/ends).
Copilot AI review requested due to automatic review settings September 30, 2025 18:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new PowerUp abstract class that provides a framework for implementing timed power-up effects in the game. The class manages automatic activation and deactivation of power-ups using FXGL's timer system.

  • Implements timer-based activation/deactivation system for power-ups
  • Provides abstract methods for applying and unapplying effects
  • Includes multiple constructors for different initialization patterns
Files not reviewed (2)
  • .idea/google-java-format.xml: Language not supported
  • .idea/misc.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@thnhmai06 thnhmai06 requested a review from Copilot September 30, 2025 18:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 5 changed files in this pull request and generated 3 comments.

Files not reviewed (2)
  • .idea/google-java-format.xml: Language not supported
  • .idea/misc.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 113 to 115
this(
FXGL.getGameTimer().getNow() + after.toMillis(),
FXGL.getGameTimer().getNow() + after.toMillis() + duration.toMillis());
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The game timer is called twice unnecessarily. Store the current time in a variable to avoid the duplicate call: double currentTime = FXGL.getGameTimer().getNow();

Suggested change
this(
FXGL.getGameTimer().getNow() + after.toMillis(),
FXGL.getGameTimer().getNow() + after.toMillis() + duration.toMillis());
double currentTime = FXGL.getGameTimer().getNow();
this(
currentTime + after.toMillis(),
currentTime + after.toMillis() + duration.toMillis());

Copilot uses AI. Check for mistakes.
@thnhmai06 thnhmai06 requested a review from Copilot September 30, 2025 18:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 5 changed files in this pull request and generated 2 comments.

Files not reviewed (2)
  • .idea/google-java-format.xml: Language not supported
  • .idea/misc.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member Author

@thnhmai06 thnhmai06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +26 to +51
private void updateWaitAction() {
final var gameTimer = FXGL.getGameTimer();
final var currentTime = gameTimer.getNow();
// when not executed
if (currentTime < startAt) {
if (waitAction != null) {
waitAction.expire();
}
final var timeLeft = Duration.millis(startAt - currentTime);
waitAction = gameTimer.runOnceAfter(this::doApply, timeLeft);
}
}

/** Update {@code activeAction} when {@code endAt} is changed. */
private void updateActiveAction() {
final var gameTimer = FXGL.getGameTimer();
final var currentTime = gameTimer.getNow();
// when not executed
if (currentTime < endAt) {
if (activeAction != null) {
activeAction.expire();
}
final var timeLeft = Duration.millis(endAt - currentTime);
activeAction = gameTimer.runOnceAfter(this::doUnapply, timeLeft);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need situation for startAt >= currentTime, and checking if startAt >= endAt

@thnhmai06 thnhmai06 merged commit 226aa86 into CodeStormOOP:main Sep 30, 2025
2 checks passed
thnhmai06 added a commit that referenced this pull request Oct 27, 2025
* feat: add PowerUp class

- Introduced PowerUp class to manage special effects and abilities for game objects (provides lazy-update functionality).
- Updated build.gradle to include JavaFX plugin and specified version.
- Modified project configuration files for compatibility with new features.

* docs: update PowerUp class documentation

- Corrected the description of PowerUps to use plural form for consistency.
- Improved clarity in the apply and unapply method descriptions (automatically used when power up becomes active/ends).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant