complete classes + part of main
This commit is contained in:
@@ -1,40 +1,68 @@
|
|||||||
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 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 void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
ArrayList<String> names = new ArrayList<>();
|
|
||||||
names.add("Nou Camp");
|
|
||||||
names.add("Bernabeu");
|
|
||||||
names.add("Azadi");
|
|
||||||
|
|
||||||
System.out.println("----------Welcome to Java-Knight");
|
startMenu();
|
||||||
|
|
||||||
while (true){
|
while (true){
|
||||||
|
|
||||||
|
do{
|
||||||
|
System.out.println("===============================");
|
||||||
|
Location fightLoc = fightMenu();
|
||||||
|
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(!player.isalive()){
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}while (true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +71,399 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setKeys(){
|
||||||
|
boolean goblinkey=false;
|
||||||
|
boolean skeletonkey = false;
|
||||||
|
boolean vampirekey = false;
|
||||||
|
keys.add(goblinkey);
|
||||||
|
keys.add(skeletonkey);
|
||||||
|
keys.add(vampirekey);
|
||||||
|
}
|
||||||
|
|
||||||
private void
|
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Location fightMenu(){
|
||||||
|
boolean dragonOpen = true;
|
||||||
|
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){
|
||||||
|
if(b){
|
||||||
|
System.out.print("✔\uFE0F");
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.print("🔒");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(dragonOpen) {
|
||||||
|
System.out.println("4.Dranon");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Dragon");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int n = (int) ((Math.random()) *3);
|
||||||
|
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 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gameplay(){
|
||||||
|
boolean playerTurn = true;
|
||||||
|
|
||||||
|
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()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
playerTurn = !playerTurn;
|
||||||
|
|
||||||
|
|
||||||
|
if(enemy instanceof Skeleton && !enemy.isalive()){
|
||||||
|
System.out.println("\n"+ RED);
|
||||||
|
enemy.specialAbility(player);
|
||||||
|
System.out.println(RESET);
|
||||||
|
playerTurn = !playerTurn;
|
||||||
|
}
|
||||||
|
if(!enemy.isalive()){
|
||||||
|
System.out.println("you WIN");
|
||||||
|
int n = (int) (Math.random()*2);
|
||||||
|
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()){
|
||||||
|
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();
|
||||||
|
playerTurn = !playerTurn;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!player.isalive()){
|
||||||
|
System.out.println("you lose");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
|
if(enemy.getHp() <= 0){
|
||||||
|
enemy.heavyattack(player);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enemy.lightattack(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.project.entity;
|
package org.project.entity;
|
||||||
|
|
||||||
import org.project.item.armors.Armor;
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
public interface Entity {
|
public interface Entity {
|
||||||
|
|
||||||
@@ -9,15 +10,22 @@ public interface Entity {
|
|||||||
void defend();
|
void defend();
|
||||||
void healHp(int health);
|
void healHp(int health);
|
||||||
void healMp(int mp);
|
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();
|
Armor getArmor();
|
||||||
|
Weapon getWeapon();
|
||||||
void falsepossible();
|
void falsepossible();
|
||||||
void truepossible();
|
void truepossible();
|
||||||
|
boolean getpossible();
|
||||||
boolean isalive();
|
boolean isalive();
|
||||||
|
void repair();
|
||||||
void specialAbility(Entity target);
|
void specialAbility(Entity target);
|
||||||
|
String toString();
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,4 +17,9 @@ public class Dragon extends Enemy{
|
|||||||
heavyattack(target);
|
heavyattack(target);
|
||||||
//sout : fire!
|
//sout : fire!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
String str = "Dragon |" + "Hp:" + getHp();
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ public abstract class Enemy implements Entity {
|
|||||||
protected int maxHp;
|
protected int maxHp;
|
||||||
protected int maxMp;
|
protected int maxMp;
|
||||||
protected boolean ispossible;
|
protected boolean ispossible;
|
||||||
protected boolean haveKey;
|
|
||||||
protected boolean isalive;
|
|
||||||
|
|
||||||
public Enemy(int hp, int mp, Weapon weapon , Armor armor) {
|
public Enemy(int hp, int mp, Weapon weapon , Armor armor) {
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
@@ -26,32 +25,35 @@ public abstract class Enemy implements Entity {
|
|||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
this.armor = armor;
|
this.armor = armor;
|
||||||
this.ispossible = true;
|
this.ispossible = true;
|
||||||
this.isalive=true;
|
|
||||||
int n = (int) (Math.random())*2;
|
|
||||||
if(n==0){
|
|
||||||
haveKey=true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
haveKey=false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void lightattack(Entity target){
|
public void lightattack(Entity target){
|
||||||
|
System.out.println(toString() + " do a light attaked with " + weapon.getDamage() + " damages");
|
||||||
target.takeDamage(weapon.getDamage());
|
target.takeDamage(weapon.getDamage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void heavyattack(Entity target){
|
||||||
|
System.out.println(toString() + " do a heavy attaked with " + weapon.getDamage() + " damages");
|
||||||
|
target.takeDamage(2 * weapon.getDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
|
|
||||||
if(!armor.checkBreak()){
|
if(!armor.checkBreak()){
|
||||||
hp -= damage - armor.getDefense();
|
hp -= damage - armor.getDefense();
|
||||||
armor.use(this);
|
armor.use(this);
|
||||||
|
System.out.println(toString() + " take " + (damage -armor.getDefense())
|
||||||
|
+ " Damage. " + armor.getDefense() +" Defens by armor" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hp -=damage;
|
hp -=damage;
|
||||||
|
System.out.println(toString() + "take " + (damage));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ public abstract class Enemy implements Entity {
|
|||||||
}
|
}
|
||||||
public void truepossible(){
|
public void truepossible(){
|
||||||
ispossible=true;}
|
ispossible=true;}
|
||||||
|
|
||||||
public boolean getpossible(){
|
public boolean getpossible(){
|
||||||
return ispossible;
|
return ispossible;
|
||||||
}
|
}
|
||||||
@@ -90,18 +93,19 @@ public abstract class Enemy implements Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isalive(){
|
public boolean isalive(){
|
||||||
return isalive;
|
return hp>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public abstract String toString();
|
||||||
|
public String getName(){return "";}
|
||||||
|
|
||||||
public void heavyattack(Entity target){
|
@Override
|
||||||
target.takeDamage(weapon.getDamage());
|
|
||||||
}
|
public void repair(){}
|
||||||
public void defend() {}
|
public void defend() {}
|
||||||
public void healHp(int health){}
|
public void healHp(int health){}
|
||||||
public void healMp(int mp){}
|
public void healMp(int mp){}
|
||||||
public void fillMana(int mana){}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,19 @@ import org.project.item.weapons.knife;
|
|||||||
public class Goblin extends Enemy {
|
public class Goblin extends Enemy {
|
||||||
|
|
||||||
public Goblin(){
|
public Goblin(){
|
||||||
super(35 , 25 , new knife() , new EnemyArmor());
|
super(35 , 30 , new knife() , new EnemyArmor());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void specialAbility(Entity target){
|
public void specialAbility(Entity target){
|
||||||
heavyattack(target);
|
System.out.println("\uD83D\uDC79 use critical hit");
|
||||||
//sout : crirtal
|
target.takeDamage(2 * weapon.getDamage());
|
||||||
|
this.mp -=10;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "\uD83D\uDC79 Goblin";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,22 @@ public class Skeleton extends Enemy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void specialAbility(Entity target){
|
public void specialAbility(Entity target){
|
||||||
if(this.isalive == false && this.resurrect == false){
|
System.out.println(this.toString() +"use Special ability");
|
||||||
this.isalive = true;
|
if(this.isalive() == false && this.resurrect == false){
|
||||||
this.hp=25;
|
this.hp=25;
|
||||||
this.mp=15;
|
this.mp=15;
|
||||||
|
System.out.println("☠\uFE0F resurrect himself");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.resurrect = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "☠\uFE0F Skeleton ";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,22 @@ import org.project.item.weapons.wood;
|
|||||||
public class Vampire extends Enemy{
|
public class Vampire extends Enemy{
|
||||||
|
|
||||||
public Vampire(){
|
public Vampire(){
|
||||||
super(60 , 25, new wood() , new EnemyArmor());
|
super(60 , 30, new wood() , new EnemyArmor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void specialAbility(Entity target){
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.toString() +"use Special ability");
|
||||||
|
System.out.println();
|
||||||
|
this.mp -=10;
|
||||||
target.takeDamage(this.weapon.getDamage());
|
target.takeDamage(this.weapon.getDamage());
|
||||||
this.hp += this.weapon.getDamage() /2;
|
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 ";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import org.project.item.weapons.knife;
|
|||||||
public class Assassin extends Player{
|
public class Assassin extends Player{
|
||||||
|
|
||||||
public Assassin(String name){
|
public Assassin(String name){
|
||||||
super(name , 60 , 80 ,new knife(), new woodenArmor() , 8);
|
super("🗡️ "+name +"(Assassin)" , 60 , 80 ,new knife(), new woodenArmor() , 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void specialAbility(Entity target){
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.getName() + "use special ability, (you are invisible now");
|
||||||
|
mp -= 30;
|
||||||
target.falsepossible();
|
target.falsepossible();
|
||||||
// sout : na marei ;
|
target.takeDamage(weapon.getDamage() + fistDamage);
|
||||||
heavyattack(target);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,14 @@ import org.project.item.weapons.Sword;
|
|||||||
public class Knight extends Player {
|
public class Knight extends Player {
|
||||||
|
|
||||||
public Knight(String name){
|
public Knight(String name){
|
||||||
super(name , 50 , 50 , new Sword() , new KnightArmor() ,10);
|
super("⚔\uFE0F " + name + "(Knight)" , 50 , 50 , new Sword() , new KnightArmor() ,10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void specialAbility(Entity target){
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.getName() + "use special ability");
|
||||||
|
mp -=30;
|
||||||
target.takeDamage(weapon.getDamage() + fistDamage);
|
target.takeDamage(weapon.getDamage() + fistDamage);
|
||||||
target.falsepossible();
|
target.falsepossible();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public abstract class Player implements Entity {
|
|||||||
protected int fistDamage;
|
protected int fistDamage;
|
||||||
protected boolean isDefending;
|
protected boolean isDefending;
|
||||||
protected boolean isalive;
|
protected boolean isalive;
|
||||||
|
protected int Xp;
|
||||||
|
|
||||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor , int fistDamage) {
|
public Player(String name, int hp, int mp, Weapon weapon, Armor armor , int fistDamage) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -28,21 +29,30 @@ public abstract class Player implements Entity {
|
|||||||
this.isDefending=false;
|
this.isDefending=false;
|
||||||
this.fistDamage = fistDamage;
|
this.fistDamage = fistDamage;
|
||||||
this.isalive=true;
|
this.isalive=true;
|
||||||
|
this.Xp=0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lightattack(Entity target){
|
public void lightattack(Entity target){
|
||||||
|
System.out.println(name + " use light attak " + "| Damge: " + fistDamage);
|
||||||
target.takeDamage(fistDamage);
|
target.takeDamage(fistDamage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void heavyattack(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() {
|
||||||
|
System.out.println("Defend mode is active now");
|
||||||
|
mp -=12;
|
||||||
isDefending =true;
|
isDefending =true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,14 +61,18 @@ public abstract class Player implements Entity {
|
|||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
|
|
||||||
if(isDefending){
|
if(isDefending){
|
||||||
|
System.out.println("you have Defend this attak (half damage)" );
|
||||||
damage /= 2;
|
damage /= 2;
|
||||||
isDefending = false;
|
isDefending = false;
|
||||||
}
|
}
|
||||||
if(!armor.checkBreak()){
|
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);
|
armor.use(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
System.out.println("you take " + (damage - armor.getDefense()));
|
||||||
hp -=damage;
|
hp -=damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +80,8 @@ public abstract class Player implements Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void healHp(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;
|
||||||
@@ -74,6 +90,8 @@ public abstract class Player implements Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void healMp(int mp) {
|
public void healMp(int mp) {
|
||||||
|
System.out.println("you have got " + mp + " Mp");
|
||||||
|
mp -=14;
|
||||||
this.mp+= mp;
|
this.mp+= mp;
|
||||||
if (this.mp > maxMP) {
|
if (this.mp > maxMP) {
|
||||||
this.mp = maxMP;
|
this.mp = maxMP;
|
||||||
@@ -81,21 +99,27 @@ public abstract class Player implements Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
public String toString(){
|
||||||
public void fillMana(int mana) {
|
return name+ " |Hp: " + hp +"/" + maxHP + " | Mp: " +mp +"/" + maxMP + "| Xp:" +this.Xp ;
|
||||||
mp += mana;
|
|
||||||
if (mp > maxMP) {
|
|
||||||
mp = maxMP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void specialAbility(Entity target);
|
public abstract void specialAbility(Entity target);
|
||||||
|
|
||||||
|
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 String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
@@ -108,6 +132,7 @@ public abstract class Player implements Entity {
|
|||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
public boolean getpossible(){ return true;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxMP() {
|
public int getMaxMP() {
|
||||||
@@ -125,7 +150,7 @@ public abstract class Player implements Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isalive(){
|
public boolean isalive(){
|
||||||
return isalive;
|
return hp > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import org.project.item.weapons.wood;
|
|||||||
|
|
||||||
public class Wizard extends Player{
|
public class Wizard extends Player{
|
||||||
public Wizard(String name){
|
public Wizard(String name){
|
||||||
super(name , 90 , 60 , new wood() , new leatherArmor() , 7 );
|
super("\uD83E\uDDD9\u200D♂\uFE0F " +name+"(Wizard)" , 90 , 60 , new wood() , new leatherArmor() , 7 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void specialAbility(Entity target){
|
public void specialAbility(Entity target){
|
||||||
|
System.out.println(this.getName() + "use special ability");
|
||||||
|
mp -= 30;
|
||||||
target.takeDamage(weapon.getDamage() + fistDamage);
|
target.takeDamage(weapon.getDamage() + fistDamage);
|
||||||
this.healHp(30);
|
this.healHp(30);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ public abstract class Armor implements Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean checkBreak() {
|
public boolean checkBreak() {
|
||||||
if (durability <= 0) {
|
if (durability <= 0) {
|
||||||
isBroke = true;
|
isBroke = true;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public class Flask extends Consumable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void use(Entity target) {
|
public void use(Entity target) {
|
||||||
target.healHp(target.getMaxHP() / 10);
|
target.healHp(target.getMaxHP() / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ package org.project.item.consumables;
|
|||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
public class Teriak {
|
public class Teriak extends Consumable{
|
||||||
|
|
||||||
|
@Override
|
||||||
public void use(Entity target) {
|
public void use(Entity target) {
|
||||||
target.healMp(target.getMaxMP() / 10);
|
target.healMp(target.getMaxMP() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Sword extends Weapon {
|
public class Sword extends Weapon {
|
||||||
public Sword() {
|
public Sword() {
|
||||||
super( 20 , 8);
|
super( 23 , 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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.Goblin;
|
||||||
import org.project.entity.enemies.Skeleton;
|
import org.project.entity.enemies.Skeleton;
|
||||||
@@ -9,21 +10,19 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Location {
|
public class Location {
|
||||||
private String name;
|
private String name;
|
||||||
private Enemy enemy;
|
private Entity enemie;
|
||||||
|
|
||||||
public Location(String name) {
|
public Location(String name, Entity enemie) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.enemie = enemie;
|
||||||
|
}
|
||||||
|
|
||||||
int n = (int) (Math.random()) * 3 ;
|
public String getName() {
|
||||||
if(n==0){
|
return name;
|
||||||
this.enemy = new Goblin();
|
|
||||||
}
|
|
||||||
if(n==1){
|
|
||||||
this.enemy = new Vampire();
|
|
||||||
}
|
|
||||||
if(n==2){
|
|
||||||
this.enemy = new Skeleton();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Entity getEnemie() {
|
||||||
|
return enemie;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
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.
Reference in New Issue
Block a user