Class GameLogic
java.lang.Object
gamelogic.GameLogic
Main gameplay controller for soul generation, timer, attacks, and merging.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddElementToMerge(BaseElement element) Adds an element to the merge slots and returns a potion when a recipe matches.voidattackFirstSoul(BasePotion potion) Attacks the first soul in the belt.booleanattackSoulAt(int soulIndex, BasePotion potion) Attacks a soul at the given belt index and refills the belt if defeated.voidClears all currently selected merge elements.intGets the number of souls defeated in this level.Gets the first soul waiting in the belt.intgetLevel()Gets the current level number.Gets the current merge slot contents.Gets a copy of the current soul belt.intGets the current remaining time.intGets the total souls required to complete this level.booleanChecks whether the game has ended.booleanChecks whether the player has defeated enough souls for the level.booleanisTimeUp()Checks whether the timer has reached zero.voidDecreases the timer and ends the game when time reaches zero.
-
Constructor Details
-
GameLogic
public GameLogic(int level) Creates gameplay state for the selected level.- Parameters:
level- level number used for time, soul pool, and win condition
-
-
Method Details
-
attackFirstSoul
Attacks the first soul in the belt.- Parameters:
potion- potion used for the attack
-
attackSoulAt
Attacks a soul at the given belt index and refills the belt if defeated.- Parameters:
soulIndex- index of the target soulpotion- potion used for the attack- Returns:
- true when a valid target was attacked
-
getFirstSoul
Gets the first soul waiting in the belt.- Returns:
- first soul, or null if the belt is empty
-
getSoulBeltAsList
-
getDefeatedSoulCount
public int getDefeatedSoulCount()Gets the number of souls defeated in this level.- Returns:
- defeated soul count
-
getTotalSoulRequired
public int getTotalSoulRequired()Gets the total souls required to complete this level.- Returns:
- required soul count
-
updateTimer
public void updateTimer()Decreases the timer and ends the game when time reaches zero. -
isLevelComplete
public boolean isLevelComplete()Checks whether the player has defeated enough souls for the level.- Returns:
- true when the level objective is complete
-
isGameOver
public boolean isGameOver()Checks whether the game has ended.- Returns:
- true when time is up or the level is complete
-
getTimeLeft
public int getTimeLeft()Gets the current remaining time.- Returns:
- remaining time in seconds
-
isTimeUp
public boolean isTimeUp()Checks whether the timer has reached zero.- Returns:
- true when no time remains
-
getLevel
public int getLevel()Gets the current level number.- Returns:
- level number
-
addElementToMerge
Adds an element to the merge slots and returns a potion when a recipe matches.- Parameters:
element- selected element- Returns:
- created potion, or null when no potion is created
-
clearMergeSlots
public void clearMergeSlots()Clears all currently selected merge elements. -
getMergeSlots
Gets the current merge slot contents.- Returns:
- selected merge elements
-