-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombatPhase.java
More file actions
43 lines (36 loc) · 1.16 KB
/
CombatPhase.java
File metadata and controls
43 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package game;
import java.util.Scanner;
public class CombatPhase {
private static Creature creatureRef;
private static Player playerRef;
@SuppressWarnings("resource")
public static void phaseLoop(Creature combatCreature, Player currentPlayer) {
creatureRef = combatCreature;
playerRef = currentPlayer;
if (creatureRef.health <= 0) {
System.out.println("The " + creatureRef.name + " has fallen!");
}
System.out.println("Creature HP: " + combatCreature.health + " Your HP: " + currentPlayer.health);
System.out.print(">>> ");
Scanner input = new Scanner(System.in);
inputCheck(input.nextLine());
}
public static boolean inputCheck(String input) {
switch(input) {
case "attack":
playerAttack();
break;
case "run":
//random number gen to depict if you get away
break;
}
return false;
}
public static void playerAttack() {
int playerAtkVal = playerRef.atk;
int creatureHP = creatureRef.health;
creatureRef.health = creatureHP - playerAtkVal;
System.out.println("You attack the creature, dealing: " + playerAtkVal + " damage.");
phaseLoop(creatureRef, playerRef);
}
}