Skip to content

Commit

Permalink
Merge branch 'master' into CheatsIndexOutOfBoundsFix
Browse files Browse the repository at this point in the history
  • Loading branch information
emmamickas authored Oct 25, 2021
2 parents ae41a47 + 555f731 commit cbc3c64
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 95 deletions.
16 changes: 8 additions & 8 deletions src/com/hotmail/kalebmarc/textfighter/item/Chest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ public static void view() {
Ui.println(" Recovery: " + Potion.get("recovery"));
Ui.println("Coins: " + Coins.get());
Ui.println("POWERS: " + Power.get());
for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
if (Weapon.arrayWeapon.get(i).owns()) {
Ui.println(Weapon.arrayWeapon.get(i).getName());
if (!Weapon.arrayWeapon.get(i).melee)
Ui.println(" (Ammo: " + Weapon.arrayWeapon.get(i).getAmmo() + ")");
for (int i = 0; i < Weapon.getWeapons().size(); i++) {
if (Weapon.getWeapons().get(i).owns()) {
Ui.println(Weapon.getWeapons().get(i).getName());
if (!Weapon.getWeapons().get(i).melee)
Ui.println(" (Ammo: " + Weapon.getWeapons().get(i).getAmmo() + ")");
}
}
for (int i = 1; i < Armour.getArmours().size(); i++) {
if (Armour.getArmours().get(i).isOwns()) {
Ui.println(Armour.getArmours().get(i).toString());
}
}
for (int i = 0; i < Food.arrayFood.size(); i++) {
if (Food.arrayFood.get(i).getQuantity() > 0)
Ui.println(Food.arrayFood.get(i).getName() + "(x" + Food.arrayFood.get(i).getQuantity() + ")");
for (int i = 0; i < Food.getFoods().size(); i++) {
if (Food.getFoods().get(i).getQuantity() > 0)
Ui.println(Food.getFoods().get(i).getName() + "(x" + Food.getFoods().get(i).getQuantity() + ")");
}
Ui.println();
Ui.println("------------------------------");
Expand Down
24 changes: 12 additions & 12 deletions src/com/hotmail/kalebmarc/textfighter/main/Cheats.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ private static void cheatSelect() {
Coins.set(5000, false);
FirstAid.set(5000, false);
InstaHealth.set(5000, false);
for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
Weapon.arrayWeapon.get(i).setAmmo(5000, false);
for (int i = 0; i < Weapon.getWeapons().size(); i++) {
Weapon.getWeapons().get(i).setAmmo(5000, false);
}
Power.set(5000, false);
for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
Weapon.arrayWeapon.get(i).owns = true;
for (int i = 0; i < Weapon.getWeapons().size(); i++) {
Weapon.getWeapons().get(i).owns = true;
}
Stats.timesCheated++;
for (int i = 0; i < Food.arrayFood.size(); i++)
Food.arrayFood.get(i).setQuantity(5000);
for (int i = 0; i < Food.getFoods().size(); i++)
Food.getFoods().get(i).setQuantity(5000);
Potion.set("Survival", 5000, false);
Potion.set("Recovery", 5000, false);
break;
Expand All @@ -63,8 +63,8 @@ private static void cheatSelect() {
}

Power.set(5000, false);
for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
Weapon.arrayWeapon.get(i).owns = true;
for (int i = 0; i < Weapon.getWeapons().size(); i++) {
Weapon.getWeapons().get(i).owns = true;
}
Stats.timesCheated++;
break;
Expand All @@ -73,8 +73,8 @@ private static void cheatSelect() {
InstaHealth.set(500, false);
Potion.set("Survival", 500, false);
Potion.set("Recovery", 500, false);
for (int i = 0; i < Food.arrayFood.size(); i++)
Food.arrayFood.get(i).setQuantity(100);
for (int i = 0; i < Food.getFoods().size(); i++)
Food.getFoods().get(i).setQuantity(100);
Stats.timesCheated++;
break;
case "healme":
Expand Down Expand Up @@ -103,8 +103,8 @@ private static void cheatSelect() {
Stats.timesCheated++;
break;
case "thirstforfood":
for (int i = 0; i < Food.arrayFood.size(); i++)
Food.arrayFood.get(i).setQuantity(10);
for (int i = 0; i < Food.getFoods().size(); i++)
Food.getFoods().get(i).setQuantity(10);
Stats.timesCheated++;
break;

Expand Down
14 changes: 7 additions & 7 deletions src/com/hotmail/kalebmarc/textfighter/main/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public static void menu() {
Xp.set(Ui.getValidInt(), false);
break;
case 3:
for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
Weapon.arrayWeapon.get(i).owns = true;
for (int i = 0; i < Weapon.getWeapons().size(); i++) {
Weapon.getWeapons().get(i).owns = true;
}
Power.set(100, true);
for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
Weapon.arrayWeapon.get(i).setAmmo(10000, false);
for (int i = 0; i < Weapon.getWeapons().size(); i++) {
Weapon.getWeapons().get(i).setAmmo(10000, false);
}
Ui.println("You now have all weapons");
Ui.pause();
Expand All @@ -84,10 +84,10 @@ public static void menu() {
break;
case 8:
Ui.cls();
for (int i = 0; i < Food.arrayFood.size(); i++) {
Ui.println(i + ") " + Food.arrayFood.get(i).getName());
for (int i = 0; i < Food.getFoods().size(); i++) {
Ui.println(i + ") " + Food.getFoods().get(i).getName());
}
Food.arrayFood.get(Ui.getValidInt()).setQuantity(10);
Food.getFoods().get(Ui.getValidInt()).setQuantity(10);
break;
case 9:
return;
Expand Down
11 changes: 8 additions & 3 deletions src/com/hotmail/kalebmarc/textfighter/main/Enemy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hotmail.kalebmarc.textfighter.main;

import com.hotmail.kalebmarc.textfighter.item.Armour;
import com.hotmail.kalebmarc.textfighter.player.*;

import javax.swing.*;
Expand Down Expand Up @@ -72,6 +73,10 @@ public static void set(int i) {
current = arrayEnemy.get(i);
}

public static ArrayList<Enemy> getEnemies() {
return arrayEnemy;
}

public static Enemy get() {
return current;
}
Expand All @@ -84,9 +89,9 @@ public static void findEnemy() {
int playerLevel = Xp.getLevel();
ArrayList<Enemy> suitableEnemies = new ArrayList<>();

for (int i = 0; i < arrayEnemy.size(); i++) {
if (arrayEnemy.get(i).levelMin <= playerLevel && playerLevel <= arrayEnemy.get(i).levelMax) {
suitableEnemies.add(arrayEnemy.get(i));
for (int i = 0; i < getEnemies().size(); i++) {
if (getEnemies().get(i).levelMin <= playerLevel && playerLevel <= getEnemies().get(i).levelMax) {
suitableEnemies.add(getEnemies().get(i));
}
}
current = suitableEnemies.get(Random.RInt(0, suitableEnemies.size() -1));
Expand Down
19 changes: 12 additions & 7 deletions src/com/hotmail/kalebmarc/textfighter/main/Food.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hotmail.kalebmarc.textfighter.main;

import com.hotmail.kalebmarc.textfighter.item.Armour;
import com.hotmail.kalebmarc.textfighter.player.Health;

import java.util.ArrayList;
Expand Down Expand Up @@ -32,10 +33,10 @@ public static void list() {
while (true) {
Ui.cls();
int j = 0;
int[] offset = new int[arrayFood.size()];
for (int i = 0; i < arrayFood.size(); i++) {
if (arrayFood.get(i).quantity > 0) {
Ui.println((j + 1) + ") " + arrayFood.get(i).getName() + "(" + arrayFood.get(i).quantity + ")");
int[] offset = new int[getFoods().size()];
for (int i = 0; i < getFoods().size(); i++) {
if (getFoods().get(i).quantity > 0) {
Ui.println((j + 1) + ") " + getFoods().get(i).getName() + "(" + getFoods().get(i).quantity + ")");
offset[j] = i - j;
j++;
}
Expand All @@ -57,14 +58,14 @@ public static void list() {

//TODO once more status effects are implemented, use a switch here if appropriate.
//Testing to make sure the option is valid goes here:
if (arrayFood.get(menuItem).getStatusEffect() == StatusEffect.type.HEALTH && Health.get() == Health.getOutOf()) {
if (getFoods().get(menuItem).getStatusEffect() == StatusEffect.type.HEALTH && Health.get() == Health.getOutOf()) {
Ui.msg("Your health is already full. No need to eat this!");
return;
}

//Results go here:
if (arrayFood.get(menuItem).quantity > 0) {
Food.arrayFood.get(menuItem).eat();
if (getFoods().get(menuItem).quantity > 0) {
Food.getFoods().get(menuItem).eat();
}
return;

Expand All @@ -76,6 +77,10 @@ public static void list() {
}
}

public static ArrayList<Food> getFoods() {
return arrayFood;
}

public String getName() {
return this.name;
}
Expand Down
63 changes: 43 additions & 20 deletions src/com/hotmail/kalebmarc/textfighter/main/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ private static void info_enemy() {
Ui.println(" ENEMY INFO ");
Ui.println("Which enemy would you like to know about?");
Ui.println();
for (int i = 0; i < Enemy.arrayEnemy.size(); i++) {
Ui.println((i + 1) + ") " + Enemy.arrayEnemy.get(i).getName());
for (int i = 0; i < Enemy.getEnemies().size(); i++) {
Ui.println((i + 1) + ") " + Enemy.getEnemies().get(i).getName());
}
Ui.println((Enemy.arrayEnemy.size() + 1) + ") Back");
Ui.println((Enemy.getEnemies().size() + 1) + ") Back");
Ui.println("------------------------------------------------------------");

int menuItem = Ui.getValidInt();

try {
Enemy.arrayEnemy.get(menuItem - 1).viewAbout();
Enemy.getEnemies().get(menuItem - 1).viewAbout();
} catch (Exception e) {
if (menuItem == (Enemy.arrayEnemy.size() + 1)) return;
if (menuItem == (Enemy.getEnemies().size() + 1)) return;
Ui.println(menuItem + " is not an option.");
Ui.pause();
}
Expand Down Expand Up @@ -115,18 +115,18 @@ private static void info_weapons() {
Ui.println(" WEAPON INFO ");
Ui.println("Which weapon would you like to know about?");
Ui.println();
for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
Ui.println((i + 1) + ") " + Weapon.arrayWeapon.get(i).getName());
for (int i = 0; i < Weapon.getWeapons().size(); i++) {
Ui.println((i + 1) + ") " + Weapon.getWeapons().get(i).getName());
}
Ui.println((Weapon.arrayWeapon.size() + 1) + ") Back");
Ui.println((Weapon.getWeapons().size() + 1) + ") Back");
Ui.println("------------------------------------------------------------");

int menuItem = Ui.getValidInt();

try {
Weapon.arrayWeapon.get(menuItem - 1).viewAbout();
Weapon.getWeapons().get(menuItem - 1).viewAbout();
} catch (Exception e) {
if (menuItem == (Weapon.arrayWeapon.size() + 1)) return;
if (menuItem == (Weapon.getWeapons().size() + 1)) return;
Ui.println(menuItem + " is not an option.");
Ui.pause();
}
Expand All @@ -141,7 +141,30 @@ private static void info_health() {
Ui.println("health up to 200. Each upgrade will cost 100 coins on easy, ");
Ui.println("and 150 coins on hard; and it will upgrade your health by 10.");
Ui.println("You will be able to upgrade once per level.");
//TODO Add more health info
Ui.println("Health deteriorates by fighting enemies.");
Ui.println("If your health reaches 0, you'll die and you will lose coins.");
Ui.println("The goal is to eliminate an enemy by reducing his health to 0.");
Ui.println("If an enemies health is 0 they will die.");
Ui.println("You'll receive XP points and gain coins if you kill an enemy.");
Ui.println("Potions are used to increase your health.");
Ui.println("You start the game with 2 Recovery and 2 Survival Potions.");
Ui.println("A Recovery Potion increases your health by 25%.");
Ui.println("A Survival Potion increases your health by 75%.");
Ui.println("You can purchase more potions at the shop once you've ");
Ui.println("completed level 2.");
Ui.println("First Aid Kits are used to increase your health.");
Ui.println("You start the game with 3 First Aid Kits.");
Ui.println("A First Aid Kit increases your health by 20 health points.");
Ui.println("You can purchase more First Aid Kits at the shop.");
Ui.println("Food is given to you at the beginning of the game.");
Ui.println("You can eat food to increase your health.");
Ui.println("If you eat all the food you cannot purchase more at the shop.");
Ui.println("InstaHealth can also restore your health.");
Ui.println("If you use an InstaHealth your health will fully recover.");
Ui.println("InstaHealth can be purchased at the shops after you have ");
Ui.println("reached level 3.");
Ui.println("The prices of the items you can purchase at the shop are ");
Ui.println("determined by which difficulty you are playing on.");
Ui.println("------------------------------------------------------------");
Ui.pause();
}
Expand All @@ -153,18 +176,18 @@ private static void info_food() {
Ui.println(" FOOD INFO ");
Ui.println("Which food would you like to know about?");
Ui.println();
for (int i = 0; i < Food.arrayFood.size(); i++) {
Ui.println((i + 1) + ") " + Food.arrayFood.get(i).getName());
for (int i = 0; i < Food.getFoods().size(); i++) {
Ui.println((i + 1) + ") " + Food.getFoods().get(i).getName());
}
Ui.println((Food.arrayFood.size() + 1) + ") Back");
Ui.println((Food.getFoods().size() + 1) + ") Back");
Ui.println("------------------------------------------------------------");

int menuItem = Ui.getValidInt();

try {
Food.arrayFood.get(menuItem - 1).viewAbout();
Food.getFoods().get(menuItem - 1).viewAbout();
} catch (Exception e) {
if (menuItem == (Food.arrayFood.size() + 1)) return;
if (menuItem == (Food.getFoods().size() + 1)) return;
Ui.println(menuItem + " is not an option.");
Ui.pause();
}
Expand Down Expand Up @@ -243,10 +266,10 @@ private static void info_achs() {
Ui.println(" Enemy Slayer | Kill a total of 100 enemies");
Ui.println(" First Kill | Kill one enemy");
Ui.println(" Time For An Upgrade | Buy any weapon from the shop");
for (int i = 0; i < Enemy.arrayEnemy.size(); i++) {
Ui.print(" Goodbye, " + Enemy.arrayEnemy.get(i).getName());
for (int x = 0; x < (14 - Enemy.arrayEnemy.get(i).getName().length()); x++) Ui.print(" ");
Ui.println("| Kill a " + Enemy.arrayEnemy.get(i).getName());
for (int i = 0; i < Enemy.getEnemies().size(); i++) {
Ui.print(" Goodbye, " + Enemy.getEnemies().get(i).getName());
for (int x = 0; x < (14 - Enemy.getEnemies().get(i).getName().length()); x++) Ui.print(" ");
Ui.println("| Kill a " + Enemy.getEnemies().get(i).getName());

}
Ui.println(" Text-Fighter Master | Get all other achievements");
Expand Down
Loading

0 comments on commit cbc3c64

Please sign in to comment.