Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de808b0541 | ||
|
|
d77fc1f3f3 | ||
|
|
526f07f2c7 | ||
|
|
38fdd06a03 | ||
|
|
a7ff45292f |
Binary file not shown.
@@ -1,15 +1,523 @@
|
|||||||
package org.project;
|
package org.project;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
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.consumables.Flask;
|
||||||
|
import org.project.item.consumables.Teriak;
|
||||||
import org.project.location.Location;
|
import org.project.location.Location;
|
||||||
|
import java.util.Scanner;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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 final String RESET = "\u001B[0m";
|
||||||
|
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 Entity player;
|
||||||
|
public static Entity enemy;
|
||||||
|
public static Scanner input = new Scanner(System.in);
|
||||||
|
public static ArrayList<Boolean> keys = new ArrayList<Boolean>();
|
||||||
|
public static boolean running = true;
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
startMenu();
|
||||||
|
|
||||||
|
while (running){ // when exit ruuning will be false
|
||||||
|
|
||||||
|
do{
|
||||||
|
|
||||||
|
try { // if we have null location we handle with this try/catch
|
||||||
|
System.out.println("===============================");
|
||||||
|
Location fightLoc = fightMenu(); // make location with random enemy
|
||||||
|
enemy = fightLoc.getEnemie();
|
||||||
|
System.out.println(enemy.toString() + "| HP:" + enemy.getHp());
|
||||||
|
System.out.println("Do you want fight?");
|
||||||
|
System.out.println("1.Yes");
|
||||||
|
System.out.println("2.No(Go to another location)");
|
||||||
|
int n = input.nextInt();
|
||||||
|
if(n==1){
|
||||||
|
gameplay(); // if you want play go to gameplay()
|
||||||
|
if(!player.isalive()){ // result of match
|
||||||
|
System.out.println("===============================");
|
||||||
|
System.out.println( YELLOW + "Goodby!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println(BLUE);
|
||||||
|
player.repair();
|
||||||
|
System.out.println(RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(n >= 3){
|
||||||
|
System.out.println("Invalid input");
|
||||||
|
}
|
||||||
|
}catch (NullPointerException exception){
|
||||||
|
System.out.println( YELLOW + "Goodby!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}while (running);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//make keys array
|
||||||
|
public static void setKeys(){ // set key array for enemies
|
||||||
|
boolean goblinkey=false;
|
||||||
|
boolean skeletonkey = false;
|
||||||
|
boolean vampirekey = false;
|
||||||
|
keys.add(goblinkey);
|
||||||
|
keys.add(skeletonkey);
|
||||||
|
keys.add(vampirekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
this method choose for player in game
|
||||||
|
*/
|
||||||
|
public static void startMenu(){
|
||||||
|
System.out.println("----------Welcome to Java-Knight----------");
|
||||||
|
setKeys();
|
||||||
|
System.out.print("Please enter your name:");
|
||||||
|
String name = input.next();
|
||||||
|
System.out.println("Choose tor player:");
|
||||||
|
System.out.println("1. ⚔\uFE0F Knight (High Damage)");
|
||||||
|
System.out.println("2. \uD83E\uDDD9\u200D♂\uFE0F Wizard (High HP)");
|
||||||
|
System.out.println("3. \uD83D\uDDE1\uFE0F️ Assassin (High Mana)");
|
||||||
|
|
||||||
|
boolean validInput = false; // check for vaild input
|
||||||
|
while (!validInput){
|
||||||
|
System.out.print("chose:");
|
||||||
|
int choose =input.nextInt();
|
||||||
|
switch (choose){
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
player = new Knight(name);
|
||||||
|
validInput= true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
player = new Wizard(name);
|
||||||
|
validInput = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
player = new Assassin(name);
|
||||||
|
validInput = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
System.out.println("Invalid input");
|
||||||
|
validInput = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make a location
|
||||||
|
* @return location with random enemy
|
||||||
|
*/
|
||||||
|
public static Location fightMenu(){
|
||||||
|
boolean dragonOpen = true; // check drangon is open
|
||||||
|
for (Boolean b : keys){
|
||||||
|
if(b == false){
|
||||||
|
dragonOpen = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("Where do you want to go?");
|
||||||
|
System.out.println("1.Desert");
|
||||||
|
System.out.println("2.Sea");
|
||||||
|
System.out.println("3.Jungle");
|
||||||
|
|
||||||
|
for(boolean b : keys){ // for every key chek and write lock or tik
|
||||||
|
if(b){
|
||||||
|
System.out.print("✔\uFE0F");
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.print("🔒");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(dragonOpen) {
|
||||||
|
System.out.println("4.Dranon");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Dragon");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("0.EXIT (CLOSE GAME)");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int n = (int) ((Math.random()) *3); // a random number for random enemy
|
||||||
|
Entity enemy = null;
|
||||||
|
if(n == 0){
|
||||||
|
enemy = new Goblin();
|
||||||
|
}
|
||||||
|
if(n==1){
|
||||||
|
enemy = new Skeleton();
|
||||||
|
}
|
||||||
|
if(n==2){
|
||||||
|
enemy = new Vampire();
|
||||||
|
}
|
||||||
|
|
||||||
|
Location location = null;
|
||||||
|
|
||||||
|
|
||||||
|
boolean validInput = false;
|
||||||
|
while (!validInput){
|
||||||
|
System.out.print("chose:");
|
||||||
|
int choose =input.nextInt();
|
||||||
|
switch (choose){
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
running = false;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
location = new Location("Desert" , enemy);
|
||||||
|
validInput = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
location = new Location("Sea" , enemy);
|
||||||
|
validInput=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
location = new Location("Jungle" , enemy);
|
||||||
|
validInput =true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
if(dragonOpen){
|
||||||
|
enemy = new Dragon();
|
||||||
|
location = new Location("The end of line" , enemy);
|
||||||
|
validInput = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("It's locked!!!!!!");
|
||||||
|
validInput = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
System.out.println("Invalid input");
|
||||||
|
validInput = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
System.out.println("===============================");
|
||||||
|
return location;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* main loop of game
|
||||||
|
*/
|
||||||
|
public static void gameplay(){
|
||||||
|
boolean playerTurn = true; // flag for check for turn
|
||||||
|
|
||||||
|
while (player.isalive() && enemy.isalive()){
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("=========================================");
|
||||||
|
|
||||||
|
if(playerTurn){
|
||||||
|
System.out.println(player.toString());
|
||||||
|
System.out.println(enemy.toString() + "| HP:" + enemy.getHp());
|
||||||
|
|
||||||
|
System.out.println("\n"+GREEN + "It's your Turn" +RESET);
|
||||||
|
while (true){
|
||||||
|
|
||||||
|
if(playerAttakMenu()){ // maybe not enough mp and should choose again
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
playerTurn = !playerTurn;
|
||||||
|
|
||||||
|
|
||||||
|
// for skeleton relive
|
||||||
|
if(enemy instanceof Skeleton && !enemy.isalive() && !((Skeleton) enemy).getResurrect()){
|
||||||
|
System.out.println("\n"+ RED);
|
||||||
|
enemy.specialAbility(player);
|
||||||
|
System.out.println(RESET);
|
||||||
|
playerTurn = !playerTurn;
|
||||||
|
}
|
||||||
|
// for win senario
|
||||||
|
if(!enemy.isalive()){
|
||||||
|
System.out.println("you WIN");
|
||||||
|
int n = (int) (Math.random()*2); // 50% present enemy have key
|
||||||
|
if(enemy instanceof Dragon){
|
||||||
|
System.out.println(YELLOW + "Congratulation \n You are the kingdom of Gogorio" +
|
||||||
|
" 1000 Hp | 1000 Mp" + RESET);
|
||||||
|
((Player) player).setKing(); // king senario;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if(n== 0){
|
||||||
|
if(enemy instanceof Goblin){
|
||||||
|
if(keys.get(0) == true){
|
||||||
|
System.out.println("You have got this key befor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
keys.set(0, true);
|
||||||
|
}
|
||||||
|
else if (enemy instanceof Skeleton){
|
||||||
|
if(keys.get(1) == true){
|
||||||
|
System.out.println("You have got this key befor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
keys.set(1 , true);
|
||||||
|
}
|
||||||
|
else if (enemy instanceof Vampire) {
|
||||||
|
if(keys.get(2) == true){
|
||||||
|
System.out.println("You have got this key befor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
keys.set(2 , true);
|
||||||
|
}
|
||||||
|
System.out.println( YELLOW +"You chatck the" + enemy.toString() +"keys"+ RESET);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("There is no keys here");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!enemy.getpossible()){ // enemy is possible act?
|
||||||
|
System.out.println(enemy.toString() + " Can't do any act");
|
||||||
|
enemy.truepossible();
|
||||||
|
playerTurn = !playerTurn;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enemy.getpossible() && !playerTurn){
|
||||||
|
|
||||||
|
System.out.println("\n" + RED +"It's enemy Turn" + RESET);
|
||||||
|
enemyAttakMenu(); // randoum act from enemy;
|
||||||
|
playerTurn = !playerTurn;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!player.isalive()){ // result
|
||||||
|
System.out.println("you lose");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* selet a random act for each enemy
|
||||||
|
*/
|
||||||
|
public static void enemyAttakMenu(){
|
||||||
|
if(enemy instanceof Goblin || enemy instanceof Vampire){
|
||||||
|
int n = (int) (Math.random()*3);
|
||||||
|
if(n ==0 && enemy.getMp() >=10){
|
||||||
|
enemy.specialAbility(player);
|
||||||
|
}
|
||||||
|
else if(n == 1){
|
||||||
|
|
||||||
|
enemy.lightattack(player);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enemy.heavyattack(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(enemy instanceof Skeleton){ // skeleton use special ability when he dead
|
||||||
|
if(enemy.getHp() <= 0){
|
||||||
|
enemy.heavyattack(player);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enemy.lightattack(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( enemy instanceof Dragon){
|
||||||
|
int n = (int)(Math.random()*3);
|
||||||
|
if(n==0){
|
||||||
|
enemy.specialAbility(player);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enemy.lightattack(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* choose a act for player
|
||||||
|
* @return was the act successful or no
|
||||||
|
*/
|
||||||
|
public static boolean playerAttakMenu() {
|
||||||
|
|
||||||
|
System.out.print("1.Light attak| ");
|
||||||
|
System.out.print("2.Heavy attak("+player.getWeapon().getManaCost()+ " mana)| ");
|
||||||
|
System.out.print("3.Defend(12 mana)| ");
|
||||||
|
System.out.print("4.Heal(14 mana)| ");
|
||||||
|
System.out.println("5.Special action (30 mana)");
|
||||||
|
|
||||||
|
int n ;
|
||||||
|
|
||||||
|
while (true){
|
||||||
|
System.out.print("choose:");
|
||||||
|
n = input.nextInt();
|
||||||
|
if(n > 0 && n < 6){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Invalid input");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (n){
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
player.lightattack(enemy);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
if(player.getMp() >= player.getWeapon().getManaCost()){
|
||||||
|
player.heavyattack(enemy);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough Mp");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
if(player.getMp() >= 12){
|
||||||
|
player.defend();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough Mp");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
if(player.getMp() >= 14){
|
||||||
|
System.out.println("1.Flask | 2. Teriak");
|
||||||
|
int k ;
|
||||||
|
while (true){
|
||||||
|
k = input.nextInt();
|
||||||
|
System.out.print("choose:");
|
||||||
|
if(k == 1){
|
||||||
|
Flask flask = new Flask();
|
||||||
|
flask.use(player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(k==2){
|
||||||
|
Teriak teriak = new Teriak();
|
||||||
|
teriak.use(player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.print("Invalid input");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough Mp");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
if(player.getMp() >= 30){
|
||||||
|
player.specialAbility(enemy);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Not enough Mp");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1,21 +1,32 @@
|
|||||||
package org.project.entity;
|
package org.project.entity;
|
||||||
|
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
public interface Entity {
|
public interface Entity {
|
||||||
void attack(Entity target);
|
|
||||||
|
|
||||||
|
void lightattack(Entity target);
|
||||||
|
void heavyattack(Entity target);
|
||||||
void defend();
|
void defend();
|
||||||
|
void healHp(int health);
|
||||||
void heal(int health);
|
void healMp(int mp);
|
||||||
|
|
||||||
void fillMana(int mana);
|
|
||||||
|
|
||||||
void takeDamage(int damage);
|
void takeDamage(int damage);
|
||||||
|
|
||||||
int getMaxHP();
|
int getMaxHP();
|
||||||
|
int getHp();
|
||||||
int getMaxMP();
|
int getMaxMP();
|
||||||
|
int getMp();
|
||||||
|
Armor getArmor();
|
||||||
|
Weapon getWeapon();
|
||||||
|
void falsepossible();
|
||||||
|
void truepossible();
|
||||||
|
boolean getpossible();
|
||||||
|
boolean isalive();
|
||||||
|
void repair();
|
||||||
|
void specialAbility(Entity target);
|
||||||
|
String toString();
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.armors.EnemyArmor;
|
||||||
|
import org.project.item.weapons.DragonWepon;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
public class Dragon extends Enemy{
|
||||||
|
|
||||||
|
|
||||||
|
public Dragon(){
|
||||||
|
super(200 , 50 , new DragonWepon() , new EnemyArmor());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void specialAbility(Entity target){
|
||||||
|
target.getArmor().brokeArmor();
|
||||||
|
System.out.println(toString()+"\uD83D\uDD25 FIRE!! special ability" );
|
||||||
|
target.takeDamage(2 * weapon.getDamage());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "\uD83D\uDC09 Dragon";
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,34 +1,111 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public abstract class Enemy {
|
|
||||||
Weapon weapon;
|
|
||||||
private int hp;
|
|
||||||
private int mp;
|
|
||||||
|
|
||||||
public Enemy(int hp, int mp, Weapon weapon) {
|
|
||||||
|
|
||||||
|
public abstract class Enemy implements Entity {
|
||||||
|
protected Weapon weapon;
|
||||||
|
protected Armor armor;
|
||||||
|
protected int hp;
|
||||||
|
protected int mp;
|
||||||
|
protected int maxHp;
|
||||||
|
protected int maxMp;
|
||||||
|
protected boolean ispossible;
|
||||||
|
|
||||||
|
|
||||||
|
public Enemy(int hp, int mp, Weapon weapon , Armor armor) {
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
|
this.maxHp=hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.maxMp=mp;
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
|
this.armor = armor;
|
||||||
|
this.ispossible = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void specialAbility(Entity target);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lightattack(Entity target){
|
||||||
|
System.out.println(toString() + " do a light attaked with " + weapon.getDamage() + " damages");
|
||||||
|
target.takeDamage(weapon.getDamage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heavyattack(Entity target){
|
||||||
|
System.out.println(toString() + " do a heavy attaked with " + weapon.getDamage() * 2 + " damages");
|
||||||
|
target.takeDamage((2 * weapon.getDamage()) - 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
|
|
||||||
|
if(!armor.checkBreak()){
|
||||||
|
hp -= damage - armor.getDefense();
|
||||||
|
armor.use(this);
|
||||||
|
System.out.println(toString() + " take " + (damage -armor.getDefense())
|
||||||
|
+ " Damage. " + armor.getDefense() +" Defens by armor" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
hp -=damage;
|
hp -=damage;
|
||||||
|
System.out.println(toString() + "take " + (damage));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
public int getMaxHP(){
|
||||||
|
return maxHp;
|
||||||
|
}
|
||||||
|
public int getMaxMP(){
|
||||||
|
return maxMp;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
public Weapon getWeapon() {
|
public Weapon getWeapon() {
|
||||||
return weapon;
|
return weapon;
|
||||||
}
|
}
|
||||||
|
public Armor getArmor(){return armor;}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void falsepossible(){
|
||||||
|
ispossible = false;
|
||||||
}
|
}
|
||||||
|
public void truepossible(){
|
||||||
|
ispossible=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getpossible(){
|
||||||
|
return ispossible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isalive(){
|
||||||
|
return hp>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract String toString();
|
||||||
|
public String getName(){return "";}
|
||||||
|
public void repair(){}
|
||||||
|
public void defend() {}
|
||||||
|
public void healHp(int health){}
|
||||||
|
public void healMp(int mp){}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.armors.EnemyArmor;
|
||||||
|
import org.project.item.weapons.knife;
|
||||||
|
|
||||||
|
public class Goblin extends Enemy {
|
||||||
|
|
||||||
|
public Goblin(){
|
||||||
|
super(35 , 30 , new knife() , new EnemyArmor());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println("\uD83D\uDC79 use critical hit");
|
||||||
|
target.takeDamage(2 * weapon.getDamage() - 5);
|
||||||
|
this.mp -=10;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "\uD83D\uDC79 Goblin";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,6 +1,40 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public class Skeleton {
|
import org.project.entity.Entity;
|
||||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
import org.project.item.armors.EnemyArmor;
|
||||||
|
import org.project.item.weapons.wood;
|
||||||
|
|
||||||
|
public class Skeleton extends Enemy {
|
||||||
|
|
||||||
|
private boolean resurrect;
|
||||||
|
|
||||||
|
public Skeleton(){
|
||||||
|
super(50 , 30 , new wood() , new EnemyArmor());
|
||||||
|
this.resurrect =false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.toString() +"use Special ability");
|
||||||
|
if(this.isalive() == false && this.resurrect == false){
|
||||||
|
this.hp=25;
|
||||||
|
this.mp=15;
|
||||||
|
System.out.println("☠\uFE0F resurrect himself");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resurrect = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getResurrect(){
|
||||||
|
return resurrect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "☠\uFE0F Skeleton ";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
|||||||
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.armors.EnemyArmor;
|
||||||
|
import org.project.item.weapons.wood;
|
||||||
|
|
||||||
|
public class Vampire extends Enemy{
|
||||||
|
|
||||||
|
public Vampire(){
|
||||||
|
super(60 , 30, new wood() , new EnemyArmor());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.toString() +"use Special ability");
|
||||||
|
System.out.println();
|
||||||
|
this.mp -=10;
|
||||||
|
target.takeDamage(this.weapon.getDamage());
|
||||||
|
this.hp += this.weapon.getDamage() /2;
|
||||||
|
System.out.println(" \uD83E\uDD87 rob your Hp :)" + "(" + this.weapon.getDamage() /2 + " Hp)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "\uD83E\uDD87 Vampire ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,24 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.armors.woodenArmor;
|
||||||
|
import org.project.item.weapons.knife;
|
||||||
|
|
||||||
|
public class Assassin extends Player{
|
||||||
|
|
||||||
|
public Assassin(String name){
|
||||||
|
super("🗡️ "+name +"(Assassin)" , 60 , 80 ,new knife(), new woodenArmor() , 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.getName() + "use special ability, (you are invisible now) " +
|
||||||
|
"+ Damge:" +weapon.getDamage() + fistDamage );
|
||||||
|
mp -= 30;
|
||||||
|
target.falsepossible();
|
||||||
|
target.takeDamage(weapon.getDamage() + fistDamage);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,6 +1,24 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
|
||||||
public class Knight {
|
import org.project.entity.Entity;
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
import org.project.item.armors.KnightArmor;
|
||||||
|
import org.project.item.weapons.Sword;
|
||||||
|
|
||||||
|
public class Knight extends Player {
|
||||||
|
|
||||||
|
public Knight(String name){
|
||||||
|
super("⚔\uFE0F " + name + "(Knight)" , 50 , 50 , new Sword() , new KnightArmor() ,10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.getName() + "use special ability");
|
||||||
|
mp -=30;
|
||||||
|
target.takeDamage(weapon.getDamage() + fistDamage);
|
||||||
|
target.falsepossible();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -4,43 +4,89 @@ 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 {
|
|
||||||
protected String name;
|
|
||||||
Weapon weapon;
|
|
||||||
Armor armor;
|
|
||||||
private int hp;
|
|
||||||
private int maxHP;
|
|
||||||
private int mp;
|
|
||||||
private int maxMP;
|
|
||||||
|
|
||||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
public abstract class Player implements Entity {
|
||||||
|
protected String name;
|
||||||
|
protected Weapon weapon;
|
||||||
|
protected Armor armor;
|
||||||
|
protected int hp;
|
||||||
|
protected int maxHP;
|
||||||
|
protected int mp;
|
||||||
|
protected int maxMP;
|
||||||
|
protected int fistDamage;
|
||||||
|
protected boolean isDefending;
|
||||||
|
protected boolean isalive;
|
||||||
|
protected int Xp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Player(String name, int hp, int mp, Weapon weapon, Armor armor , int fistDamage) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
|
this.maxHP=hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.maxMP = mp;
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
this.armor = armor;
|
this.armor = armor;
|
||||||
|
this.isDefending=false;
|
||||||
|
this.fistDamage = fistDamage;
|
||||||
|
this.isalive=true;
|
||||||
|
this.Xp=0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void specialAbility(Entity target);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lightattack(Entity target){
|
||||||
|
System.out.println(name + " use light attak " + "| Damge: " + fistDamage);
|
||||||
|
target.takeDamage(fistDamage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attack(Entity target) {
|
public void heavyattack(Entity target){
|
||||||
|
System.out.println(name + " use Heavy attak | Damage " + weapon.getDamage());
|
||||||
target.takeDamage(weapon.getDamage());
|
target.takeDamage(weapon.getDamage());
|
||||||
|
mp -= weapon.getManaCost();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void defend() {
|
public void defend() {
|
||||||
// TODO
|
System.out.println("Defend mode is active now");
|
||||||
|
mp -=12;
|
||||||
|
isDefending =true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
|
|
||||||
|
if(isDefending){
|
||||||
|
System.out.println("you have Defend this attak (half damage)" );
|
||||||
|
damage /= 2;
|
||||||
|
isDefending = false;
|
||||||
|
}
|
||||||
|
if(!armor.checkBreak()){
|
||||||
|
System.out.println("you take " + (damage - armor.getDefense()) +
|
||||||
|
" Damage. armor defend: " + armor.getDefense());
|
||||||
hp -= damage - armor.getDefense();
|
hp -= damage - armor.getDefense();
|
||||||
|
armor.use(this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("you take " + (damage - armor.getDefense()) + " Damage");
|
||||||
|
hp -=damage;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void heal(int health) {
|
public void healHp(int health) {
|
||||||
|
System.out.println("you have got " + health + " Hp");
|
||||||
|
mp -=14;
|
||||||
hp += health;
|
hp += health;
|
||||||
if (hp > maxHP) {
|
if (hp > maxHP) {
|
||||||
hp = maxHP;
|
hp = maxHP;
|
||||||
@@ -48,18 +94,47 @@ public abstract class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillMana(int mana) {
|
public void healMp(int mp) {
|
||||||
mp += mana;
|
System.out.println("you have got " + mp + " Mp");
|
||||||
if (mp > maxMP) {
|
mp -=14;
|
||||||
mp = maxMP;
|
this.mp+= mp;
|
||||||
|
if (this.mp > maxMP) {
|
||||||
|
this.mp = maxMP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return name+ " |Hp: " + hp +"/" + maxHP + " | Mp: " +mp +"/" + maxMP + "| Xp:" +this.Xp ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void repair(){
|
||||||
|
this.Xp +=1;
|
||||||
|
this.maxHP +=5;
|
||||||
|
this.maxMP +=5;
|
||||||
|
this.hp = maxHP;
|
||||||
|
this.mp += (maxMP / 4);
|
||||||
|
armor.repair();
|
||||||
|
System.out.println( "Repair: we full your Hp , repair your armor and give you some Mp");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKing(){
|
||||||
|
this.maxHP =1000;
|
||||||
|
this.hp=maxHP;
|
||||||
|
this.maxMP = 1000;
|
||||||
|
this.mp = maxMP;
|
||||||
|
armor.repair();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
@@ -69,21 +144,35 @@ public abstract class Player {
|
|||||||
return maxHP;
|
return maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getpossible(){ return true;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxMP() {
|
public int getMaxMP() {
|
||||||
return maxMP;
|
return maxMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Weapon getWeapon() {
|
public Weapon getWeapon() {
|
||||||
return weapon;
|
return weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Armor getArmor() {
|
public Armor getArmor() {
|
||||||
return armor;
|
return armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isalive(){
|
||||||
|
return hp > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we should override this function but they are for enemies
|
||||||
|
public void falsepossible(){}
|
||||||
|
public void truepossible(){}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,24 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.armors.leatherArmor;
|
||||||
|
import org.project.item.weapons.wood;
|
||||||
|
|
||||||
|
public class Wizard extends Player{
|
||||||
|
public Wizard(String name){
|
||||||
|
super("\uD83E\uDDD9\u200D♂\uFE0F " +name+"(Wizard)" , 90 , 60 , new wood() , new leatherArmor() , 7 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.getName() + "use special ability");
|
||||||
|
mp -= 30;
|
||||||
|
target.takeDamage(weapon.getDamage() + fistDamage);
|
||||||
|
this.hp += 30;
|
||||||
|
System.out.println(toString()+ "have got 30 Hp");
|
||||||
|
if(hp > maxHP){
|
||||||
|
hp = maxHP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -4,8 +4,4 @@ import org.project.entity.Entity;
|
|||||||
|
|
||||||
public interface Item {
|
public interface Item {
|
||||||
void use(Entity target);
|
void use(Entity target);
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -1,7 +1,10 @@
|
|||||||
package org.project.item.armors;
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Armor {
|
public abstract class Armor implements Item {
|
||||||
private int defense;
|
private int defense;
|
||||||
private int maxDefense;
|
private int maxDefense;
|
||||||
private int durability;
|
private int durability;
|
||||||
@@ -12,16 +15,33 @@ public abstract class Armor {
|
|||||||
public Armor(int defense, int durability) {
|
public Armor(int defense, int durability) {
|
||||||
this.defense = defense;
|
this.defense = defense;
|
||||||
this.durability = durability;
|
this.durability = durability;
|
||||||
|
this.maxDurability = durability;
|
||||||
|
this.maxDefense = defense;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkBreak() {
|
public void use(Entity target){
|
||||||
|
durability -= defense;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean checkBreak() {
|
||||||
|
if(isBroke){ // if armor broke by dragon return true
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (durability <= 0) {
|
if (durability <= 0) {
|
||||||
isBroke = true;
|
isBroke = true;
|
||||||
defense = 0;
|
defense = 0;
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
isBroke= false;
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
|
||||||
public void repair() {
|
public void repair() {
|
||||||
isBroke = false;
|
isBroke = false;
|
||||||
defense = maxDefense;
|
defense = maxDefense;
|
||||||
@@ -36,7 +56,19 @@ public abstract class Armor {
|
|||||||
return durability;
|
return durability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxDefense(int maxDefense) {
|
||||||
|
this.maxDefense = maxDefense;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxDurability(int maxDurability) {
|
||||||
|
this.maxDurability = maxDurability;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isBroke() {
|
public boolean isBroke() {
|
||||||
return isBroke;
|
return isBroke;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void brokeArmor(){
|
||||||
|
isBroke =true;
|
||||||
|
} // for dragon attak
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class EnemyArmor extends Armor{
|
||||||
|
public EnemyArmor(){
|
||||||
|
super(2 , 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,6 +1,9 @@
|
|||||||
package org.project.item.armors;
|
package org.project.item.armors;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class KnightArmor {
|
public class KnightArmor extends Armor{
|
||||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
|
||||||
|
public KnightArmor(){
|
||||||
|
super(5 , 20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class leatherArmor extends Armor {
|
||||||
|
public leatherArmor(){
|
||||||
|
super(4 , 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class woodenArmor extends Armor{
|
||||||
|
public woodenArmor(){
|
||||||
|
super(4 , 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,8 +1,11 @@
|
|||||||
package org.project.item.consumables;
|
package org.project.item.consumables;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.entity.Entity;
|
||||||
public abstract class Consumable {
|
import org.project.item.Item;
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
public abstract class Consumable implements Item {
|
||||||
|
|
||||||
|
public abstract void use(Entity target);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -2,15 +2,11 @@ package org.project.item.consumables;
|
|||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public class Flask extends Consumable {
|
||||||
public class Flask {
|
|
||||||
/*
|
|
||||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: UPDATE USE METHOD
|
|
||||||
@Override
|
@Override
|
||||||
public void use(Entity target) {
|
public void use(Entity target) {
|
||||||
target.heal(target.getMaxHP() / 10);
|
target.healHp(target.getMaxHP() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
package org.project.item.consumables;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class Teriak extends Consumable{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void use(Entity target) {
|
||||||
|
target.healMp(target.getMaxMP() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
|
public class DragonWepon extends Weapon{
|
||||||
|
|
||||||
|
public DragonWepon(){
|
||||||
|
super(25 , 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void use(Entity target){
|
||||||
|
target.takeDamage(this.getDamage()+ target.getArmor().getDefense());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -4,23 +4,8 @@ import org.project.entity.Entity;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public class Sword extends Weapon {
|
||||||
public class Sword {
|
|
||||||
/*
|
|
||||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int abilityCharge;
|
|
||||||
|
|
||||||
public Sword() {
|
public Sword() {
|
||||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
super( 23 , 8);
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
|
||||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
|
||||||
abilityCharge += 2;
|
|
||||||
for (Entity target : targets) {
|
|
||||||
target.takeDamage(getDamage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -1,15 +1,12 @@
|
|||||||
package org.project.item.weapons;
|
package org.project.item.weapons;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public class Weapon implements Item {
|
||||||
public abstract class Weapon {
|
|
||||||
private int damage;
|
private int damage;
|
||||||
private int manaCost;
|
private int manaCost;
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Weapon(int damage, int manaCost) {
|
public Weapon(int damage, int manaCost) {
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
@@ -29,7 +26,4 @@ public abstract class Weapon {
|
|||||||
return manaCost;
|
return manaCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
public class knife extends Weapon{
|
||||||
|
public knife(){
|
||||||
|
super(18 , 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
package org.project.item.weapons;
|
||||||
|
|
||||||
|
public class wood extends Weapon{
|
||||||
|
|
||||||
|
public wood(){
|
||||||
|
super(16, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,28 +1,28 @@
|
|||||||
package org.project.location;
|
package org.project.location;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
import org.project.entity.enemies.Enemy;
|
import org.project.entity.enemies.Enemy;
|
||||||
|
import org.project.entity.enemies.Goblin;
|
||||||
|
import org.project.entity.enemies.Skeleton;
|
||||||
|
import org.project.entity.enemies.Vampire;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Location {
|
public class Location {
|
||||||
private String name;
|
private String name;
|
||||||
|
private Entity enemie;
|
||||||
|
|
||||||
private ArrayList<Enemy> enemies;
|
public Location(String name, Entity enemie) {
|
||||||
|
this.name = name;
|
||||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
this.enemie = enemie;
|
||||||
this.locations = locations;
|
|
||||||
this.enemies = enemies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Location> getLocations() {
|
public Entity getEnemie() {
|
||||||
return locations;
|
return enemie;
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
# Fourth Assignment - Java Knight ⚔️
|
# Fourth Assignment - Java Knight ⚔️
|
||||||
A turn-based RPG with Roguelike elements which can be run in the terminal.
|
A turn-based RPG with Roguelike elements which can be run in the terminal.
|
||||||
|
|
||||||
### **Prologue: The Legend of Javanest**
|
## **Prologue: The Legend of Javanest**
|
||||||
*For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into absolute darkness. With a wicked curse, the Dragon transformed the innocent people into horrific monsters: Goblins, Skeletons, and Vampires. Retreating to its impenetrable Castle, the Dragon divided the three keys to its lair and hid them among these cursed creatures. Now, it is your duty to step up and save the land. You must battle these monsters, recover the unique key from each monster type, and finally slay the Dragon to break the curse and restore peace to Javanest!*
|
*For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into absolute darkness. With a wicked curse, the Dragon transformed the innocent people into horrific monsters: Goblins, Skeletons, and Vampires. Retreating to its impenetrable Castle, the Dragon divided the three keys to its lair and hid them among these cursed creatures. Now, it is your duty to step up and save the land. You must battle these monsters, recover the unique key from each monster type, and finally slay the Dragon to break the curse and restore peace to Javanest!*
|
||||||
|
|
||||||
### **Introduction**
|
### **Introduction**
|
||||||
|
|||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
# HELLO and Welcom to Java-knight⚔️
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
|
||||||
|
Goguryeo has been conquered by the dragon mercenary of Emperor Tso. As the savior of Goguryeo, you must conquer it. To do this, you must first obtain 3 keys.Each enemy army has 1 key, but we do not know which member of that army has it. Fight them to obtain the keys. Then go fight the dragon and become the ruler of Goguryeo. Dont forget java knight is a turn-based game and enemy can attak you.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## HOW TO RUN GAME
|
||||||
|
|
||||||
|
first you should go to project file and open src\main\java folder then open terminal and use this promote to compile project
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
javac org/project/Main.java
|
||||||
|
```
|
||||||
|
|
||||||
|
then use this promte to run the game
|
||||||
|
|
||||||
|
```
|
||||||
|
java org.project.Main
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can play!
|
||||||
|
|
||||||
|
## About game
|
||||||
|
|
||||||
|
---
|
||||||
|
Hp: is your heart
|
||||||
|
|
||||||
|
Mp : is your mana
|
||||||
|
|
||||||
|
Xp : is your experiences
|
||||||
|
|
||||||
|
**After any fight if you win . we will full your Hp and give you some Mp and you got 1 Xp and we add 5 Mp&Hp to MaxHP&Hp**
|
||||||
|
|
||||||
|
At first you shout choose your player (Knight - Wizard - Assassin)
|
||||||
|
|
||||||
|
- **⚔️Knight**: Hp:50 Mp:50 Weapon:sword(23 Damage)
|
||||||
|
|
||||||
|
- **🗡️Assassin**: HP:60 Mp:80 Weapon: knife(18 damage)
|
||||||
|
|
||||||
|
- **🧙♂️WIZARS**: HP:90 Mp:60 Weapon: wood(16 damage)
|
||||||
|
|
||||||
|
After that you should choose your location. in each location exist one enemy such as:
|
||||||
|
|
||||||
|
- **Goblin** 👹: Hp:35 Weapon: knife(18 Damage) Special : critical attack
|
||||||
|
- **Skeleton** ☠️: Hp:50 Weapon: wood(16 Damage) Special: relive after dead
|
||||||
|
- **Vampire** 🦇: Hp: 60 Weapon : wood(16 Damage) Special : rob Hp
|
||||||
|
- **Dragon (Final Boss)** 🐉: Hp: 200 Weapon:fire(25 Damage) Special : Fire + break Armor
|
||||||
|
|
||||||
|
In each turn enemy can use 1.light attack 2.heavy attack 3 special abilities
|
||||||
|
|
||||||
|
Player in each turn can use :
|
||||||
|
1. **Light Attack:** Deals moderate damage and costs **NO Mana**. (Note: If the player runs out of Mana/Stamina, this is the ONLY action they can perform.)
|
||||||
|
2. **Heavy Attack:** Deals high damage, medium Mana cost.
|
||||||
|
3. **Defend:** Completely blocks or significantly reduces the damage of the enemy's *next* strike. Medium Mana cost.
|
||||||
|
4. **Heal:** Restores a portion of the player's HP. Medium-high Mana cost.
|
||||||
|
- 4.1 Flask : Give you Hp
|
||||||
|
- 4.2 Teriak : Give you Mp
|
||||||
|
5. **Special Ability:** A unique class-based ultimate move (Highest Mana cost):
|
||||||
|
- **Wizard** 🧙♂️: Casts a devastating spell that damages the enemy while simultaneously replenishing some HP.
|
||||||
|
- **Assassin** 🗡️: Turns invisible, dodging the next incoming attack completely and guaranteeing a *Critical Hit* on their next turn.
|
||||||
|
- **Knight** ⚔️: Performs a shield bash that stuns the enemy, forcing them to skip their next turn while dealing heavy damage.
|
||||||
|
|
||||||
|
---
|
||||||
|
## About oop
|
||||||
|
In this project we use oop. we have 2 interface
|
||||||
|
|
||||||
|
1. Entity
|
||||||
|
- **Player**(Knight - Wizard - Assassin)
|
||||||
|
- **Enemy**(Goblin - Skeleton - vampire - Dragon)
|
||||||
|
|
||||||
|
2. Item
|
||||||
|
- **Armors**(Enemy armor - Knight armor - leather armor - wooden armor)
|
||||||
|
- **Consumable**(Flask - Teriak)
|
||||||
|
- **Weapon** (Sword - Weapon - Wood - DragonWeapon)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
### **For control game you should input number . if you input invalid number you should input again**
|
||||||
|

|
||||||
Reference in New Issue
Block a user