develop #1
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,8 @@
|
|||||||
package org.project;
|
package org.project;
|
||||||
|
|
||||||
import org.project.location.Location;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
private Menu menu = new Menu();
|
||||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
public void main() {
|
||||||
List<Location> locations = new ArrayList<>();
|
menu.start();
|
||||||
|
|
||||||
// TODO: IMPLEMENT GAMEPLAY
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package org.project;
|
||||||
|
|
||||||
|
import org.project.entity.players.Knight;
|
||||||
|
import org.project.entity.players.Player;
|
||||||
|
import org.project.item.weapons.Sword;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Menu {
|
||||||
|
private Scanner scanner = new Scanner(System.in);
|
||||||
|
private MenuActions actions = new MenuActions();
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
while (true) {
|
||||||
|
System.out.println("\n"+"===== Java Knight =====");
|
||||||
|
System.out.println("Main menu");
|
||||||
|
System.out.println("What would you like to do, sir?");
|
||||||
|
System.out.println("1-Start a game");
|
||||||
|
System.out.println("2-Show help and game tips.");
|
||||||
|
System.out.println("0-Exit");
|
||||||
|
System.out.println("=======================");
|
||||||
|
|
||||||
|
int choice = getValidIntInput();
|
||||||
|
switch(choice) {
|
||||||
|
case 0: return;
|
||||||
|
case 1: startMenu(); break;
|
||||||
|
case 2: showHelp(); break;
|
||||||
|
default:
|
||||||
|
System.out.println("Invalid choice, please choose a number between 0-2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startMenu() {
|
||||||
|
Player player = chooseCharacter();
|
||||||
|
if (player == null) {
|
||||||
|
System.out.println("Returning to the main menu...");
|
||||||
|
start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
actions.startGame(player);
|
||||||
|
}
|
||||||
|
public Player chooseCharacter() {
|
||||||
|
String name;
|
||||||
|
Player character = null;
|
||||||
|
System.out.println("Enter Your name: ");
|
||||||
|
name = scanner.nextLine();
|
||||||
|
System.out.println("\n" + "Choose a character: ");
|
||||||
|
System.out.println("1-Knight");
|
||||||
|
System.out.println("2-Wizard");
|
||||||
|
System.out.println("3-Assassin");
|
||||||
|
System.out.println("0-back");
|
||||||
|
|
||||||
|
boolean keepAsking = true;
|
||||||
|
while (keepAsking) {
|
||||||
|
int choice = getValidIntInput();
|
||||||
|
switch (choice) {
|
||||||
|
case 1: character = new Knight(name, 1000, 1000, new Sword(), 5, 5);
|
||||||
|
System.out.println("You are a knight!");
|
||||||
|
keepAsking = false; break;
|
||||||
|
case 2: character = new Knight(name);
|
||||||
|
System.out.println("You are a wizard!");
|
||||||
|
keepAsking = false; break;
|
||||||
|
case 3: character = new Knight(name);
|
||||||
|
System.out.println("You are an assassin!");
|
||||||
|
keepAsking = false; break;
|
||||||
|
case 0: keepAsking = false; break;
|
||||||
|
default: System.out.println("Invalid choice, please choose a number between 0-3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return character;
|
||||||
|
|
||||||
|
}
|
||||||
|
private void showHelp() {
|
||||||
|
System.out.println("\n"+"===== Java Knight =====");
|
||||||
|
System.out.println("Help menu");
|
||||||
|
System.out.println("What do you need help with, sir?");
|
||||||
|
System.out.println("1-What is Java-Knight?");
|
||||||
|
System.out.println("2-How to play");
|
||||||
|
System.out.println("3-About characters");
|
||||||
|
System.out.println("4-General tips");
|
||||||
|
System.out.println("0-Back");
|
||||||
|
System.out.println("=======================");
|
||||||
|
}
|
||||||
|
private int getValidIntInput() {
|
||||||
|
while (!scanner.hasNextInt()) {
|
||||||
|
System.out.print("Please enter a valid number: ");
|
||||||
|
scanner.next();
|
||||||
|
}
|
||||||
|
int input = scanner.nextInt();
|
||||||
|
scanner.nextLine(); // Clear buffer
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
package org.project;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.entity.enemies.Enemy;
|
||||||
|
import org.project.entity.enemies.Skeleton;
|
||||||
|
import org.project.entity.players.Player;
|
||||||
|
import org.project.location.Location;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class MenuActions {
|
||||||
|
private ArrayList<Location> locations = new ArrayList<>();
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
public void startGame(Player player) {
|
||||||
|
while (player.getKeysCollected() < 3) {
|
||||||
|
System.out.println("Keys collected: " + player.getKeysCollected());
|
||||||
|
askInventory(player);
|
||||||
|
Enemy enemy = chooseEnemy();
|
||||||
|
Entity winner = fight(player, enemy);
|
||||||
|
if (winner != player) {
|
||||||
|
System.out.println("Game over!\nreturning to main menu...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
askInventory(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Enemy chooseEnemy() {
|
||||||
|
while (true) {
|
||||||
|
Location location = new Location();
|
||||||
|
Enemy enemy = location.getEnemies().get(0);
|
||||||
|
String enemyName = enemy.getType();
|
||||||
|
System.out.println("====================================");
|
||||||
|
System.out.println("You are in the " + location.getName() + ".\nYou may fight with a "
|
||||||
|
+ enemyName);
|
||||||
|
System.out.println("Which option do you choose?" +"\n1- Fight with the "
|
||||||
|
+ enemyName + "\n2- Skip to Another Location");
|
||||||
|
outerLoop:
|
||||||
|
while (true) {
|
||||||
|
int choice = getValidIntInput();
|
||||||
|
switch (choice) {
|
||||||
|
case 1:
|
||||||
|
return enemy;
|
||||||
|
case 2:
|
||||||
|
System.out.println("You chose not to fight...Skipping to next location...");break outerLoop;
|
||||||
|
default:
|
||||||
|
System.out.println("Invalid choice. Please choose a number (1 or 2).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLocation(String name) {
|
||||||
|
locations.add(new Location(name));
|
||||||
|
}
|
||||||
|
public Entity fight(Player player, Enemy enemy) {
|
||||||
|
player.heal(player.getMaxHP());
|
||||||
|
player.fillMana(player.getMaxMP());
|
||||||
|
Entity winner = null;
|
||||||
|
while (true) {
|
||||||
|
playerTurn(player, enemy);
|
||||||
|
if (enemy.getHp() == 0) {
|
||||||
|
winner = player;
|
||||||
|
System.out.println(player.getName() + " won the fight!");
|
||||||
|
player.setXp(player.getXp()+5);
|
||||||
|
System.out.println(player.getName() + " got 5 XP for winning the fight!");
|
||||||
|
System.out.println("Keys collected: " + player.getKeysCollected());
|
||||||
|
if (enemy instanceof Skeleton) {
|
||||||
|
boolean hasKey = ((Skeleton) enemy).generateKey();
|
||||||
|
if (hasKey) {
|
||||||
|
player.collectKey();
|
||||||
|
player.setXp(player.getXp()+20);
|
||||||
|
System.out.println(player.getName() + " got a key and 20 XP!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return winner;
|
||||||
|
}
|
||||||
|
enemyTurn(player, enemy);
|
||||||
|
if (player.getHp() == 0) {
|
||||||
|
winner = enemy;
|
||||||
|
System.out.println(winner.getType() + " won the fight!");
|
||||||
|
return winner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enemyTurn(Player player, Enemy enemy) {
|
||||||
|
System.out.println("====================================");
|
||||||
|
System.out.println("Enemy turn. Let's see what it does!");
|
||||||
|
System.out.println("Your hp: " + player.getHp() + "/" + player.getMaxHP());
|
||||||
|
System.out.println("Enemy hp: " + enemy.getHp() + "/" + enemy.getMaxHP());
|
||||||
|
// System.out.println("1-Light attack, mana cost: 0");
|
||||||
|
// System.out.println("2-Heavy attack, mana cost: ");
|
||||||
|
// System.out.println("3-Special Ability, mana cost: ");
|
||||||
|
// System.out.println("4-Defend, mana cost: 10");
|
||||||
|
// System.out.println("5-Heal, mana cost: 20");
|
||||||
|
while (true) {
|
||||||
|
Random random = new Random();
|
||||||
|
int choice = random.nextInt(5) + 1;
|
||||||
|
switch (choice) {
|
||||||
|
case 1: enemy.getWeapon().lightAttack(player); return;
|
||||||
|
case 2: if(enemy.getMp() >= enemy.getWeapon().getManaCost()) {
|
||||||
|
enemy.getWeapon().heavyAttack(enemy, player); return;
|
||||||
|
} break;
|
||||||
|
case 3: if (enemy.getMp() >= enemy.getWeapon().getSpecialMana()){
|
||||||
|
enemy.getWeapon().useSpecialAbility(enemy, player); return;
|
||||||
|
} break;
|
||||||
|
case 4: if (enemy.getMp() >= enemy.getDefendManaCost()) {
|
||||||
|
enemy.defend(); return;
|
||||||
|
} break;
|
||||||
|
case 5: if (enemy.getMp() >= enemy.getHealManaCost()) {
|
||||||
|
enemy.heal(20); return;
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
System.out.println("Invalid choice");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playerTurn(Player player, Enemy enemy) {
|
||||||
|
System.out.println("====================================");
|
||||||
|
System.out.println("Player turn. What do you want to do?");
|
||||||
|
System.out.println("Your hp: " + player.getHp() + "/" + player.getMaxHP() +
|
||||||
|
"\t Your mana: " + player.getMp() + "/" + player.getMaxMP());
|
||||||
|
System.out.println("Enemy hp: " + enemy.getHp() + "/" + enemy.getMaxHP());
|
||||||
|
System.out.println("1-Light attack, mana cost: 0");
|
||||||
|
System.out.println("2-Heavy attack, mana cost: " + player.getWeapon().getManaCost());
|
||||||
|
System.out.println("3-Special Ability, mana cost: " + player.getWeapon().getSpecialMana());
|
||||||
|
System.out.println("4-Defend, mana cost: " + player.getDefendManaCost());
|
||||||
|
System.out.println("5-Heal, mana cost: " + player.getHealManaCost());
|
||||||
|
while (true) {
|
||||||
|
int choice = getValidIntInput();
|
||||||
|
switch (choice) {
|
||||||
|
case 1: player.getWeapon().lightAttack(enemy);
|
||||||
|
System.out.println("You chose light attack.");return;
|
||||||
|
case 2: if(player.getMp() >= player.getWeapon().getManaCost()) {
|
||||||
|
player.getWeapon().heavyAttack(player, enemy);
|
||||||
|
System.out.println("You chose heavy attack.");return;
|
||||||
|
} else {
|
||||||
|
System.out.println("Not enough mana. Choose Again: "); break;
|
||||||
|
}
|
||||||
|
case 3: if (player.getMp() >= player.getWeapon().getSpecialMana()){
|
||||||
|
player.getWeapon().useSpecialAbility(player, enemy);
|
||||||
|
System.out.println("You chose special ability.");return;
|
||||||
|
} else {
|
||||||
|
System.out.println("Not enough mana. Choose Again: "); break;
|
||||||
|
}
|
||||||
|
case 4: if (player.getMp() >= player.getDefendManaCost()) {
|
||||||
|
player.defend();
|
||||||
|
System.out.println("You chose to defend."); return;
|
||||||
|
} else {
|
||||||
|
System.out.println("Not enough mana. Choose Again: "); break;
|
||||||
|
}
|
||||||
|
case 5: if (player.getMp() >= player.getHealManaCost()) {
|
||||||
|
player.heal(20); return;
|
||||||
|
} else {
|
||||||
|
System.out.println("Not enough mana. Choose Again:");
|
||||||
|
System.out.println("You chose to heal yourself.");break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
System.out.println("Invalid choice");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void askInventory(Player player) {
|
||||||
|
System.out.println("Choose an option: ");
|
||||||
|
System.out.println("1- Go to the inventory");
|
||||||
|
System.out.println("2- Continue to next fight");
|
||||||
|
while (true) {
|
||||||
|
int choice = getValidIntInput();
|
||||||
|
switch (choice) {
|
||||||
|
case 1: shop(player);
|
||||||
|
case 2: return;
|
||||||
|
default:
|
||||||
|
System.out.println("Invalid choice, please choose a number (1 or 2)."); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shop(Player player) {
|
||||||
|
while (true) {
|
||||||
|
System.out.println("=====Shop=====");
|
||||||
|
System.out.println("You have " + player.getXp() + " XP");
|
||||||
|
System.out.println("Each experience point can be converted into either 1 mana or 1 hp");
|
||||||
|
System.out.println("Which option do you choose?");
|
||||||
|
System.out.println("1- Buy hp");
|
||||||
|
System.out.println("2- Buy mana");
|
||||||
|
System.out.println("0- Back");
|
||||||
|
switchLoop:
|
||||||
|
while(true) {
|
||||||
|
int choice = getValidIntInput();
|
||||||
|
switch (choice) {
|
||||||
|
case 1:
|
||||||
|
while (true) {
|
||||||
|
System.out.println("Enter amount: " + "\tShould be less than or equal to " + player.getXp());
|
||||||
|
int amount = getValidIntInput();
|
||||||
|
if (amount <= player.getXp()) {
|
||||||
|
player.buyHp(amount);
|
||||||
|
System.out.println("Successfully bought " + amount + " hp.");
|
||||||
|
System.out.println("Current hp and mana: " + "\thp: " + player.getMaxHP() +"\tmana: " + player.getMaxMP());
|
||||||
|
break switchLoop;
|
||||||
|
} else if (amount > player.getXp()) {
|
||||||
|
System.out.println("Not enough XP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
while (true) {
|
||||||
|
System.out.println("Enter amount: " + "\tShould be less than or equal to " + player.getXp());
|
||||||
|
int amount = getValidIntInput();
|
||||||
|
if (amount <= player.getXp()) {
|
||||||
|
player.buyMp(amount);
|
||||||
|
System.out.println("Successfully bought " + amount + " mana.");
|
||||||
|
System.out.println("Current maximum hp and mana: " + "\thp: " + player.getMaxHP() +"\tmana: " + player.getMaxMP());
|
||||||
|
break switchLoop;
|
||||||
|
} else if (amount > player.getXp()) {
|
||||||
|
System.out.println("Not enough XP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 0: return;
|
||||||
|
default:
|
||||||
|
System.out.println("Invalid choice. Please choose a number from 0-2.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int getValidIntInput() {
|
||||||
|
while (!scanner.hasNextInt()) {
|
||||||
|
System.out.print("Please enter a valid number: ");
|
||||||
|
scanner.next();
|
||||||
|
}
|
||||||
|
int input = scanner.nextInt();
|
||||||
|
scanner.nextLine(); // Clear buffer
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package org.project.entity;
|
package org.project.entity;
|
||||||
|
|
||||||
public interface Entity {
|
public interface Entity {
|
||||||
void attack(Entity target);
|
|
||||||
|
|
||||||
void defend();
|
void defend();
|
||||||
|
|
||||||
void heal(int health);
|
void heal(int health);
|
||||||
@@ -11,10 +9,18 @@ public interface Entity {
|
|||||||
|
|
||||||
void takeDamage(int damage);
|
void takeDamage(int damage);
|
||||||
|
|
||||||
|
void reduceMana(int mana);
|
||||||
|
|
||||||
int getMaxHP();
|
int getMaxHP();
|
||||||
|
|
||||||
int getMaxMP();
|
int getMaxMP();
|
||||||
|
|
||||||
|
String getType();
|
||||||
|
|
||||||
|
int getHealManaCost();
|
||||||
|
int getDefendManaCost();
|
||||||
|
void skipNextTurn();
|
||||||
|
void skipTurn();
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,33 +1,109 @@
|
|||||||
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
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Enemy {
|
public abstract class Enemy implements Entity {
|
||||||
Weapon weapon;
|
Weapon weapon;
|
||||||
private int hp;
|
private int hp;
|
||||||
|
private int maxHP;
|
||||||
private int mp;
|
private int mp;
|
||||||
|
private int maxMP;
|
||||||
public Enemy(int hp, int mp, Weapon weapon) {
|
private boolean canPlayThisTurn = true;
|
||||||
|
private boolean isDefendingThisTurn = false;
|
||||||
|
private boolean isAlive;
|
||||||
|
private int healManaCost;
|
||||||
|
private int defendManaCost;
|
||||||
|
public Enemy(int hp, int mp, Weapon weapon,
|
||||||
|
int healManaCost, int defendManaCost) {
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.maxHP = hp;
|
||||||
|
this.maxMP = mp;
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
|
this.healManaCost = healManaCost;
|
||||||
|
this.defendManaCost = defendManaCost;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void defend() {
|
||||||
|
isDefendingThisTurn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
|
if (!isDefendingThisTurn) {
|
||||||
hp -= damage;
|
hp -= damage;
|
||||||
|
if (hp < 0) {
|
||||||
|
hp = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isDefendingThisTurn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void heal(int health) {
|
||||||
|
hp += health;
|
||||||
|
if (hp > maxHP) {
|
||||||
|
hp = maxHP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillMana(int mana) {
|
||||||
|
mp += mana;
|
||||||
|
if (mp > maxMP) {
|
||||||
|
mp = maxMP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reduceMana(int mana) {
|
||||||
|
mp -= mana;
|
||||||
|
if (mp < 0) {
|
||||||
|
mp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void skipNextTurn() {
|
||||||
|
this.canPlayThisTurn = false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void skipTurn() {
|
||||||
|
this.canPlayThisTurn = true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Enemy";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHP() {
|
||||||
|
return maxHP;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxMP() {
|
||||||
|
return maxMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHealManaCost() {
|
||||||
|
return healManaCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefendManaCost() {
|
||||||
|
return defendManaCost;
|
||||||
|
}
|
||||||
|
|
||||||
public Weapon getWeapon() {
|
public Weapon getWeapon() {
|
||||||
return weapon;
|
return weapon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
public interface Key {
|
||||||
|
boolean generateKey();
|
||||||
|
void decreaseKey();
|
||||||
|
int getKeysRemaining();
|
||||||
|
}
|
||||||
@@ -1,6 +1,56 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.item.weapons.BoneHarpoon;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Skeleton {
|
public class Skeleton extends Enemy implements Key {
|
||||||
|
private static int DEFAULT_HP = 100;
|
||||||
|
private static int DEFAULT_MP = 100;
|
||||||
|
private static BoneHarpoon DEFAULT_WEAPON = new BoneHarpoon();
|
||||||
|
private static int DEFAULT_HEAL_MANA_COST = 30;
|
||||||
|
private static int DEFAULT_DEFEND_MANA_COST = 20;
|
||||||
|
private static int keysRemaining = 1;
|
||||||
|
private boolean hasKey = false;
|
||||||
|
|
||||||
|
public Skeleton() {
|
||||||
|
super(DEFAULT_HP, DEFAULT_MP, DEFAULT_WEAPON,
|
||||||
|
DEFAULT_HEAL_MANA_COST, DEFAULT_DEFEND_MANA_COST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Skeleton(String name, int hp, int mp, Weapon weapon,
|
||||||
|
int healManaCost, int defendManaCost) {
|
||||||
|
super(hp, mp, weapon, healManaCost, defendManaCost);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Skeleton" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean generateKey() {
|
||||||
|
if (keysRemaining > 0) {
|
||||||
|
Random random = new Random();
|
||||||
|
int dice = random.nextInt(5);
|
||||||
|
if (dice == 1) {
|
||||||
|
decreaseKey();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decreaseKey() {
|
||||||
|
keysRemaining -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getKeysRemaining() {
|
||||||
|
return keysRemaining;
|
||||||
|
}
|
||||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,40 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.weapons.Sword;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Knight {
|
public class Knight extends Player {
|
||||||
|
private static int DEFAULT_HP = 100;
|
||||||
|
private static int DEFAULT_MP = 100;
|
||||||
|
private static Sword DEFAULT_WEAPON = new Sword();
|
||||||
|
private static String DEFAULT_NAME = "Ser Duncan";
|
||||||
|
private static int DEFAULT_HEAL_MANA_COST = 30;
|
||||||
|
private static int DEFAULT_DEFEND_MANA_COST = 20;
|
||||||
|
|
||||||
|
public Knight() {
|
||||||
|
super(DEFAULT_NAME, DEFAULT_HP, DEFAULT_MP, DEFAULT_WEAPON,
|
||||||
|
DEFAULT_HEAL_MANA_COST, DEFAULT_DEFEND_MANA_COST);
|
||||||
|
}
|
||||||
|
public Knight(String name) {
|
||||||
|
super(name, DEFAULT_HP, DEFAULT_MP, DEFAULT_WEAPON,
|
||||||
|
DEFAULT_HEAL_MANA_COST, DEFAULT_DEFEND_MANA_COST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Knight(String name, int hp, int mp, Weapon weapon,
|
||||||
|
int healManaCost, int defendManaCost) {
|
||||||
|
super(name, hp, mp, weapon, healManaCost, defendManaCost);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Knight" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,46 +5,64 @@ import org.project.item.armors.Armor;
|
|||||||
import org.project.item.weapons.Weapon;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Player {
|
public abstract class Player implements Entity{
|
||||||
protected String name;
|
protected String name;
|
||||||
Weapon weapon;
|
Weapon weapon;
|
||||||
Armor armor;
|
|
||||||
private int hp;
|
private int hp;
|
||||||
private int maxHP;
|
private int maxHP;
|
||||||
private int mp;
|
private int mp;
|
||||||
private int maxMP;
|
private int maxMP;
|
||||||
|
private boolean canPlayThisTurn = true;
|
||||||
|
private boolean isDefendingThisTurn = false;
|
||||||
|
private int healManaCost;
|
||||||
|
private int defendManaCost;
|
||||||
|
private int keysCollected;
|
||||||
|
private int xp = 0;
|
||||||
|
|
||||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
public Player(String name, int hp, int mp, Weapon weapon,
|
||||||
|
int healManaCost, int defendManaCost) {
|
||||||
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.weapon = weapon;
|
this.weapon = weapon;
|
||||||
this.armor = armor;
|
this.keysCollected = 0;
|
||||||
|
this.healManaCost = healManaCost;
|
||||||
|
this.defendManaCost = defendManaCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void collectKey() {
|
||||||
public void attack(Entity target) {
|
keysCollected += 1;
|
||||||
target.takeDamage(weapon.getDamage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void defend() {
|
public void defend() {
|
||||||
// TODO
|
isDefendingThisTurn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
hp -= damage - armor.getDefense();
|
if (!isDefendingThisTurn) {
|
||||||
|
hp -= damage;
|
||||||
|
if (hp < 0) {
|
||||||
|
hp = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isDefendingThisTurn = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void heal(int health) {
|
public void heal(int health) {
|
||||||
|
if (hp < maxHP) {
|
||||||
hp += health;
|
hp += health;
|
||||||
if (hp > maxHP) {
|
if (hp > maxHP) {
|
||||||
hp = maxHP;
|
hp = maxHP;
|
||||||
}
|
}
|
||||||
|
this.reduceMana(this.getHealManaCost());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,7 +73,22 @@ public abstract class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reduceMana(int mana) {
|
||||||
|
mp -= mana;
|
||||||
|
if (mp < 0) {
|
||||||
|
mp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void skipNextTurn() {
|
||||||
|
this.canPlayThisTurn = false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void skipTurn() {
|
||||||
|
this.canPlayThisTurn = true;
|
||||||
|
}
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -69,6 +102,10 @@ public abstract class Player {
|
|||||||
return maxHP;
|
return maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxHP(int maxHP) {
|
||||||
|
this.maxHP = maxHP;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
@@ -77,13 +114,49 @@ public abstract class Player {
|
|||||||
public int getMaxMP() {
|
public int getMaxMP() {
|
||||||
return maxMP;
|
return maxMP;
|
||||||
}
|
}
|
||||||
|
public void setMaxMP(int maxMP) {
|
||||||
|
this.maxMP = maxMP;
|
||||||
|
}
|
||||||
public Weapon getWeapon() {
|
public Weapon getWeapon() {
|
||||||
return weapon;
|
return weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Armor getArmor() {
|
public int getKeysCollected() {
|
||||||
return armor;
|
return keysCollected;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Player";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHealManaCost() {
|
||||||
|
return healManaCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getXp() {
|
||||||
|
return xp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXp(int xp) {
|
||||||
|
this.xp = xp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buyHp(int amount) {
|
||||||
|
if (amount <= this.getXp()) {
|
||||||
|
this.setXp(this.getXp() - amount);
|
||||||
|
this.setMaxHP(this.getMaxHP() + amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void buyMp(int amount) {
|
||||||
|
if (amount <= this.getXp()) {
|
||||||
|
this.setXp(this.getXp() - amount);
|
||||||
|
this.setMaxMP(this.getMaxMP() + amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefendManaCost() {
|
||||||
|
return defendManaCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package org.project.item;
|
|||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
public interface Item {
|
public interface Item {
|
||||||
void use(Entity target);
|
|
||||||
|
|
||||||
/*
|
String getType();
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
String getExplanation();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package org.project.item.consumables;
|
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public abstract class Consumable {
|
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package org.project.item.consumables;
|
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public class Flask {
|
|
||||||
/*
|
|
||||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: UPDATE USE METHOD
|
|
||||||
@Override
|
|
||||||
public void use(Entity target) {
|
|
||||||
target.heal(target.getMaxHP() / 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class BoneHarpoon extends Weapon{
|
||||||
|
private static int DEFAULT_DAMAGE = 10;
|
||||||
|
private static int DEFAULT_MANACOST = 10;
|
||||||
|
private static int DEFAULT_SPECIAL_MANA = 20;
|
||||||
|
|
||||||
|
public BoneHarpoon() {
|
||||||
|
super(DEFAULT_DAMAGE, DEFAULT_MANACOST, DEFAULT_SPECIAL_MANA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void useSpecialAbility(Entity attacker, Entity target) {
|
||||||
|
target.takeDamage(this.getDamage() + 10);
|
||||||
|
attacker.reduceMana(this.getSpecialMana());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Bone Harpoon(Skeletons)";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getExplanation() {
|
||||||
|
return "Melee slashing tool for skeletons.\n"+
|
||||||
|
"Damage: "+ this.getDamage() +" Mana cost: " + this.getManaCost() +
|
||||||
|
"\nSpecial ability: When used by the skeleton, it resurrects with 50% hp.";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class Dagger extends Weapon{
|
||||||
|
private static int DEFAULT_DAMAGE = 20;
|
||||||
|
private static int DEFAULT_MANACOST = 20;
|
||||||
|
private static int DEFAULT_SPECIAL_MANA = 20;
|
||||||
|
|
||||||
|
|
||||||
|
public Dagger() {
|
||||||
|
super(DEFAULT_DAMAGE, DEFAULT_MANACOST, DEFAULT_SPECIAL_MANA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void useSpecialAbility(Entity attacker, Entity target) {
|
||||||
|
target.takeDamage(50);
|
||||||
|
attacker.reduceMana(this.getManaCost() + 10);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Dagger(Assassins)";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getExplanation() {
|
||||||
|
return "Melee piercing for Assassins.\n"+
|
||||||
|
"Damage: "+ this.getDamage() +" Mana cost: " + this.getManaCost() +
|
||||||
|
"\nSpecial ability: Inflicts 40 damage";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class Fireball extends Weapon{
|
||||||
|
private static int DEFAULT_DAMAGE = 20;
|
||||||
|
private static int DEFAULT_MANACOST = 20;
|
||||||
|
private static int DEFAULT_SPECIAL_MANA = 20;
|
||||||
|
|
||||||
|
|
||||||
|
public Fireball() {
|
||||||
|
super(DEFAULT_DAMAGE, DEFAULT_MANACOST, DEFAULT_SPECIAL_MANA);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void useSpecialAbility(Entity attacker, Entity target) {
|
||||||
|
target.takeDamage(this.getDamage() * 3);
|
||||||
|
attacker.reduceMana(this.getManaCost() + 10);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Dagger(Assassins)";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getExplanation() {
|
||||||
|
return "Magical balls of fire for Wizards.\n"+
|
||||||
|
"Damage: "+ this.getDamage() +" Mana cost: " + this.getManaCost() +
|
||||||
|
"\nSpecial ability: Throws 3 fireballs at once inflicting 3 times the normal damage.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class GoblinSickle extends Weapon {
|
||||||
|
private static int DEFAULT_DAMAGE = 10;
|
||||||
|
private static int DEFAULT_MANACOST = 15;
|
||||||
|
private static int DEFAULT_SPECIAL_MANA = 20;
|
||||||
|
|
||||||
|
|
||||||
|
public GoblinSickle() {
|
||||||
|
super(DEFAULT_DAMAGE, DEFAULT_MANACOST, DEFAULT_SPECIAL_MANA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void useSpecialAbility(Entity attacker, Entity target) {
|
||||||
|
target.takeDamage(this.getDamage()*2);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Goblin Sickle(Goblins)";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getExplanation() {
|
||||||
|
return "Melee slashing tool for goblins. Causes bleeding over time.\n" +
|
||||||
|
"Damage: "+ this.getDamage() +" Mana cost: " + this.getManaCost() +
|
||||||
|
"Special ability: The target takes twice the normal damage.";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class MirrorClaws extends Weapon{
|
||||||
|
private static int DEFAULT_DAMAGE = 25;
|
||||||
|
private static int DEFAULT_MANACOST = 15;
|
||||||
|
private static int DEFAULT_SPECIAL_MANA = 20;
|
||||||
|
|
||||||
|
|
||||||
|
public MirrorClaws() {
|
||||||
|
super(DEFAULT_DAMAGE, DEFAULT_MANACOST, DEFAULT_SPECIAL_MANA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void useSpecialAbility(Entity attacker, Entity target) {
|
||||||
|
target.takeDamage(this.getDamage());
|
||||||
|
target.reduceMana(30);
|
||||||
|
attacker.reduceMana(this.getManaCost() + 10);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Mirror Claws(Vampires)";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getExplanation() {
|
||||||
|
return "Melee slashing weapon for vampires. Inflicts \"reflection\" debuff.\n" +
|
||||||
|
"Damage: "+ this.getDamage() +" Mana cost: " + this.getManaCost() +
|
||||||
|
"\nSpecial ability: reduces target's mana by 30 on top of normal damage.";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,22 +5,27 @@ 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 {
|
||||||
/*
|
private static int DEFAULT_DAMAGE = 20;
|
||||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
private static int DEFAULT_MANACOST = 20;
|
||||||
*/
|
private static int DEFAULT_SPECIAL_MANA = 30;
|
||||||
|
|
||||||
int abilityCharge;
|
|
||||||
|
|
||||||
public Sword() {
|
public Sword() {
|
||||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
super(DEFAULT_DAMAGE, DEFAULT_MANACOST, DEFAULT_SPECIAL_MANA);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
@Override
|
||||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
public void useSpecialAbility(Entity attacker, Entity target) {
|
||||||
abilityCharge += 2;
|
target.takeDamage(this.getDamage()* 2 + 5);
|
||||||
for (Entity target : targets) {
|
attacker.reduceMana(this.getManaCost());
|
||||||
target.takeDamage(getDamage());
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Sword(Knights)";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getExplanation() {
|
||||||
|
return "Melee piercing/bludgeoning for knights. Ignores armor on critical hits.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class TailScythe extends Weapon{
|
||||||
|
private static int DEFAULT_DAMAGE = 40;
|
||||||
|
private static int DEFAULT_MANACOST = 20;
|
||||||
|
private static int DEFAULT_SPECIAL_MANA = 20;
|
||||||
|
|
||||||
|
|
||||||
|
public TailScythe() {
|
||||||
|
super(DEFAULT_DAMAGE, DEFAULT_MANACOST, DEFAULT_SPECIAL_MANA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void useSpecialAbility(Entity attacker, Entity target) {
|
||||||
|
target.takeDamage(this.getDamage() + 20);
|
||||||
|
attacker.reduceMana(this.getManaCost() + 5);
|
||||||
|
target.skipNextTurn();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Tail Scythe(Dragons)";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getExplanation() {
|
||||||
|
return "Melee sweeping attack for Dragons. Hitting targets with its tail.\n" +
|
||||||
|
"Damage: "+ this.getDamage() +" Mana cost: " + this.getManaCost() +
|
||||||
|
"Special ability:The target takes +20 damage than normal attack. Also loses their next turn.";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,30 @@
|
|||||||
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;
|
||||||
|
private int specialMana;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Weapon(int damage, int manaCost) {
|
public Weapon(int damage, int manaCost, int specialMana) {
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.manaCost = manaCost;
|
this.manaCost = manaCost;
|
||||||
|
this.specialMana = specialMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManaCost(int manaCost) {
|
||||||
|
this.manaCost = manaCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setDamage(int damage) {
|
||||||
public void use(Entity target) {
|
this.damage = damage;
|
||||||
target.takeDamage(damage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDamage() {
|
public int getDamage() {
|
||||||
@@ -29,6 +35,22 @@ public abstract class Weapon {
|
|||||||
return manaCost;
|
return manaCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSpecialMana() {
|
||||||
|
return specialMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecialMana(int specialMana) {
|
||||||
|
this.specialMana = specialMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void lightAttack(Entity target) {
|
||||||
|
target.takeDamage(this.getDamage());
|
||||||
|
}
|
||||||
|
public void heavyAttack(Entity attacker, Entity target){
|
||||||
|
target.takeDamage(this.getDamage() * 2);
|
||||||
|
attacker.reduceMana(this.getManaCost());
|
||||||
|
}
|
||||||
|
public abstract void useSpecialAbility(Entity attacker, Entity target);
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,27 +1,75 @@
|
|||||||
package org.project.location;
|
package org.project.location;
|
||||||
|
|
||||||
import org.project.entity.enemies.Enemy;
|
import org.project.entity.enemies.Enemy;
|
||||||
|
import org.project.entity.enemies.Skeleton;
|
||||||
|
import org.project.item.weapons.BoneHarpoon;
|
||||||
|
import org.project.item.weapons.Sword;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
public class Location {
|
public class Location {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private ArrayList<Enemy> enemies;
|
private ArrayList<Enemy> enemies;
|
||||||
|
|
||||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
public Location() {
|
||||||
this.locations = locations;
|
this.name = pickName();
|
||||||
this.enemies = enemies;
|
this.enemies = new ArrayList<>();
|
||||||
|
addEnemy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location(String name, ArrayList<Enemy> enemies) {
|
||||||
|
this.name = name;
|
||||||
|
this.enemies = enemies;
|
||||||
|
addEnemy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.enemies = new ArrayList<>();
|
||||||
|
addEnemy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addEnemy() {
|
||||||
|
Random random = new Random();
|
||||||
|
int enemyId = random.nextInt(3);
|
||||||
|
Enemy e = null;
|
||||||
|
switch (enemyId) {
|
||||||
|
case 0: e = new Skeleton(); break;
|
||||||
|
case 1: e = new Skeleton(); break;
|
||||||
|
case 2: e = new Skeleton(); break;
|
||||||
|
}
|
||||||
|
this.enemies.add(e);
|
||||||
|
}
|
||||||
|
private void addSkeleton() {
|
||||||
|
Enemy e = new Skeleton();
|
||||||
|
this.enemies.add(e);
|
||||||
|
}
|
||||||
|
private void addGoblin() {
|
||||||
|
Enemy e = null;
|
||||||
|
this.enemies.add(e);
|
||||||
|
}
|
||||||
|
private void addVampire() {
|
||||||
|
Enemy e = null;
|
||||||
|
this.enemies.add(e);
|
||||||
|
}
|
||||||
|
public static String pickName() {
|
||||||
|
String[] locations = {
|
||||||
|
"Tomb", "Yard", "Road", "Jungle", "Pit", "Swamp", "Hill",
|
||||||
|
"Den", "Ditch", "Cave", "Bog", "Woods", "Cliff", "Edge",
|
||||||
|
"Crack", "Brush", "Mound"
|
||||||
|
};
|
||||||
|
Random rand = new Random();
|
||||||
|
String chosen = locations[rand.nextInt(locations.length)];
|
||||||
|
return chosen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Location> getLocations() {
|
|
||||||
return locations;
|
|
||||||
}
|
|
||||||
|
|
||||||
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.
Binary file not shown.
Reference in New Issue
Block a user