BattleState
We will first look at the primary business logic that maintains the state and calculations involved in determining the outcome of a particular player's battle with an enemy. The following code snippet represents the BattleState
class, which can be found at core\src\com\packtpub\libgdx\bludbourne\battle\BattleState.java
:
package com.packtpub.libgdx.bludbourne.battle; import com.badlogic.gdx.math.MathUtils; import com.packtpub.libgdx.bludbourne.Entity; import com.packtpub.libgdx.bludbourne.EntityConfig; import com.packtpub.libgdx.bludbourne.UI.InventoryObserver; import com.packtpub.libgdx.bludbourne.profile.ProfileManager; public class BattleState extends BattleSubject implements InventoryObserver {
We need a way to communicate changes that occur during a battle turn, such as loss of HP or MP, a finished turn, or an escape attempt. We will use an observer pattern, consisting of BattleSubject
and BattleObserver
, to send the relevant notifications during a battle session. Here...