Browse Source

create player attacking system

master
Yazan Alaamer 2 years ago
parent
commit
6651499e86
  1. 35
      src/main/java/game/StartDarkSoulsGame.java

35
src/main/java/game/StartDarkSoulsGame.java

@ -230,14 +230,33 @@ public class StartDarkSoulsGame {
choice3.setText(""); choice3.setText("");
choice4.setText(""); choice4.setText("");
} }
public void fight() { // commit 31 boss fight
position = "fight"; // commit 31 boss fight
public void fight() {
position = "fight";
mainTextArea.setText("Monster HP:"+ monsterHP + " \n" mainTextArea.setText("Monster HP:"+ monsterHP + " \n"
+ " THE SOUl OF CINDER: Run for your life ASHEN ONE "); // commit 31 boss fight
choice1.setText("Attack"); // commit (31) west location
choice2.setText("Run for your live");// commit (31) west location
choice3.setText("");// commit (31) west location
choice4.setText("");// commit (31) west location
+ " THE SOUl OF CINDER: Run for your life ASHEN ONE ");
choice1.setText("Attack");
choice2.setText("Run for your live");
choice3.setText("");
choice4.setText("");
}
public void playerAttack() {
position = "playerAttack";
int playerDamage=0;
playerDamage = new java.util.Random().nextInt(3);
if(weapon.equals("Knife")) {
playerDamage = new java.util.Random().nextInt(3);
}
else if (weapon.equals("Gift of Tears")) {
playerDamage = new java.util.Random().nextInt(8);
}
mainTextArea.setText("monster has been attacked: "+ playerDamage +" Damage ");
monsterHP = monsterHP - playerDamage;
choice1.setText(">");
choice2.setText("");
choice3.setText("");
choice4.setText("");
} }
public class TitelScreenHandler implements ActionListener{ public class TitelScreenHandler implements ActionListener{
@ -295,7 +314,7 @@ public class StartDarkSoulsGame {
break; break;
case "fight": case "fight":
switch(yourChoice) { switch(yourChoice) {
case "c1": break;
case "c1": playerAttack(); break;
case "c2": crossRoad(); break; case "c2": crossRoad(); break;
} }
} }

Loading…
Cancel
Save