Added Narrative Console by adding ANSI escape codes.
This commit is contained in:
@@ -17,6 +17,4 @@ public interface Entity {
|
||||
int getHp();
|
||||
|
||||
int getMp();
|
||||
|
||||
String getName();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.weapons.BoneDagger;
|
||||
import org.project.item.weapons.DragonClaw;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -34,33 +35,33 @@ public class Dragon extends Enemy {
|
||||
if (target instanceof Player) {
|
||||
Player player = (Player) target;
|
||||
if (player.isDefending()) {
|
||||
System.out.println("🐉 Dragon ignores your pathetic shield!");
|
||||
NarrativeConsole.printCombat("🐉 Dragon ignores your pathetic shield!");
|
||||
//Complete damage is done
|
||||
}
|
||||
}
|
||||
|
||||
target.takeDamage(damage);
|
||||
System.out.println("🐉 Dragon strikes with its claw!");
|
||||
System.out.println("💥 " + damage + " damage dealt to " + getName(target) + "!");
|
||||
NarrativeConsole.printCombat("🐉 Dragon strikes with its claw!");
|
||||
NarrativeConsole.printDamage("💥 " + damage + " damage dealt to " + getName(target) + "!");
|
||||
}
|
||||
|
||||
private void fireBreath(Entity target) {
|
||||
int damage = 45;
|
||||
|
||||
System.out.println("🐉🐉🐉 DRAGON BREATHES FIRE! 🐉🐉🐉");
|
||||
System.out.println("🔥🔥🔥 FIERY BREATH ENGULFS EVERYTHING! 🔥🔥🔥");
|
||||
NarrativeConsole.printSpecial("🐉🐉🐉 DRAGON BREATHES FIRE! 🐉🐉🐉");
|
||||
NarrativeConsole.printSpecial("🔥🔥🔥 FIERY BREATH ENGULFS EVERYTHING! 🔥🔥🔥");
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player player = (Player) target;
|
||||
if (player.isDefending()) {
|
||||
System.out.println("🛡️ Your shield MELTS under the dragon's breath!");
|
||||
System.out.println("🔥 Defense is USELESS against this attack!");
|
||||
NarrativeConsole.printSpecial("🛡️ Your shield MELTS under the dragon's breath!");
|
||||
NarrativeConsole.printSpecial("🔥 Defense is USELESS against this attack!");
|
||||
player.setDefending(false); //The defense is invalid
|
||||
}
|
||||
}
|
||||
|
||||
target.takeDamage(damage);
|
||||
System.out.println("💥 " + getName(target) + " takes " + damage + " MASSIVE damage!");
|
||||
NarrativeConsole.printDamage("💥 " + getName(target) + " takes " + damage + " MASSIVE damage!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,4 +73,6 @@ public class Dragon extends Enemy {
|
||||
public int getMaxMP() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.project.entity.enemies;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
public abstract class Enemy implements Entity {
|
||||
Weapon weapon;
|
||||
@@ -80,7 +81,7 @@ public abstract class Enemy implements Entity {
|
||||
public void heal(int health) {
|
||||
//checking mana
|
||||
if (mp < healCost) {
|
||||
System.out.println("Not enough mana to heal!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to heal!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.project.entity.enemies;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.BoneDagger;
|
||||
import org.project.item.weapons.ToothedHook;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -28,11 +29,11 @@ public class Goblin extends Enemy {
|
||||
target.takeDamage(damage);
|
||||
|
||||
if (isCritical) {
|
||||
System.out.println("💣 Goblin used CRITICAL STRIKE! ");
|
||||
System.out.println("💥 Goblin dealt " + damage + " damage to " + getName(target) + "!");
|
||||
NarrativeConsole.printSpecial("💣 Goblin used CRITICAL STRIKE! ");
|
||||
NarrativeConsole.printDamage("💥 Goblin dealt " + damage + " damage to " + getName(target) + "!");
|
||||
} else {
|
||||
System.out.println("👹 Goblin attacked " + getName(target) + "!");
|
||||
System.out.println("💥 Goblin dealt " + damage + " damage to " + getName(target) + "!");
|
||||
NarrativeConsole.printCombat("👹 Goblin attacked " + getName(target) + "!");
|
||||
NarrativeConsole.printDamage("💥 Goblin dealt " + damage + " damage to " + getName(target) + "!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.BoneDagger;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
public class Skeleton extends Enemy {
|
||||
private boolean hasResurrected = false;
|
||||
@@ -16,8 +17,8 @@ public class Skeleton extends Enemy {
|
||||
|
||||
target.takeDamage(damage);
|
||||
|
||||
System.out.println("💀 Skeleton attacked " + getName(target) + "!");
|
||||
System.out.println("💥 Skeleton dealt " + damage + " damage to "
|
||||
NarrativeConsole.printWarning("💀 Skeleton attacked " + getName(target) + "!");
|
||||
NarrativeConsole.printDamage("💥 Skeleton dealt " + damage + " damage to "
|
||||
+ getName(target) + "!");
|
||||
}
|
||||
|
||||
@@ -31,8 +32,8 @@ public class Skeleton extends Enemy {
|
||||
setHp(resurrectedHp);
|
||||
hasResurrected = true;
|
||||
|
||||
System.out.println("💀 Skeleton has been defeated...");
|
||||
System.out.println("☠️ But Skeleton rises again! Resurrected with "
|
||||
NarrativeConsole.printSuccess("💀 Skeleton has been defeated...");
|
||||
NarrativeConsole.printSpecial("☠️ But Skeleton rises again! Resurrected with "
|
||||
+ resurrectedHp + " HP!");
|
||||
return;
|
||||
}
|
||||
@@ -40,11 +41,11 @@ public class Skeleton extends Enemy {
|
||||
setHp(newHp);
|
||||
if (getHp() < 0) setHp(0);
|
||||
|
||||
System.out.println("💥 Skeleton took " + damage + " damage! HP: "
|
||||
NarrativeConsole.printDamage("💥 Skeleton took " + damage + " damage! HP: "
|
||||
+ getHp() + "/" + getMaxHP());
|
||||
|
||||
if (getHp() <= 0) {
|
||||
System.out.println("☠️ Skeleton has been destroyed for good!");
|
||||
NarrativeConsole.printSuccess("☠️ Skeleton has been destroyed for good!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.ToothedHook;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
public class Vampire extends Enemy {
|
||||
public Vampire() {
|
||||
@@ -22,13 +23,13 @@ public class Vampire extends Enemy {
|
||||
}
|
||||
setHp(newHp);
|
||||
|
||||
System.out.println("🦇 Vampire attacks " + getName(target) + "!");
|
||||
System.out.println("💥 Dealt " + damage + " damage!");
|
||||
System.out.println("🩸 Life steal: Vampire drains " + healAmount + " HP and regenerates!");
|
||||
System.out.println("💚 Vampire HP: " + getHp() + "/" + getMaxHP());
|
||||
NarrativeConsole.printCombat("🦇 Vampire attacks " + getName(target) + "!");
|
||||
NarrativeConsole.printDamage("💥 Dealt " + damage + " damage!");
|
||||
NarrativeConsole.printSpecial("🩸 Life steal: Vampire drains " + healAmount + " HP and regenerates!");
|
||||
NarrativeConsole.printSpecial("💚 Vampire HP: " + getHp() + "/" + getMaxHP());
|
||||
|
||||
if (getHp() == getMaxHP()) {
|
||||
System.out.println("🦇 Vampire is fully satiated!");
|
||||
NarrativeConsole.printInfo("🦇 Vampire is fully satiated!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.project.entity.players;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
public class Assassin extends Player implements Entity, ICombatActions {
|
||||
public Assassin(String name, Weapon weapon, Armor armor) {
|
||||
@@ -13,7 +14,7 @@ public class Assassin extends Player implements Entity, ICombatActions {
|
||||
public void specialAbility(Entity target) {
|
||||
//Checking if the mana is enough of not
|
||||
if (getMp() < 15) {
|
||||
System.out.println("❌ Not enough mana for Devastating Spell!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana for Devastating Spell!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,10 +24,10 @@ public class Assassin extends Player implements Entity, ICombatActions {
|
||||
setInvisible(true);
|
||||
setNextAttackCritical(true);
|
||||
|
||||
System.out.println("💜 " + getName() + " turns INVISIBLE!");
|
||||
System.out.println("⚡ Next attack will be CRITICAL (2x damage)!");
|
||||
System.out.println("🛡️ Will dodge the next incoming attack completely!");
|
||||
System.out.println("💙 Mana left: " + getMp());
|
||||
NarrativeConsole.printSpecial("💜 " + getName() + " turns INVISIBLE!");
|
||||
NarrativeConsole.printSpecial("⚡ Next attack will be CRITICAL (2x damage)!");
|
||||
NarrativeConsole.printSpecial("🛡️ Will dodge the next incoming attack completely!");
|
||||
NarrativeConsole.printMana("💙 Mana left: " + getMp());
|
||||
}
|
||||
|
||||
public void lightAttack(Entity target) {
|
||||
@@ -35,18 +36,18 @@ public class Assassin extends Player implements Entity, ICombatActions {
|
||||
//Critical Action (if enabled)
|
||||
if (isNextAttackCritical()) {
|
||||
damage *= 2;
|
||||
System.out.println("⚡ CRITICAL HIT! Damage doubled to " + damage + "!");
|
||||
NarrativeConsole.printSpecial("⚡ CRITICAL HIT! Damage doubled to " + damage + "!");
|
||||
setNextAttackCritical(false);
|
||||
}
|
||||
|
||||
target.takeDamage(damage);
|
||||
System.out.println("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
|
||||
NarrativeConsole.printDamage("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
if (getMp() < 8) {
|
||||
System.out.println("❌ Not enough mana for Heavy Attack!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana for Heavy Attack!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 8);
|
||||
@@ -55,35 +56,35 @@ public class Assassin extends Player implements Entity, ICombatActions {
|
||||
//Critical Action (if enabled)
|
||||
if (isNextAttackCritical()) {
|
||||
damage *= 2;
|
||||
System.out.println("⚡ CRITICAL HIT! Damage doubled to " + damage + "!");
|
||||
NarrativeConsole.printSpecial("⚡ CRITICAL HIT! Damage doubled to " + damage + "!");
|
||||
setNextAttackCritical(false);
|
||||
}
|
||||
|
||||
target.takeDamage(damage);
|
||||
System.out.println("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
|
||||
NarrativeConsole.printDamage("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
if (getMp() < 6) {
|
||||
System.out.println("❌ Not enough mana to defend!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to defend!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 6);
|
||||
setDefending(true);
|
||||
System.out.println("🛡️ " + getName() + " is defending! Next attack will be halved.");
|
||||
NarrativeConsole.printCombat("🛡️ " + getName() + " is defending! Next attack will be halved.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal() {
|
||||
if (getMp() < 12) {
|
||||
System.out.println("❌ Not enough mana to heal!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to heal!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 12);
|
||||
int healAmount = 20;
|
||||
setHp(getHp() + healAmount);
|
||||
if (getHp() > getMaxHP()) setHp(getMaxHP());
|
||||
System.out.println("💚 " + getName() + " healed " + healAmount + " HP!");
|
||||
NarrativeConsole.printHeal("💚 " + getName() + " healed " + healAmount + " HP!");
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -19,7 +20,7 @@ public class Knight extends Player implements ICombatActions {
|
||||
public void specialAbility(Entity target) {
|
||||
//Checking if the mana is enough of not
|
||||
if (getMp() < 15) {
|
||||
System.out.println("❌ Mana is not enough for Shield Bash!");
|
||||
NarrativeConsole.printWarning("❌ Mana is not enough for Shield Bash!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,48 +32,48 @@ public class Knight extends Player implements ICombatActions {
|
||||
((Sword) getWeapon()).uniqueAbility(target);
|
||||
}
|
||||
|
||||
System.out.println("💥 Shield Bash! Enemy is stunned!");
|
||||
NarrativeConsole.printSpecial("💥 Shield Bash! Enemy is stunned!");
|
||||
}
|
||||
|
||||
public void lightAttack(Entity target) {
|
||||
int damage = 10;
|
||||
target.takeDamage(damage);
|
||||
System.out.println("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
|
||||
NarrativeConsole.printCombat("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
if (getMp() < 8) {
|
||||
System.out.println("❌ Not enough mana for Heavy Attack!");
|
||||
NarrativeConsole.printWarning("❌ Mana is not enough for Heavy Attack!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 8);
|
||||
int damage = 20;
|
||||
target.takeDamage(damage);
|
||||
System.out.println("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
|
||||
NarrativeConsole.printDamage("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
if (getMp() < 6) {
|
||||
System.out.println("❌ Not enough mana to defend!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to defend!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 6);
|
||||
setDefending(true);
|
||||
System.out.println("🛡️ " + getName() + " is defending! Next attack will be halved.");
|
||||
NarrativeConsole.printCombat("🛡️ " + getName() + " is defending! Next attack will be halved.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal() {
|
||||
if (getMp() < 12) {
|
||||
System.out.println("❌ Not enough mana to heal!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to heal!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 12);
|
||||
int healAmount = 20;
|
||||
setHp(getHp() + healAmount);
|
||||
if (getHp() > getMaxHP()) setHp(getMaxHP());
|
||||
System.out.println("💚 " + getName() + " healed " + healAmount + " HP!");
|
||||
NarrativeConsole.printHeal("💚 " + getName() + " healed " + healAmount + " HP!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.project.entity.players;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -34,7 +35,7 @@ public abstract class Player implements Entity {
|
||||
public void defend() {
|
||||
//checking mana
|
||||
if (mp < defendCost) {
|
||||
System.out.println("Not enough mana to defend!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to defend!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ public abstract class Player implements Entity {
|
||||
//activating defense mode
|
||||
isDefending = true;
|
||||
|
||||
System.out.println("🛡️ " + name + " raises shield, preparing to block next attack!");
|
||||
NarrativeConsole.printCombat("🛡️ " + name + " raises shield, preparing to block next attack!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +55,7 @@ public abstract class Player implements Entity {
|
||||
//reducing damage if the player is in defend mode
|
||||
if (isDefending()) {
|
||||
actualDamage = damage / 2;
|
||||
System.out.println("🛡️ Defense reduced damage from " + damage + " to " + actualDamage);
|
||||
NarrativeConsole.printCombat("🛡️ Defense reduced damage from " + damage + " to " + actualDamage);
|
||||
setDefending(false);
|
||||
}
|
||||
|
||||
@@ -64,16 +65,17 @@ public abstract class Player implements Entity {
|
||||
if (actualDamage < 0) actualDamage = 0;
|
||||
|
||||
armor.reduceDurability(1);
|
||||
System.out.println("🛡️ Armor blocked " + defense +
|
||||
NarrativeConsole.printCombat("🛡️ Armor blocked " + defense +
|
||||
" damage! Remaining durability: " + armor.getDurability());
|
||||
}
|
||||
|
||||
setHp(getHp() - actualDamage);
|
||||
System.out.println("💥 " + getName() + " took " + actualDamage + " damage! HP: " + getHp());
|
||||
NarrativeConsole.printDamage("💥 " + getName() + " took "
|
||||
+ actualDamage + " damage! HP: " + getHp());
|
||||
|
||||
if (getHp() < 0) {
|
||||
setHp(0);
|
||||
System.out.println("💀 " + getName() + " has been defeated!");
|
||||
NarrativeConsole.printDamage("💀 " + getName() + " has been defeated!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +83,7 @@ public abstract class Player implements Entity {
|
||||
public void heal(int health) {
|
||||
//checking mana
|
||||
if (mp < healCost) {
|
||||
System.out.println("Not enough mana to heal!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to heal!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,9 +108,9 @@ public abstract class Player implements Entity {
|
||||
}
|
||||
|
||||
if (mp == maxMP) {
|
||||
System.out.println("Mana is now full! (" + mp + "/" + maxMP + ")");
|
||||
NarrativeConsole.printMana("🩵 Mana is now full! (" + mp + "/" + maxMP + ")");
|
||||
} else {
|
||||
System.out.println("Mana increased from " + oldMana + " to " + mp);
|
||||
NarrativeConsole.printMana("🩵 Mana increased from " + oldMana + " to " + mp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Wand;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
public class Wizard extends Player implements Entity,ICombatActions {
|
||||
public Wizard (String name, Weapon weapon, Armor armor) {
|
||||
@@ -16,7 +17,7 @@ public class Wizard extends Player implements Entity,ICombatActions {
|
||||
public void specialAbility(Entity target) {
|
||||
//Checking if the mana is enough of not
|
||||
if (getMp() < 15) {
|
||||
System.out.println("❌ Not enough mana for Devastating Spell!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana for Devastating Spell!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,58 +25,57 @@ public class Wizard extends Player implements Entity,ICombatActions {
|
||||
setMp(getMp()-15);
|
||||
|
||||
target.takeDamage(30);
|
||||
System.out.println("🔮 " + getName() + "used DEVASTATING SPELL Dealt" + 30 + " damage!");
|
||||
NarrativeConsole.printSpecial("🔮 " + getName() + "used DEVASTATING SPELL Dealt" + 30 + " damage!");
|
||||
|
||||
int newHp = getHp() + 10;
|
||||
if (newHp > getMaxHP()) newHp = getMaxHP();
|
||||
setHp(newHp);
|
||||
|
||||
System.out.println("💚 " + getName() + " healed " + 10 + " HP! (Now: " +
|
||||
NarrativeConsole.printSpecial("💚 " + getName() + " healed " + 10 + " HP! (Now: " +
|
||||
getHp() + "/" + getMaxHP() + ")");
|
||||
System.out.println("🔮 " + getName() + " casts DEVASTATING SPELL!");
|
||||
System.out.println("💙 Mana left: " + getMp());
|
||||
NarrativeConsole.printMana("💙 Mana left: " + getMp());
|
||||
}
|
||||
|
||||
public void lightAttack(Entity target) {
|
||||
int damage = 10;
|
||||
target.takeDamage(damage);
|
||||
System.out.println("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
|
||||
NarrativeConsole.printCombat("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
if (getMp() < 8) {
|
||||
System.out.println("❌ Not enough mana for Heavy Attack!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana for Heavy Attack!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 8);
|
||||
int damage = 20;
|
||||
target.takeDamage(damage);
|
||||
System.out.println("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
|
||||
NarrativeConsole.printDamage("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
if (getMp() < 6) {
|
||||
System.out.println("❌ Not enough mana to defend!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to defend!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 6);
|
||||
setDefending(true);
|
||||
System.out.println("🛡️ " + getName() + " is defending! Next attack will be halved.");
|
||||
NarrativeConsole.printCombat("🛡️ " + getName() + " is defending! Next attack will be halved.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal() {
|
||||
if (getMp() < 12) {
|
||||
System.out.println("❌ Not enough mana to heal!");
|
||||
NarrativeConsole.printWarning("❌ Not enough mana to heal!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 12);
|
||||
int healAmount = 20;
|
||||
setHp(getHp() + healAmount);
|
||||
if (getHp() > getMaxHP()) setHp(getMaxHP());
|
||||
System.out.println("💚 " + getName() + " healed " + healAmount + " HP!");
|
||||
NarrativeConsole.printHeal("💚 " + getName() + " healed " + healAmount + " HP!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
public class Flask extends Consumable {
|
||||
public Flask(int healingPersent) {
|
||||
super("Healing Flask");
|
||||
this.healingPercent = 25;
|
||||
public Flask(String name, int healingPercent) {
|
||||
super(name , healingPercent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
//Checking if the target is alive
|
||||
if (target == null || target.getHp() <= 0) {
|
||||
System.out.println("❌ Target is dead already!");
|
||||
NarrativeConsole.printWarning("❌ Target is dead already!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ public class Flask extends Consumable {
|
||||
target.heal(healAmount);
|
||||
int actualHeal = target.getHp() - oldHp;
|
||||
|
||||
System.out.println("🧪🧪🧪 ============== 🧪🧪🧪");
|
||||
System.out.println("💚 " + target.getName() + " drinks the Healing Flask!");
|
||||
System.out.println("✨ Restored " + actualHeal + " HP!");
|
||||
System.out.println("💚 HP: " + target.getHp() + "/" + target.getMaxHP());
|
||||
NarrativeConsole.printHeal("🧪🧪🧪 ============== 🧪🧪🧪");
|
||||
NarrativeConsole.printHeal("💚 " + getName() + " drinks the Healing Flask!");
|
||||
NarrativeConsole.printHeal("✨ Restored " + actualHeal + " HP!");
|
||||
NarrativeConsole.printHeal("💚 HP: " + target.getHp() + "/" + target.getMaxHP());
|
||||
|
||||
if (target.getHp() == target.getMaxHP()) {
|
||||
System.out.println("💪 " + target.getName() + " is fully healed!");
|
||||
NarrativeConsole.printHeal("💪 " + getName() + " is fully healed!");
|
||||
}
|
||||
System.out.println("🧪🧪🧪 ============== 🧪🧪🧪");
|
||||
NarrativeConsole.printHeal("🧪🧪🧪 ============== 🧪🧪🧪");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ package org.project.item.consumables;
|
||||
|
||||
public class GreatFlask extends Flask {
|
||||
public GreatFlask() {
|
||||
super(50); //50% healing
|
||||
super("Great Flask", 50); //50% healing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ package org.project.item.consumables;
|
||||
|
||||
public class HealthFlask extends Flask {
|
||||
public HealthFlask() {
|
||||
super(25); //25% healing
|
||||
super("Health Flask",25); //25% healing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ package org.project.item.consumables;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.location.NarrativeConsole;
|
||||
|
||||
public class ManaFlask extends Flask {
|
||||
public ManaFlask() {
|
||||
super(30); //30% mana increasing
|
||||
super("Mana Flask",30); //30% mana increasing
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,7 +15,7 @@ public class ManaFlask extends Flask {
|
||||
Player player = (Player) target;
|
||||
int manaAmount = player.getMaxMP() / 3;
|
||||
player.setMp(Math.min(player.getMp() + manaAmount, player.getMaxMP()));
|
||||
System.out.println("💙 Restored " + manaAmount + " Mana!");
|
||||
NarrativeConsole.printMana("💙 Restored " + manaAmount + " Mana!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,6 @@ public abstract class Weapon implements Item {
|
||||
private int damage;
|
||||
private int manaCost;
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||
*/
|
||||
|
||||
public Weapon(int damage, int manaCost) {
|
||||
this.damage = damage;
|
||||
this.manaCost = manaCost;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.project.location;
|
||||
|
||||
public class AnsiColors {
|
||||
// Reset
|
||||
public static final String RESET = "\u001B[0m";
|
||||
|
||||
// Regular Colors
|
||||
public static final String BLACK = "\u001B[30m";
|
||||
public static final String RED = "\u001B[31m";
|
||||
public static final String GREEN = "\u001B[32m";
|
||||
public static final String YELLOW = "\u001B[33m";
|
||||
public static final String BLUE = "\u001B[34m";
|
||||
public static final String PURPLE = "\u001B[35m";
|
||||
public static final String CYAN = "\u001B[36m";
|
||||
public static final String WHITE = "\u001B[37m";
|
||||
|
||||
// Bold Colors
|
||||
public static final String BOLD_RED = "\u001B[1;31m";
|
||||
public static final String BOLD_GREEN = "\u001B[1;32m";
|
||||
public static final String BOLD_YELLOW = "\u001B[1;33m";
|
||||
public static final String BOLD_BLUE = "\u001B[1;34m";
|
||||
public static final String BOLD_PURPLE = "\u001B[1;35m";
|
||||
public static final String BOLD_CYAN = "\u001B[1;36m";
|
||||
|
||||
// Background Colors
|
||||
public static final String BG_RED = "\u001B[41m";
|
||||
public static final String BG_GREEN = "\u001B[42m";
|
||||
public static final String BG_YELLOW = "\u001B[43m";
|
||||
public static final String BG_BLUE = "\u001B[44m";
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.project.location;
|
||||
|
||||
public class NarrativeConsole {
|
||||
|
||||
//Damage
|
||||
public static void printDamage(String message) {
|
||||
System.out.println(AnsiColors.RED + "💥 " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Heal
|
||||
public static void printHeal(String message) {
|
||||
System.out.println(AnsiColors.GREEN + "💚 " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Mana
|
||||
public static void printMana(String message) {
|
||||
System.out.println(AnsiColors.BLUE + "💙 " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Warning
|
||||
public static void printWarning(String message) {
|
||||
System.out.println(AnsiColors.YELLOW + "⚠️ " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Success
|
||||
public static void printSuccess(String message) {
|
||||
System.out.println(AnsiColors.BOLD_GREEN + "✨ " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Info
|
||||
public static void printInfo(String message) {
|
||||
System.out.println(AnsiColors.CYAN + "ℹ️ " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Error
|
||||
public static void printError(String message) {
|
||||
System.out.println(AnsiColors.BOLD_RED + "❌ " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Combat
|
||||
public static void printCombat(String message) {
|
||||
System.out.println(AnsiColors.PURPLE + "⚔️ " + message + AnsiColors.RESET);
|
||||
}
|
||||
|
||||
//Special
|
||||
public static void printSpecial(String message) {
|
||||
System.out.println(AnsiColors.BOLD_YELLOW + "⭐ " + message + AnsiColors.RESET);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user