Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4129f89d4e | ||
|
|
4e929ebdab |
Generated
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" project-jdk-name="ms-25" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,15 +1,132 @@
|
|||||||
package org.project;
|
package org.project;
|
||||||
|
|
||||||
import org.project.location.Location;
|
import org.project.entity.enemies.*;
|
||||||
|
import org.project.entity.players.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Random;
|
||||||
import java.util.List;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
Scanner scanner = new Scanner(System.in);
|
||||||
List<Location> locations = new ArrayList<>();
|
Random random = new Random();
|
||||||
|
|
||||||
// TODO: IMPLEMENT GAMEPLAY
|
System.out.println("\u001B[33m=== The Legend of Javanest ===\u001B[0m");
|
||||||
|
System.out.println("Choose your Hero Class:");
|
||||||
|
System.out.println("1. Knight (High Damage)");
|
||||||
|
System.out.println("2. Wizard (High Health)");
|
||||||
|
System.out.println("3. Assassin (High Mana)");
|
||||||
|
|
||||||
|
int classChoice = scanner.nextInt();
|
||||||
|
Player player;
|
||||||
|
if (classChoice == 2) {
|
||||||
|
player = new Wizard("Merlin");
|
||||||
|
} else if (classChoice == 3) {
|
||||||
|
player = new Assassin("Ezio");
|
||||||
|
} else {
|
||||||
|
player = new Knight("Ser Duncan");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasGoblinKey = false;
|
||||||
|
boolean hasSkeletonKey = false;
|
||||||
|
boolean hasVampireKey = false;
|
||||||
|
boolean gameRunning = true;
|
||||||
|
|
||||||
|
while (gameRunning && player.isAlive()) {
|
||||||
|
boolean hasAllKeys = hasGoblinKey && hasSkeletonKey && hasVampireKey;
|
||||||
|
|
||||||
|
System.out.println("\n\u001B[35mYou arrived at a new location.\u001B[0m");
|
||||||
|
Enemy currentEnemy = spawnRandomEnemy(random);
|
||||||
|
System.out.println("A wild " + currentEnemy.getName() + " appears!");
|
||||||
|
|
||||||
|
boolean inLocation = true;
|
||||||
|
while (inLocation && player.isAlive()) {
|
||||||
|
System.out.println("\nWhat would you like to do?");
|
||||||
|
System.out.println("1. Fight the enemy");
|
||||||
|
System.out.println("2. Move to another location");
|
||||||
|
if (hasAllKeys) {
|
||||||
|
System.out.println("\u001B[31m3. Go to the Castle to fight the Dragon\u001B[0m");
|
||||||
|
}
|
||||||
|
|
||||||
|
int choice = scanner.nextInt();
|
||||||
|
|
||||||
|
if (choice == 1) {
|
||||||
|
fight(player, currentEnemy, scanner);
|
||||||
|
inLocation = false;
|
||||||
|
|
||||||
|
if (player.isAlive() && !currentEnemy.isAlive()) {
|
||||||
|
System.out.println("\u001B[32mVictory! " + currentEnemy.getName() + " was defeated.\u001B[0m");
|
||||||
|
player.gainXP(50);
|
||||||
|
player.heal(player.getMaxHP());
|
||||||
|
player.fillMana(player.getMaxMP());
|
||||||
|
|
||||||
|
if (currentEnemy instanceof Goblin && !hasGoblinKey && random.nextInt(100) < 20) {
|
||||||
|
System.out.println("\u001B[33m🗝️ You found the Goblin Key!\u001B[0m");
|
||||||
|
hasGoblinKey = true;
|
||||||
|
} else if (currentEnemy instanceof Skeleton && !hasSkeletonKey && random.nextInt(100) < 20) {
|
||||||
|
System.out.println("\u001B[33m🗝️ You found the Skeleton Key!\u001B[0m");
|
||||||
|
hasSkeletonKey = true;
|
||||||
|
} else if (currentEnemy instanceof Vampire && !hasVampireKey && random.nextInt(100) < 20) {
|
||||||
|
System.out.println("\u001B[33m🗝️ You found the Vampire Key!\u001B[0m");
|
||||||
|
hasVampireKey = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (choice == 2) {
|
||||||
|
System.out.println("You moved to a new location.");
|
||||||
|
inLocation = false;
|
||||||
|
} else if (choice == 3 && hasAllKeys) {
|
||||||
|
System.out.println("\n\u001B[31m=== You entered the Castle! ===\u001B[0m");
|
||||||
|
Enemy dragon = new Dragon();
|
||||||
|
fight(player, dragon, scanner);
|
||||||
|
if (player.isAlive()) {
|
||||||
|
System.out.println("\u001B[33m🎉 You defeated the Dragon and saved Javanest! You Win!\u001B[0m");
|
||||||
|
}
|
||||||
|
gameRunning = false;
|
||||||
|
inLocation = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.isAlive()) {
|
||||||
|
System.out.println("\u001B[31m💀 Game Over. You died.\u001B[0m");
|
||||||
|
}
|
||||||
|
scanner.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Enemy spawnRandomEnemy(Random random) {
|
||||||
|
int r = random.nextInt(3);
|
||||||
|
if (r == 0) return new Goblin();
|
||||||
|
if (r == 1) return new Skeleton();
|
||||||
|
return new Vampire();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void fight(Player player, Enemy enemy, Scanner scanner) {
|
||||||
|
System.out.println("\u001B[31mYou chose to FIGHT!\u001B[0m");
|
||||||
|
while (player.isAlive() && enemy.isAlive()) {
|
||||||
|
System.out.println("\n[" + player.getName() + " - " + player.getHp() + "/" + player.getMaxHP() + " HP | " + player.getMp() + "/" + player.getMaxMP() + " Mana]");
|
||||||
|
System.out.println("[" + enemy.getName() + " - " + enemy.getHp() + "/" + enemy.getMaxHP() + " HP]");
|
||||||
|
|
||||||
|
System.out.println("\nYour Turn:");
|
||||||
|
System.out.println("1. Light Attack | 2. Heavy Attack (-8 Mana) | 3. Defend (-6 Mana) | 4. Heal (-12 Mana) | 5. Special Ability (-15 Mana)");
|
||||||
|
int action = scanner.nextInt();
|
||||||
|
|
||||||
|
if (player.isStunned()) {
|
||||||
|
System.out.println("\u001B[33mYou are stunned and cannot move!\u001B[0m");
|
||||||
|
player.setStunned(false);
|
||||||
|
} else {
|
||||||
|
switch (action) {
|
||||||
|
case 1: player.lightAttack(enemy); break;
|
||||||
|
case 2: player.heavyAttack(enemy); break;
|
||||||
|
case 3: player.defendAction(); break;
|
||||||
|
case 4: player.healAction(); break;
|
||||||
|
case 5: player.specialAbility(enemy); break;
|
||||||
|
default: player.lightAttack(enemy); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enemy.isAlive()) {
|
||||||
|
enemy.attackAction(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,15 @@
|
|||||||
package org.project.entity;
|
package org.project.entity;
|
||||||
|
|
||||||
public interface Entity {
|
public interface Entity {
|
||||||
void attack(Entity target);
|
|
||||||
|
|
||||||
void defend();
|
|
||||||
|
|
||||||
void heal(int health);
|
|
||||||
|
|
||||||
void fillMana(int mana);
|
|
||||||
|
|
||||||
void takeDamage(int damage);
|
void takeDamage(int damage);
|
||||||
|
void heal(int health);
|
||||||
|
void fillMana(int mana);
|
||||||
|
int getHp();
|
||||||
int getMaxHP();
|
int getMaxHP();
|
||||||
|
int getMp();
|
||||||
int getMaxMP();
|
int getMaxMP();
|
||||||
|
boolean isAlive();
|
||||||
/*
|
String getName();
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
void setStunned(boolean stunned);
|
||||||
*/
|
boolean isStunned();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class Dragon extends Enemy {
|
||||||
|
|
||||||
|
public Dragon() {
|
||||||
|
super("Dragon", 250, 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attackAction(Entity target) {
|
||||||
|
if (!isStunned()) {
|
||||||
|
System.out.println("\u001B[31m🐉 Dragon breathes massive FIRE! (Bypasses shields)\u001B[0m");
|
||||||
|
target.takeDamage(baseDamage);
|
||||||
|
} else {
|
||||||
|
System.out.println("🐉 Dragon is stunned, but recovers quickly!");
|
||||||
|
setStunned(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +1,61 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public abstract class Enemy implements Entity {
|
||||||
public abstract class Enemy {
|
protected String name;
|
||||||
Weapon weapon;
|
protected int hp;
|
||||||
private int hp;
|
protected int maxHP;
|
||||||
private int mp;
|
protected int baseDamage;
|
||||||
|
protected boolean stunned;
|
||||||
|
|
||||||
public Enemy(int hp, int mp, Weapon weapon) {
|
public Enemy(String name, int hp, int baseDamage) {
|
||||||
|
this.name = name;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.mp = mp;
|
this.maxHP = hp;
|
||||||
|
this.baseDamage = baseDamage;
|
||||||
this.weapon = weapon;
|
this.stunned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void attackAction(Entity target);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
hp -= damage;
|
hp -= damage;
|
||||||
|
if (hp < 0) hp = 0;
|
||||||
|
System.out.println("\u001B[31m" + name + " took " + damage + " damage!\u001B[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHp() {
|
@Override
|
||||||
return hp;
|
public void heal(int health) {
|
||||||
|
hp += health;
|
||||||
|
if (hp > maxHP) hp = maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMp() {
|
@Override
|
||||||
return mp;
|
public void fillMana(int mana) {}
|
||||||
}
|
|
||||||
|
|
||||||
public Weapon getWeapon() {
|
@Override
|
||||||
return weapon;
|
public int getHp() { return hp; }
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
|
public int getMaxHP() { return maxHP; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMp() { return 0; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMP() { return 0; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAlive() { return hp > 0; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return name; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStunned(boolean stunned) { this.stunned = stunned; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStunned() { return stunned; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Goblin extends Enemy {
|
||||||
|
private Random random;
|
||||||
|
|
||||||
|
public Goblin() {
|
||||||
|
super("Goblin", 30, 10);
|
||||||
|
this.random = new Random();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attackAction(Entity target) {
|
||||||
|
if (!isStunned()) {
|
||||||
|
if (random.nextInt(100) < 40) {
|
||||||
|
System.out.println("\u001B[31m👹 Goblin used Critical Strike!\u001B[0m");
|
||||||
|
target.takeDamage(baseDamage * 2);
|
||||||
|
} else {
|
||||||
|
System.out.println("👹 Goblin attacks normally!");
|
||||||
|
target.takeDamage(baseDamage);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("👹 Goblin is stunned and skips the turn!");
|
||||||
|
setStunned(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,33 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.entity.Entity;
|
||||||
public class Skeleton {
|
|
||||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
public class Skeleton extends Enemy {
|
||||||
}
|
private boolean hasResurrected;
|
||||||
|
|
||||||
|
public Skeleton() {
|
||||||
|
super("Skeleton", 40, 8);
|
||||||
|
this.hasResurrected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void takeDamage(int damage) {
|
||||||
|
super.takeDamage(damage);
|
||||||
|
if (hp == 0 && !hasResurrected) {
|
||||||
|
System.out.println("\u001B[33m☠️ Skeleton resurrected with 50% HP!\u001B[0m");
|
||||||
|
hasResurrected = true;
|
||||||
|
hp = maxHP / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attackAction(Entity target) {
|
||||||
|
if (!isStunned()) {
|
||||||
|
System.out.println("☠️ Skeleton uses Bone Strike!");
|
||||||
|
target.takeDamage(baseDamage);
|
||||||
|
} else {
|
||||||
|
System.out.println("☠️ Skeleton is stunned and skips the turn!");
|
||||||
|
setStunned(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class Vampire extends Enemy {
|
||||||
|
|
||||||
|
public Vampire() {
|
||||||
|
super("Vampire", 50, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attackAction(Entity target) {
|
||||||
|
if (!isStunned()) {
|
||||||
|
System.out.println("\u001B[31m🦇 Vampire uses Life Steal!\u001B[0m");
|
||||||
|
target.takeDamage(baseDamage);
|
||||||
|
|
||||||
|
int healAmount = baseDamage / 2;
|
||||||
|
heal(healAmount);
|
||||||
|
System.out.println("\u001B[32m🦇 Vampire healed for " + healAmount + " HP!\u001B[0m");
|
||||||
|
} else {
|
||||||
|
System.out.println("🦇 Vampire is stunned and skips the turn!");
|
||||||
|
setStunned(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class Assassin extends Player {
|
||||||
|
private boolean isInvisible = false;
|
||||||
|
private boolean nextAttackCrit = false;
|
||||||
|
|
||||||
|
public Assassin(String name) {
|
||||||
|
super(name, 80, 120, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void takeDamage(int damage) {
|
||||||
|
if (isInvisible) {
|
||||||
|
System.out.println("\u001B[35m💨 " + name + " dodged the attack completely by being invisible!\u001B[0m");
|
||||||
|
isInvisible = false;
|
||||||
|
} else {
|
||||||
|
super.takeDamage(damage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lightAttack(Entity target) {
|
||||||
|
int dmg = baseDamage;
|
||||||
|
if (nextAttackCrit) {
|
||||||
|
System.out.println("\u001B[31m💥 Critical Hit!\u001B[0m");
|
||||||
|
dmg *= 2;
|
||||||
|
nextAttackCrit = false;
|
||||||
|
}
|
||||||
|
target.takeDamage(dmg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heavyAttack(Entity target) {
|
||||||
|
int cost = 8;
|
||||||
|
if (mp >= cost) {
|
||||||
|
mp -= cost;
|
||||||
|
int dmg = baseDamage * 2;
|
||||||
|
if (nextAttackCrit) {
|
||||||
|
System.out.println("\u001B[31m💥 Critical Hit!\u001B[0m");
|
||||||
|
dmg *= 2;
|
||||||
|
nextAttackCrit = false;
|
||||||
|
}
|
||||||
|
target.takeDamage(dmg);
|
||||||
|
} else {
|
||||||
|
lightAttack(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void specialAbility(Entity target) {
|
||||||
|
int cost = 15;
|
||||||
|
if (mp >= cost) {
|
||||||
|
mp -= cost;
|
||||||
|
System.out.println("\u001B[36m🗡️ " + name + " (Assassin) used Shadow Step! (-15 Mana)\u001B[0m");
|
||||||
|
isInvisible = true;
|
||||||
|
nextAttackCrit = true;
|
||||||
|
System.out.println("\u001B[35m" + name + " turned invisible! Next attack will dodge and crit.\u001B[0m");
|
||||||
|
} else {
|
||||||
|
System.out.println("\u001B[34mNot enough mana! Defaulting to Light Attack.\u001B[0m");
|
||||||
|
lightAttack(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public interface ICombatActions {
|
||||||
|
void lightAttack(Entity target);
|
||||||
|
void heavyAttack(Entity target);
|
||||||
|
void defendAction();
|
||||||
|
void healAction();
|
||||||
|
void specialAbility(Entity target);
|
||||||
|
}
|
||||||
@@ -1,6 +1,25 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.entity.Entity;
|
||||||
public class Knight {
|
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
public class Knight extends Player {
|
||||||
}
|
|
||||||
|
public Knight(String name) {
|
||||||
|
super(name, 100, 50, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void specialAbility(Entity target) {
|
||||||
|
int cost = 15;
|
||||||
|
if (mp >= cost) {
|
||||||
|
mp -= cost;
|
||||||
|
System.out.println("\u001B[36m⚔️ " + name + " (Knight) used Shield Bash! (-15 Mana)\u001B[0m");
|
||||||
|
target.takeDamage(baseDamage * 2);
|
||||||
|
target.setStunned(true);
|
||||||
|
System.out.println("\u001B[33m" + target.getName() + " is stunned for the next turn!\u001B[0m");
|
||||||
|
} else {
|
||||||
|
System.out.println("\u001B[34mNot enough mana! Defaulting to Light Attack.\u001B[0m");
|
||||||
|
lightAttack(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,65 +1,123 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
import org.project.item.armors.Armor;
|
|
||||||
import org.project.item.weapons.Weapon;
|
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public abstract class Player implements Entity, ICombatActions {
|
||||||
public abstract class Player {
|
|
||||||
protected String name;
|
protected String name;
|
||||||
Weapon weapon;
|
protected int hp;
|
||||||
Armor armor;
|
protected int maxHP;
|
||||||
private int hp;
|
protected int mp;
|
||||||
private int maxHP;
|
protected int maxMP;
|
||||||
private int mp;
|
protected int baseDamage;
|
||||||
private int maxMP;
|
protected boolean isDefending;
|
||||||
|
protected boolean stunned;
|
||||||
|
protected int level = 1;
|
||||||
|
protected int xp = 0;
|
||||||
|
|
||||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
public Player(String name, int maxHP, int maxMP, int baseDamage) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.hp = hp;
|
this.maxHP = maxHP;
|
||||||
this.mp = mp;
|
this.hp = maxHP;
|
||||||
|
this.maxMP = maxMP;
|
||||||
this.weapon = weapon;
|
this.mp = maxMP;
|
||||||
this.armor = armor;
|
this.baseDamage = baseDamage;
|
||||||
|
this.isDefending = false;
|
||||||
|
this.stunned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void attack(Entity target) {
|
|
||||||
target.takeDamage(weapon.getDamage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void defend() {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
hp -= damage - armor.getDefense();
|
if (isDefending) {
|
||||||
|
damage /= 2;
|
||||||
|
isDefending = false;
|
||||||
|
}
|
||||||
|
hp -= damage;
|
||||||
|
if (hp < 0) hp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void heal(int health) {
|
public void heal(int health) {
|
||||||
hp += health;
|
hp += health;
|
||||||
if (hp > maxHP) {
|
if (hp > maxHP) hp = maxHP;
|
||||||
hp = maxHP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillMana(int mana) {
|
public void fillMana(int mana) {
|
||||||
mp += mana;
|
mp += mana;
|
||||||
if (mp > maxMP) {
|
if (mp > maxMP) mp = maxMP;
|
||||||
mp = maxMP;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAlive() {
|
||||||
|
return hp > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStunned(boolean stunned) {
|
||||||
|
this.stunned = stunned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStunned() {
|
||||||
|
return stunned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void gainXP(int amount) {
|
||||||
|
xp += amount;
|
||||||
|
if (xp >= level * 100) {
|
||||||
|
levelUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void levelUp() {
|
||||||
|
level++;
|
||||||
|
maxHP += 20;
|
||||||
|
maxMP += 10;
|
||||||
|
baseDamage += 5;
|
||||||
|
hp = maxHP;
|
||||||
|
mp = maxMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lightAttack(Entity target) {
|
||||||
|
target.takeDamage(baseDamage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heavyAttack(Entity target) {
|
||||||
|
int cost = 8;
|
||||||
|
if (mp >= cost) {
|
||||||
|
mp -= cost;
|
||||||
|
target.takeDamage(baseDamage * 2);
|
||||||
|
} else {
|
||||||
|
lightAttack(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void defendAction() {
|
||||||
|
int cost = 6;
|
||||||
|
if (mp >= cost) {
|
||||||
|
mp -= cost;
|
||||||
|
isDefending = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void healAction() {
|
||||||
|
int cost = 12;
|
||||||
|
if (mp >= cost) {
|
||||||
|
mp -= cost;
|
||||||
|
heal(maxHP / 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
@@ -69,6 +127,7 @@ public abstract class Player {
|
|||||||
return maxHP;
|
return maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
@@ -77,13 +136,4 @@ public abstract class Player {
|
|||||||
public int getMaxMP() {
|
public int getMaxMP() {
|
||||||
return maxMP;
|
return maxMP;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public Weapon getWeapon() {
|
|
||||||
return weapon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Armor getArmor() {
|
|
||||||
return armor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class Wizard extends Player {
|
||||||
|
|
||||||
|
public Wizard(String name) {
|
||||||
|
super(name, 150, 80, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void specialAbility(Entity target) {
|
||||||
|
int cost = 15;
|
||||||
|
if (mp >= cost) {
|
||||||
|
mp -= cost;
|
||||||
|
System.out.println("\u001B[36m🧙♂️ " + name + " (Wizard) cast Life Drain! (-15 Mana)\u001B[0m");
|
||||||
|
target.takeDamage(baseDamage * 2);
|
||||||
|
heal(maxHP / 4);
|
||||||
|
System.out.println("\u001B[32m" + name + " healed for " + (maxHP / 4) + " HP!\u001B[0m");
|
||||||
|
} else {
|
||||||
|
System.out.println("\u001B[34mNot enough mana! Defaulting to Light Attack.\u001B[0m");
|
||||||
|
lightAttack(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,4 @@ import org.project.entity.Entity;
|
|||||||
|
|
||||||
public interface Item {
|
public interface Item {
|
||||||
void use(Entity target);
|
void use(Entity target);
|
||||||
|
}
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,25 @@
|
|||||||
package org.project.item.armors;
|
package org.project.item.armors;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.item.Item;
|
||||||
public abstract class Armor {
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public abstract class Armor implements Item {
|
||||||
private int defense;
|
private int defense;
|
||||||
private int maxDefense;
|
private int maxDefense;
|
||||||
private int durability;
|
private int durability;
|
||||||
private int maxDurability;
|
private int maxDurability;
|
||||||
|
|
||||||
private boolean isBroke;
|
private boolean isBroke;
|
||||||
|
|
||||||
public Armor(int defense, int durability) {
|
public Armor(int defense, int durability) {
|
||||||
this.defense = defense;
|
this.defense = defense;
|
||||||
|
this.maxDefense = defense;
|
||||||
this.durability = durability;
|
this.durability = durability;
|
||||||
|
this.maxDurability = durability;
|
||||||
|
this.isBroke = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void use(Entity target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkBreak() {
|
public void checkBreak() {
|
||||||
@@ -21,7 +29,6 @@ public abstract class Armor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
|
||||||
public void repair() {
|
public void repair() {
|
||||||
isBroke = false;
|
isBroke = false;
|
||||||
defense = maxDefense;
|
defense = maxDefense;
|
||||||
@@ -39,4 +46,9 @@ public abstract class Armor {
|
|||||||
public boolean isBroke() {
|
public boolean isBroke() {
|
||||||
return isBroke;
|
return isBroke;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void reduceDurability(int amount) {
|
||||||
|
durability -= amount;
|
||||||
|
checkBreak();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.project.item.armors;
|
package org.project.item.armors;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public class KnightArmor extends Armor {
|
||||||
public class KnightArmor {
|
public KnightArmor() {
|
||||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
super(10, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package org.project.item.consumables;
|
package org.project.item.consumables;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.item.Item;
|
||||||
public abstract class Consumable {
|
|
||||||
/*
|
public abstract class Consumable implements Item {
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
}
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -2,15 +2,9 @@ package org.project.item.consumables;
|
|||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public class Flask extends Consumable {
|
||||||
public class Flask {
|
|
||||||
/*
|
|
||||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: UPDATE USE METHOD
|
|
||||||
@Override
|
@Override
|
||||||
public void use(Entity target) {
|
public void use(Entity target) {
|
||||||
target.heal(target.getMaxHP() / 10);
|
target.heal(target.getMaxHP() / 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,26 +1,20 @@
|
|||||||
package org.project.item.weapons;
|
package org.project.item.weapons;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public class Sword extends Weapon {
|
||||||
public class Sword {
|
private int abilityCharge;
|
||||||
/*
|
|
||||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int abilityCharge;
|
|
||||||
|
|
||||||
public Sword() {
|
public Sword() {
|
||||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
super(15, 5);
|
||||||
|
this.abilityCharge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
|
||||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||||
abilityCharge += 2;
|
abilityCharge += 2;
|
||||||
for (Entity target : targets) {
|
for (Entity target : targets) {
|
||||||
target.takeDamage(getDamage());
|
target.takeDamage(getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
package org.project.item.weapons;
|
package org.project.item.weapons;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public abstract class Weapon implements Item {
|
||||||
public abstract class Weapon {
|
|
||||||
private int damage;
|
private int damage;
|
||||||
private int manaCost;
|
private int manaCost;
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Weapon(int damage, int manaCost) {
|
public Weapon(int damage, int manaCost) {
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.manaCost = manaCost;
|
this.manaCost = manaCost;
|
||||||
@@ -28,8 +24,4 @@ public abstract class Weapon {
|
|||||||
public int getManaCost() {
|
public int getManaCost() {
|
||||||
return manaCost;
|
return manaCost;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package org.project.location;
|
package org.project.location;
|
||||||
|
|
||||||
import org.project.entity.enemies.Enemy;
|
import org.project.entity.enemies.Enemy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Location {
|
public class Location {
|
||||||
private String name;
|
private String name;
|
||||||
|
private ArrayList<Location> locations;
|
||||||
private ArrayList<Enemy> enemies;
|
private ArrayList<Enemy> enemies;
|
||||||
|
|
||||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
public Location(String name, ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
||||||
this.locations = locations;
|
this.name = name;
|
||||||
this.enemies = enemies;
|
this.locations = locations != null ? locations : new ArrayList<>();
|
||||||
|
this.enemies = enemies != null ? enemies : new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -25,4 +25,4 @@ public class Location {
|
|||||||
public ArrayList<Enemy> getEnemies() {
|
public ArrayList<Enemy> getEnemies() {
|
||||||
return enemies;
|
return enemies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user