Releasing version one.
This commit is contained in:
Generated
+5
@@ -10,4 +10,9 @@
|
|||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="JavacSettings">
|
||||||
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
|
<module name="Java-Knight" options="--add-exports java.desktop/sun.swing=ALL-UNNAMED" />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Generated
+5
@@ -16,5 +16,10 @@
|
|||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://mirror-maven.runflare.com/maven2" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,15 +1,185 @@
|
|||||||
package org.project;
|
package org.project;
|
||||||
|
|
||||||
|
import org.project.entity.enemies.*;
|
||||||
|
import org.project.entity.players.Assassin;
|
||||||
|
import org.project.entity.players.Knight;
|
||||||
|
import org.project.entity.players.Player;
|
||||||
|
import org.project.entity.players.Wizard;
|
||||||
|
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.Location;
|
import org.project.location.Location;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Scanner;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
|
||||||
List<Location> locations = new ArrayList<>();
|
|
||||||
|
|
||||||
// TODO: IMPLEMENT GAMEPLAY
|
public static void printBorder() {
|
||||||
|
for (int i = 0; i < 40; i++)
|
||||||
|
System.out.print("-");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printBorder(int x) {
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
System.out.println();
|
||||||
|
for (int i = 0; i < x; i++)
|
||||||
|
System.out.print("-");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int moveSelector() {
|
||||||
|
System.out.println("Choose your move:");
|
||||||
|
System.out.println("1. Light attack (Mana: 0) | 2. Normal attack (mana: 2) | 3. Heavy attack (mana: 3)");
|
||||||
|
System.out.println("4. Heal (5 mana) | 5. Skip");
|
||||||
|
Scanner in = new Scanner(System.in);
|
||||||
|
while (true) {
|
||||||
|
int answer = in.nextInt();
|
||||||
|
if (answer == 1 || answer == 2 || answer == 3 || answer == 4 || answer == 5)
|
||||||
|
return answer;
|
||||||
|
System.out.println("Invalid input try again.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void fightEnemy(Player player, Location location, String enemyName, String locationDesc) {
|
||||||
|
String RED = "\u001B[31m";
|
||||||
|
String YELLOW = "\u001B[33m";
|
||||||
|
String RESET = "\u001B[0m";
|
||||||
|
|
||||||
|
System.out.printf("You're in the %s fighting a %s%s%s!\n", locationDesc, RED, enemyName, RESET);
|
||||||
|
|
||||||
|
while (player.isAlive() && location.getEnemy().getHP() > 0) {
|
||||||
|
// Player's turn: up to 5 actions
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
System.out.printf("%s | %sHP%s: %d, %sMP%s: %d\n",
|
||||||
|
player.getName(), RED, RESET, player.getHP(), YELLOW, RESET, player.getMP());
|
||||||
|
printBorder();
|
||||||
|
System.out.printf("%s | %sHP%s: %d, %sMP%s: %d\n",
|
||||||
|
enemyName, RED, RESET, location.getEnemy().getHP(), YELLOW, RESET, location.getEnemy().getMP());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
switch (moveSelector()) {
|
||||||
|
case 1: // Base Attack
|
||||||
|
location.getEnemy().takeDamage(player.getBaseDamage());
|
||||||
|
break;
|
||||||
|
case 2: // Normal Attack (2 mana)
|
||||||
|
if (player.useMana(2)) {
|
||||||
|
player.attack(location.getEnemy());
|
||||||
|
} else {
|
||||||
|
System.out.println("Not enough mana for Normal Attack!");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3: // Heavy Attack (3 mana)
|
||||||
|
if (player.useMana(3)) {
|
||||||
|
player.heavyAttack(location.getEnemy());
|
||||||
|
} else {
|
||||||
|
System.out.println("Not enough mana for Heavy Attack!");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4: // Heal (5 mana)
|
||||||
|
if (player.useMana(5)) {
|
||||||
|
player.heal(20);
|
||||||
|
} else {
|
||||||
|
System.out.println("Not enough mana to Heal!");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printBorder();
|
||||||
|
|
||||||
|
// If enemy died or player died, end the player's turn early
|
||||||
|
if (location.getEnemy().getHP() <= 0 || !player.isAlive()) {
|
||||||
|
location.getEnemy().getKilled();
|
||||||
|
i = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enemy's turn
|
||||||
|
if (location.getEnemy().getHP() > 0) {
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
location.getEnemy().attack(player);
|
||||||
|
printBorder();
|
||||||
|
if (!player.isAlive())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore mana after each full round
|
||||||
|
player.fillMana(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String RED = "\u001B[31m";
|
||||||
|
String YELLOW = "\u001B[33m";
|
||||||
|
String RESET = "\u001B[0m";
|
||||||
|
String GREEN = "\u001B[32m";
|
||||||
|
|
||||||
|
printBorder();
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
System.out.println("Enter your name:");
|
||||||
|
String name = input.next();
|
||||||
|
printBorder();
|
||||||
|
|
||||||
|
Weapon sword = new Sword();
|
||||||
|
Armor armor = new KnightArmor();
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
System.out.println("Chose your character:");
|
||||||
|
System.out.printf("1. Knight | %sHP%s: 100, %sMP%s: 10\n", RED, RESET, YELLOW, RESET);
|
||||||
|
System.out.printf("2. Wizard | %sHP%s: 150, %sMP%s: 10\n", RED, RESET, YELLOW, RESET);
|
||||||
|
System.out.printf("3. Assassin | %sHP%s: 80 , %sMP%s: 20\n", RED, RESET, YELLOW, RESET);
|
||||||
|
player = switch (input.nextInt()) {
|
||||||
|
case 1 -> new Knight(name, sword, armor);
|
||||||
|
case 2 -> new Wizard(name, sword, armor);
|
||||||
|
case 3 -> new Assassin(name, sword, armor);
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
if (player == null) {
|
||||||
|
System.out.println("Invalid input try again.");
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location overworld = new Location("Overworld", new Vampire(sword));
|
||||||
|
Location village = new Location("Village", new Goblin(sword));
|
||||||
|
Location nether = new Location("Nether", new Skeleton(sword));
|
||||||
|
Location end = new Location("End", new Dragon());
|
||||||
|
|
||||||
|
// Fight each enemy
|
||||||
|
fightEnemy(player, overworld, "Vampire", "Overworld");
|
||||||
|
if (!player.isAlive()) {
|
||||||
|
System.out.println("You lost!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fightEnemy(player, village, "Goblin", "Village");
|
||||||
|
if (!player.isAlive()) {
|
||||||
|
System.out.println("You lost!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fightEnemy(player, nether, "Skeleton", "Nether");
|
||||||
|
if (!player.isAlive()) {
|
||||||
|
System.out.println("You lost!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fightEnemy(player, end, "Dragon","End");
|
||||||
|
if (!player.isAlive()) {
|
||||||
|
System.out.println("You lost!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printBorder();
|
||||||
|
System.out.println(GREEN + " " + RESET);
|
||||||
|
System.out.println(RED + " VICTORY! " + RESET);
|
||||||
|
System.out.println(GREEN + " You have conquered all enemies! " + RESET);
|
||||||
|
System.out.println(GREEN + " The realm is safe, brave warrior. " + RESET);
|
||||||
|
System.out.println();
|
||||||
|
printBorder();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package org.project.entity;
|
package org.project.entity;
|
||||||
|
|
||||||
public interface Entity {
|
public interface Entity {
|
||||||
void attack(Entity target);
|
|
||||||
|
|
||||||
void defend();
|
void attack(Entity target);
|
||||||
|
|
||||||
void heal(int health);
|
void heal(int health);
|
||||||
|
|
||||||
@@ -14,8 +13,4 @@ public interface Entity {
|
|||||||
int getMaxHP();
|
int getMaxHP();
|
||||||
|
|
||||||
int getMaxMP();
|
int getMaxMP();
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.weapons.DragonBreath;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
public class Dragon extends Enemy{
|
||||||
|
public Dragon() {
|
||||||
|
int baseDamage = 2;
|
||||||
|
int hp = 500;
|
||||||
|
int mp = 1000;
|
||||||
|
Weapon weapon1 = new DragonBreath();
|
||||||
|
super(hp, mp, weapon1, baseDamage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void takeDamage(int damage) {
|
||||||
|
super.takeDamage(damage);
|
||||||
|
if(!isAlive)
|
||||||
|
getKilled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getKilled() {
|
||||||
|
isAlive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attack(Entity target) {
|
||||||
|
target.takeDamage((weapon.getDamage() + getBaseDamage()));
|
||||||
|
System.out.println("\u001B[31mDragon breathes a raging fire!\u001B[0m");
|
||||||
|
System.out.printf("\u001B[31mYou took %d damage.\u001B[0m\n", weapon.getDamage() + getBaseDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heal(int health) {
|
||||||
|
if (getHP() + health > getMaxHP())
|
||||||
|
setHP(getMaxHP());
|
||||||
|
else
|
||||||
|
setHP(getHP()+ health);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillMana(int mana) {
|
||||||
|
if (getMP() + mana > getMaxMP())
|
||||||
|
setMP(getMaxMP());
|
||||||
|
else
|
||||||
|
setMP(getMP()+ mana);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHP() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMP() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +1,57 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public abstract class Enemy implements Entity {
|
||||||
public abstract class Enemy {
|
|
||||||
Weapon weapon;
|
Weapon weapon;
|
||||||
|
boolean isAlive;
|
||||||
private int hp;
|
private int hp;
|
||||||
private int mp;
|
private int mp;
|
||||||
|
private int baseDamage;
|
||||||
|
|
||||||
public Enemy(int hp, int mp, Weapon weapon) {
|
public Enemy(int hp, int mp, Weapon weapon, int baseDamage) {
|
||||||
|
this.baseDamage = baseDamage;
|
||||||
|
isAlive = true;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHP(int hp) {
|
||||||
|
this.hp = hp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMP(int mp) {
|
||||||
|
this.mp = mp;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
|
if (0 >= (hp - damage)) {
|
||||||
|
isAlive = false;
|
||||||
|
hp = 0;
|
||||||
|
System.out.println("\u001B[32myou killed your enemy\u001B[0m");
|
||||||
|
return;
|
||||||
|
}
|
||||||
hp -= damage;
|
hp -= damage;
|
||||||
|
System.out.printf("\u001B[31mEnemy took %d damage.\u001B[0m\n", damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHp() {
|
public abstract void getKilled();
|
||||||
|
|
||||||
|
public int getHP() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMp() {
|
public int getMP() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBaseDamage() {
|
||||||
|
return baseDamage;
|
||||||
|
}
|
||||||
|
|
||||||
public Weapon getWeapon() {
|
public Weapon getWeapon() {
|
||||||
return weapon;
|
return weapon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Goblin extends Enemy {
|
||||||
|
public Goblin(Weapon weapon) {
|
||||||
|
int hp = 30;
|
||||||
|
int mp = 50;
|
||||||
|
super(hp, mp, weapon, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getKilled() {
|
||||||
|
isAlive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attack(Entity target) {
|
||||||
|
Random rand = new Random();
|
||||||
|
if (rand.nextBoolean()) {
|
||||||
|
target.takeDamage((weapon.getDamage() + getBaseDamage()) * 2);
|
||||||
|
System.out.println("\u001B[33mGoblin did critical Hit!!!!!\u001B[0m");
|
||||||
|
System.out.printf("\u001B[31mYou took %d damage.\u001B[0m\n", (weapon.getDamage() + getBaseDamage()) * 2);
|
||||||
|
} else {
|
||||||
|
target.takeDamage(weapon.getDamage() + getBaseDamage());
|
||||||
|
System.out.printf("\u001B[31mYou took %d damage.\u001B[0m\n", weapon.getDamage() + getBaseDamage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heal(int health) {
|
||||||
|
if (getHP() + health > getMaxHP())
|
||||||
|
setHP(getMaxHP());
|
||||||
|
else
|
||||||
|
setHP(getHP() + health);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillMana(int mana) {
|
||||||
|
if (getMP() + mana > getMaxMP())
|
||||||
|
setMP(getMaxMP());
|
||||||
|
else
|
||||||
|
setMP(getMP() + mana);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHP() {
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMP() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,65 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.entity.Entity;
|
||||||
public class Skeleton {
|
import org.project.item.weapons.Weapon;
|
||||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
|
||||||
|
public class Skeleton extends Enemy {
|
||||||
|
int timesDied;
|
||||||
|
|
||||||
|
public Skeleton(Weapon weapon) {
|
||||||
|
int hp = 50;
|
||||||
|
int mp = 50;
|
||||||
|
timesDied = 0;
|
||||||
|
super(hp, mp, weapon, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void takeDamage(int damage) {
|
||||||
|
super.takeDamage(damage);
|
||||||
|
if (!isAlive)
|
||||||
|
getKilled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getKilled() {
|
||||||
|
if (timesDied == 0) {
|
||||||
|
timesDied += 1;
|
||||||
|
setHP(getMaxHP() / 2);
|
||||||
|
System.out.println("\u001B[33myour enemy revived itself!!!\u001B[0m");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isAlive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attack(Entity target) {
|
||||||
|
target.takeDamage((weapon.getDamage() + getBaseDamage()));
|
||||||
|
System.out.printf("\u001B[31mYou took %d damage.\u001B[0m\n", weapon.getDamage() + getBaseDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heal(int health) {
|
||||||
|
if (getHP() + health > getMaxHP())
|
||||||
|
setHP(getMaxHP());
|
||||||
|
else
|
||||||
|
setHP(getHP() + health);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillMana(int mana) {
|
||||||
|
if (getMP() + mana > getMaxMP())
|
||||||
|
setMP(getMaxMP());
|
||||||
|
else
|
||||||
|
setMP(getMP() + mana);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHP() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMP() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
public class Vampire extends Enemy {
|
||||||
|
public Vampire(Weapon weapon) {
|
||||||
|
int maxHP = 50;
|
||||||
|
int maxMP = 50;
|
||||||
|
super(maxHP, maxMP, weapon, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getKilled() {
|
||||||
|
isAlive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attack(Entity target) {
|
||||||
|
target.takeDamage((weapon.getDamage() + getBaseDamage()));
|
||||||
|
System.out.println("\u001B[35mVampire stole your HP\u001B[0m");
|
||||||
|
System.out.printf("\u001B[32mVampire: +%d hp\u001B[0m\n", (int) ((weapon.getDamage() + getBaseDamage()) * 0.5));
|
||||||
|
this.heal((int) ((weapon.getDamage() + getBaseDamage()) * 0.5));
|
||||||
|
System.out.printf("\u001B[31mYou took %d damage.\u001B[0m\n", (int) (weapon.getDamage() + getBaseDamage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heal(int health) {
|
||||||
|
if (getHP() + health > getMaxHP())
|
||||||
|
setHP(getMaxHP());
|
||||||
|
else
|
||||||
|
setHP(getHP() + health);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillMana(int mana) {
|
||||||
|
if (getMP() + mana > getMaxMP())
|
||||||
|
setMP(getMaxMP());
|
||||||
|
else
|
||||||
|
setMP(getMP() + mana);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHP() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMP() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
public class Assassin extends Player{
|
||||||
|
|
||||||
|
public Assassin(String name, Weapon weapon, Armor armor) {
|
||||||
|
int hp = 80;
|
||||||
|
int mp = 20;
|
||||||
|
int baseDamage = 5;
|
||||||
|
super(name, hp, mp, baseDamage, weapon, armor);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.item.armors.Armor;
|
||||||
public class Knight {
|
import org.project.item.weapons.Weapon;
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
|
||||||
|
public class Knight extends Player {
|
||||||
|
|
||||||
|
public Knight(String name, Weapon weapon, Armor armor) {
|
||||||
|
int hp = 100;
|
||||||
|
int mp = 10;
|
||||||
|
int baseDamage = 10;
|
||||||
|
super(name, hp, mp, baseDamage, weapon, armor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import org.project.entity.Entity;
|
|||||||
import org.project.item.armors.Armor;
|
import org.project.item.armors.Armor;
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public abstract class Player implements Entity {
|
||||||
public abstract class Player {
|
|
||||||
protected String name;
|
protected String name;
|
||||||
Weapon weapon;
|
Weapon weapon;
|
||||||
Armor armor;
|
Armor armor;
|
||||||
@@ -13,30 +12,42 @@ public abstract class Player {
|
|||||||
private int maxHP;
|
private int maxHP;
|
||||||
private int mp;
|
private int mp;
|
||||||
private int maxMP;
|
private int maxMP;
|
||||||
|
private int baseDamage;
|
||||||
|
private boolean isAlive;
|
||||||
|
|
||||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
public int getBaseDamage() {
|
||||||
|
return baseDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player(String name, int hp, int mp, int baseDamage, Weapon weapon, Armor armor) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.maxHP = hp;
|
||||||
|
this.maxMP = mp;
|
||||||
|
this.baseDamage = baseDamage;
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
this.armor = armor;
|
this.armor = armor;
|
||||||
|
this.isAlive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attack(Entity target) {
|
public void attack(Entity target) {
|
||||||
target.takeDamage(weapon.getDamage());
|
target.takeDamage(weapon.getDamage() + this.baseDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void heavyAttack(Entity target) {
|
||||||
public void defend() {
|
target.takeDamage(weapon.getDamage() + this.baseDamage + 7);
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
hp -= damage - armor.getDefense();
|
if (damage - armor.getDefense() > 0) {
|
||||||
|
hp -= damage - armor.getDefense();
|
||||||
|
if (hp <= 0) {
|
||||||
|
getKilled();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,6 +56,7 @@ public abstract class Player {
|
|||||||
if (hp > maxHP) {
|
if (hp > maxHP) {
|
||||||
hp = maxHP;
|
hp = maxHP;
|
||||||
}
|
}
|
||||||
|
System.out.println("\u001B[32myou Healed yourself!\u001B[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,15 +64,16 @@ public abstract class Player {
|
|||||||
mp += mana;
|
mp += mana;
|
||||||
if (mp > maxMP) {
|
if (mp > maxMP) {
|
||||||
mp = maxMP;
|
mp = maxMP;
|
||||||
}
|
System.out.println("\u001B[33myour Mana got spilled.\u001B[0m");
|
||||||
|
} else
|
||||||
|
System.out.printf("\u001B[36m+%d Mana\u001B[0m\n", mana);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHp() {
|
public int getHP() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +82,7 @@ public abstract class Player {
|
|||||||
return maxHP;
|
return maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMp() {
|
public int getMP() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,4 +99,21 @@ public abstract class Player {
|
|||||||
return armor;
|
return armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAlive() {
|
||||||
|
return isAlive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getKilled() {
|
||||||
|
isAlive = false;
|
||||||
|
System.out.println("\u001B[31mYou died!\u001B[0m");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean useMana(int mana) {
|
||||||
|
if (mp - mana < 0)
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
mp -= mana;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
public class Wizard extends Player{
|
||||||
|
public Wizard(String name, Weapon weapon, Armor armor) {
|
||||||
|
int hp = 150;
|
||||||
|
int mp = 10;
|
||||||
|
int baseDamage = 4;
|
||||||
|
super(name, hp, mp, baseDamage, weapon, armor);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
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
|
int defense = 6;
|
||||||
|
int durability = 20;
|
||||||
|
super(defense, durability);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package org.project.item.consumables;
|
package org.project.item.consumables;
|
||||||
|
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Consumable {
|
public abstract class Consumable implements Item {
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.project.item.consumables;
|
|||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Flask {
|
public class Flask extends Consumable{
|
||||||
/*
|
/*
|
||||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
public class DragonBreath extends Weapon{
|
||||||
|
public DragonBreath() {
|
||||||
|
super(8, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import org.project.entity.Entity;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Sword {
|
public class Sword extends Weapon{
|
||||||
/*
|
/*
|
||||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||||
*/
|
*/
|
||||||
@@ -13,7 +13,9 @@ public class Sword {
|
|||||||
int abilityCharge;
|
int abilityCharge;
|
||||||
|
|
||||||
public Sword() {
|
public Sword() {
|
||||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
int damage = 2;
|
||||||
|
int manaCost = 10;
|
||||||
|
super(damage, manaCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
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
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Weapon {
|
public abstract class Weapon implements Item {
|
||||||
private int damage;
|
private int damage;
|
||||||
private int manaCost;
|
private int manaCost;
|
||||||
|
|
||||||
|
|||||||
@@ -2,27 +2,20 @@ package org.project.location;
|
|||||||
|
|
||||||
import org.project.entity.enemies.Enemy;
|
import org.project.entity.enemies.Enemy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Location {
|
public class Location {
|
||||||
private String name;
|
private String name;
|
||||||
|
private Enemy enemiy;
|
||||||
|
|
||||||
private ArrayList<Enemy> enemies;
|
public Location(String name,Enemy enemiy) {
|
||||||
|
this.enemiy = enemiy;
|
||||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
this.name = name;
|
||||||
this.locations = locations;
|
|
||||||
this.enemies = enemies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Location> getLocations() {
|
public Enemy getEnemy() {
|
||||||
return locations;
|
return enemiy;
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Enemy> getEnemies() {
|
|
||||||
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