Skip to content

Feature 62: Automatic game end - #80

Open
tommy33790 wants to merge 16 commits into
devfrom
62-initiate-automatic-game-end-after-a-certain-amount-of-time
Open

tommy33790 wants to merge 16 commits into
devfrom
62-initiate-automatic-game-end-after-a-certain-amount-of-time

Conversation

@tommy33790

Copy link
Copy Markdown
Contributor

📜 Description

Changes proposed in this pull request:

  • Closes Initiate automatic game end after a certain amount of time #62
  • Adds two time inputs in configuration screen for automatic game end and calculation
    • Decided against adding them as a menu control (like SpeedcontrolFrame) to prevent issues with saving values or changing them after starting a level
  • Fixes unchanged inital delay in LevelMenuPanel (after changing game speed the initial delay was still 1000ms)
  • Fixes ignored initial game speed factor in LevelMenuPanelwhen changing it while in configuration screen
  • I have to admit that the whole PR is a bit hacky (especially the call to finalizeGame)

🔨 Breaking Changes

  • None that I'm aware of

✅ Checklist:

  • Created tests which fail without the change (if possible)
  • Extended the documentation (if necessary)
  • Checked the checklist and figures that nothing on it is possible

📸 Screenshots

Screenshots to review the UX/UI Design:
grafik

@DivineThreepwood DivineThreepwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for putting this together! I have a few concerns that I’d like to address before we move forward.

From a code perspective, there is currently quite a bit of boilerplate, and some parts feel more complex than necessary. The implementation also follows a rather Java-oriented style in several places. Since this is Kotlin, I’d prefer to simplify and make the code more idiomatic where possible.

I also think we could improve the separation of concerns. At the moment, the Game Manager is taking on quite a lot of responsibility, and the game start/stop flows are becoming rather large as a result. It might be worth restructuring this so that these responsibilities are separated more clearly.

From a UX perspective, I’m also not fully convinced by the current placement of the settings. I would prefer to have them in the top menu. In addition, the current alignment and positioning of the visual components feels a little inconsistent and could benefit from some cleanup.

That said, considering our current timeline and the announced feature freeze, I would personally prioritize more critical topics at this point. Since this functionality can still be handled manually for now, I don’t consider it essential for the upcoming release.

So my preference would be to postpone this feature and revisit it afterwards, when we have enough time to properly refine both the implementation and the UX.

private var secondsRemaining = durationInMs / 1000
private var fired: Boolean = false

init { // This is a blatant copy of LevelMenuPanel, thus knowingly violating single source of truth

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

import java.awt.event.ActionListener
import javax.swing.Timer

// This still de-syncs slightly from the timer in LevelMenuPanel

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this an open todo / issue? Or what is the intent of this comment? :)

Comment on lines +53 to +54
private var gameEndDurationInMs: Long = 0
private var gameEndCalcDurationInMs: Long = 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not using Duration for that?

Comment on lines +124 to +130
fun setGameEndDuration(durationInMs: Long) {
gameEndDurationInMs = durationInMs
}

fun setGameEndCalcDuration(durationInMs: Long) {
gameEndCalcDurationInMs = durationInMs
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thats java not kotlin, just make the var public accessable.

Comment on lines +55 to +56
private var gameEndTimeout: GameTimeout? = null
private var gameEndCalcTimeout: GameTimeout? = null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

make non nullable and directly initialize it please.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The calculation is always at the end of the game, thus this names are quite confusing. Furthermore its not a timeout of the game end but a game timeout right ;)

Comment on lines +198 to +207
if (state == GameState.Break) {
isPause = true
gameEndCalcTimeout?.stopTimer()
gameEndTimeout?.stopTimer()
} else if (isPause && gameState == GameState.Running) {
isPause = false
gameEndCalcTimeout?.startTimer()
gameEndTimeout?.startTimer()
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not letting the timeout consume the GameState? by that you could save lots of boilerplate code.

private var finished = false

private fun finalizeGame() {
fun finalizeGame() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why public?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initiate automatic game end after a certain amount of time

2 participants