Class Battle


  • public class Battle
    extends java.lang.Object
    Class for Battle with graphic implementation
    • Field Detail

      • enemies

        private final java.util.LinkedList<Enemy> enemies
      • heroes

        private final java.util.LinkedList<Hero> heroes
      • timer

        private javax.swing.Timer timer
      • turnOrder

        private java.util.LinkedList<BattlePerson> turnOrder
      • delay

        private int delay
      • playerAttack

        private boolean playerAttack
      • timerStopped

        private boolean timerStopped
      • LOG

        public static final java.util.logging.Logger LOG
    • Constructor Detail

      • Battle

        public Battle​(java.util.LinkedList<Hero> heroes,
                      java.util.LinkedList<Enemy> enemies,
                      WindowOfBattle window)
    • Method Detail

      • setPlayerAttack

        public void setPlayerAttack​(boolean playerAttack)
        Hide Menu and Enemy Description Set Attack of Player
        Parameters:
        playerAttack - true if attacks
      • addToTurnOrder

        public void addToTurnOrder​(BattlePerson person)
      • getEnemies

        public java.util.LinkedList<Enemy> getEnemies()
      • getHeroes

        public java.util.LinkedList<Hero> getHeroes()
      • checkHealthOfEnemies

        public boolean checkHealthOfEnemies()
        Checks, if all enemies died
        Returns:
        true if all dies
      • checkHealthOfHeroes

        public boolean checkHealthOfHeroes()
        Checks, if all heroes died
        Returns:
        true if all dies
      • startBattle

        public void startBattle()
        Start fight by showing menu and creating Timer of battle
      • endBattle

        public void endBattle​(boolean b)
        End battle and start cutscene of win or lose
        Parameters:
        b - true if win, false if lose
      • returnControlToPlayer

        private void returnControlToPlayer()
        Show all Menus and Enemy Description
      • attackByHero

        private void attackByHero​(Enemy e)
        Attack with animation and logic Do delay of 2 seconds
        Parameters:
        e - Enemy to attack
      • nextTurn

        private void nextTurn()
        Function, which decide who will attack next
      • attackByMonster

        private void attackByMonster​(Hero e)
        Attack with animation and logic Do delay of 2 seconds
        Parameters:
        e - Hero to attack
      • randomEnemy

        private Enemy randomEnemy()
        Random enemy from list
        Returns:
        Random enemy
      • randomHero

        private Hero randomHero()
        Random hero from list
        Returns:
        Random hero
      • getTimer

        public javax.swing.Timer getTimer()
      • setTurnBelongTo

        public void setTurnBelongTo​(BattlePerson turnBelongTo)
      • checkIfTurnOrderIsFull

        private boolean checkIfTurnOrderIsFull​(java.util.LinkedList<BattlePerson> allBattlePerson)
      • removePersonFromList

        public void removePersonFromList​(BattlePerson person)
        Remove person from one of the list, if died
        Parameters:
        person - Person to delete
      • setDelay

        public void setDelay​(int delay)
      • isTimerStopped

        public boolean isTimerStopped()
      • setTimerStopped

        public void setTimerStopped​(boolean timerStopped)