diff --git a/src/com/hotmail/kalebmarc/textfighter/main/Weapon.java b/src/com/hotmail/kalebmarc/textfighter/main/Weapon.java index 45055909..48a2e615 100644 --- a/src/com/hotmail/kalebmarc/textfighter/main/Weapon.java +++ b/src/com/hotmail/kalebmarc/textfighter/main/Weapon.java @@ -7,8 +7,9 @@ import javax.swing.*; import java.util.ArrayList; +import java.util.Collections; -public class Weapon { +public class Weapon implements Comparable { //Weapon List public static final ArrayList arrayWeapon = new ArrayList<>(); @@ -61,6 +62,8 @@ public Weapon(String name, int ammoUsed, int ammoIncludedWithPurchase, boolean b } + Collections.sort(arrayWeapon); + } public Weapon(String name, boolean startingWeapon, boolean buyable, int price, int level,//For Melee @@ -197,13 +200,13 @@ public void dealDam() { if (this.melee) { /* * Melee Attack - */ + */ damageDealt = Random.RInt(this.damageMin, this.damageMax); } else { - /* - * Gun Attack - */ + /* + * Gun Attack + */ if (getAmmo() >= this.ammoUsed) { for (int i = 1; i <= this.ammoUsed; i++) { @@ -230,19 +233,19 @@ public void dealDam() { com.hotmail.kalebmarc.textfighter.player.Stats.totalDamageDealt += damageDealt; com.hotmail.kalebmarc.textfighter.player.Xp.setBattleXp(damageDealt, true); if(!Enemy.get().takeDamage(damageDealt)) { // !dead - Ui.cls(); - Ui.println("----------------------------------------------------"); - Ui.println("You have attacked a " + Enemy.get().getName() + "!"); - Ui.println("You dealt " + damageDealt + " damage with a " + this.name); - Ui.println("----------------------------------------------------"); - Ui.println("Your health: " + com.hotmail.kalebmarc.textfighter.player.Health.getStr()); - Ui.println("Enemy health: " + Enemy.get().getHeathStr()); - Ui.println("----------------------------------------------------"); - Ui.pause(); - - if (Enemy.get().getHealth() <= Enemy.get().getHealthMax() / 3){ - Enemy.get().useFirstAidKit(); - } + Ui.cls(); + Ui.println("----------------------------------------------------"); + Ui.println("You have attacked a " + Enemy.get().getName() + "!"); + Ui.println("You dealt " + damageDealt + " damage with a " + this.name); + Ui.println("----------------------------------------------------"); + Ui.println("Your health: " + com.hotmail.kalebmarc.textfighter.player.Health.getStr()); + Ui.println("Enemy health: " + Enemy.get().getHeathStr()); + Ui.println("----------------------------------------------------"); + Ui.pause(); + + if (Enemy.get().getHealth() <= Enemy.get().getHealthMax() / 3){ + Enemy.get().useFirstAidKit(); + } } damageDealt = 0; } @@ -376,4 +379,9 @@ public void buyAmmo() { public int getAmmoPrice() { return this.ammoPrice; } + + @Override + public int compareTo(Weapon w) { + return Integer.compare(this.level, w.level); + } } \ No newline at end of file