Class GameLogic

java.lang.Object
gamelogic.GameLogic

public class GameLogic extends Object
Main gameplay controller for soul generation, timer, attacks, and merging.
  • 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

      public void attackFirstSoul(BasePotion potion)
      Attacks the first soul in the belt.
      Parameters:
      potion - potion used for the attack
    • attackSoulAt

      public boolean attackSoulAt(int soulIndex, BasePotion potion)
      Attacks a soul at the given belt index and refills the belt if defeated.
      Parameters:
      soulIndex - index of the target soul
      potion - potion used for the attack
      Returns:
      true when a valid target was attacked
    • getFirstSoul

      public BaseSoul getFirstSoul()
      Gets the first soul waiting in the belt.
      Returns:
      first soul, or null if the belt is empty
    • getSoulBeltAsList

      public List<BaseSoul> getSoulBeltAsList()
      Gets a copy of the current soul belt.
      Returns:
      list copy of souls in belt order
    • 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

      public BasePotion addElementToMerge(BaseElement element)
      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

      public List<BaseElement> getMergeSlots()
      Gets the current merge slot contents.
      Returns:
      selected merge elements