Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. package com.shitfacedchimpanzee.textGame.model.battle;
  2.  
  3. import com.shitfacedchimpanzee.textGame.model.character.Attack;
  4. import com.shitfacedchimpanzee.textGame.model.character.Character;
  5. import com.shitfacedchimpanzee.textGame.view.TextOutput;
  6. import org.jetbrains.annotations.NotNull;
  7.  
  8. public class Battle {
  9. BattleScanner bs = new BattleScanner();
  10. public String s = new String();
  11.  
  12.  
  13. public Battle() throws InterruptedException {
  14. }
  15.  
  16. public String getResults() {
  17. return s.toString();
  18. }
  19.  
  20. public BattleScanner getBs() {
  21. return bs;
  22. }
  23.  
  24. public boolean nobodyDead(Character c) {
  25. return c.getHealth() > 0;
  26. }
  27.  
  28. public void doBattle(@NotNull Character charOne, @NotNull Character charTwo, Attack attack) throws InterruptedException {
  29. charTwo.setHealth(charTwo.getHealth() - charOne.getAttack() * attack.getDamage());
  30. s ("\n")
  31. + charOne.getName()
  32. + " did "
  33. + attack.getName()
  34. + " it did "
  35. + (charOne.getAttack() * attack.getDamage())
  36. + " damage"
  37. + "\n"
  38. + charTwo.getName()
  39. + " now only has "
  40. + charTwo.getHealth()
  41. + "\n";
  42. }
  43.  
  44. public String battleResults() {
  45. return s.toString();
  46. }
  47.  
  48. public void nextAttack(TextOutput tp, Character charOne, Character charTwo) throws InterruptedException {
  49.  
  50. Attack attack = this.getBs().whatAttack(charOne, tp);
  51. this.doBattle(charOne, charTwo, attack);
  52. tp.letterByLetter(this.getResults());
  53. if (this.nobodyDead(charTwo)) {
  54. nextAttack(tp, charTwo, charOne);
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement