public class CombatEngine
extends java.lang.Object
| Constructor and Description |
|---|
CombatEngine(GameData data,
GameView view)
To run the combat, a GameData and GameView is essential for it to work.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Sets all fortunes to null across all knights.
|
void |
initialize()
Before every quest, active knights are assigned random fortunes (
GameData.getRandomFortune(). |
void |
runCombat()
Runs the combat simulation.
|
public void initialize()
GameData.getRandomFortune().
Once an a fortune is assigned to each active knight, call GameView.printFortunes(List)public void runCombat()
GameView.checkContinue().
If they respond yes, more random monsters will be generated, and combat begins again.
At the start of each battle:
GameData.getRandomMonsters()GameView.printBattleText(List, List)MOB.getHP() <= 0), they are removed from active knightsKnight.addXP(int))GameView.printBattleText(MOB)
If all knights are defeated, we notify the player using GameView.printDefeated().
Calculating Hits
To calculate a successful hit, you roll a D20 (DiceSet.roll(DiceType) take that
value, add the MOBs/Knights toHitModifier. If the value is greater than the armor value, they score
a hit, and the damage die is rolled.
D20 + hitModifier > armor (successful hit formula)
DiceSet.roll(DiceType)public void clear()