Browse Source

create monster attacking system

master
Yazan Alaamer 2 years ago
parent
commit
c7a907335a
  1. 43
      src/main/java/game/StartDarkSoulsGame.java

43
src/main/java/game/StartDarkSoulsGame.java

@ -258,6 +258,20 @@ public class StartDarkSoulsGame {
choice4.setText("");
}
public void monsterAttack() {
position = "monsterAttack";
int monsterDamage = 0;
monsterDamage = new java.util.Random().nextInt(5);
mainTextArea.setText("Monster attacked you "+ monsterDamage +" Damage");
playerHP = playerHP - monsterDamage;
hpLabelNumber.setText(" " + playerHP);
choice1.setText(">");
choice2.setText("");
choice3.setText("");
choice4.setText("");
}
public void win() {
position = "win";
mainTextArea.setText("THE SOUl OF CINDER has been defeated.\n"
@ -346,7 +360,7 @@ public class StartDarkSoulsGame {
break;
case "west":
switch(yourChoice) {
case "c1": break;
case "c1": fight(); break;
case "c2": crossRoad(); break;
}
break;
@ -355,6 +369,33 @@ public class StartDarkSoulsGame {
case "c1": playerAttack(); break;
case "c2": crossRoad(); break;
}
break;
case "playerAttack":
switch (yourChoice) {
case "c1": if(monsterHP < 1) {
win();
}
else {
monsterAttack(); break;
}
}
break;
case "monsterAttack":
switch (yourChoice) {
case "c1": if (playerHP < 1) {
lose();
}
else {
fight();
}
break;
}
break;
case "win":
switch(yourChoice) {
case "c1": crossRoad(); break;
}
}
}

Loading…
Cancel
Save