This commit is contained in:
2026-05-14 15:22:32 +03:30
parent 526f07f2c7
commit d77fc1f3f3
19 changed files with 44 additions and 28 deletions
@@ -295,15 +295,15 @@ public class Main {
// for win senario // for win senario
if(!enemy.isalive()){ if(!enemy.isalive()){
System.out.println("you WIN"); System.out.println("you WIN");
int n = (int) (Math.random()*2); // 50% present enemy have key
if(enemy instanceof Dragon){ if(enemy instanceof Dragon){
System.out.println(YELLOW + "Congratulation \n + you are the kingdom of Gogorio" + RESET); System.out.println(YELLOW + "Congratulation \n You are the kingdom of Gogorio" +
" 1000 Hp | 1000 Mp" + RESET);
((Player) player).setKing(); // king senario; ((Player) player).setKing(); // king senario;
} }
else if(n== 0){
int n = (int) (Math.random()*2); // 50% present enemy have key
if(n== 0){
if(enemy instanceof Goblin){ if(enemy instanceof Goblin){
if(keys.get(0) == true){ if(keys.get(0) == true){
System.out.println("You have got this key befor"); System.out.println("You have got this key befor");
@@ -28,7 +28,10 @@ public abstract class Enemy implements Entity {
} }
public abstract void specialAbility(Entity target);
@Override
public void lightattack(Entity target){ public void lightattack(Entity target){
System.out.println(toString() + " do a light attaked with " + weapon.getDamage() + " damages"); System.out.println(toString() + " do a light attaked with " + weapon.getDamage() + " damages");
target.takeDamage(weapon.getDamage()); target.takeDamage(weapon.getDamage());
@@ -36,13 +39,15 @@ public abstract class Enemy implements Entity {
} }
@Override
public void heavyattack(Entity target){ public void heavyattack(Entity target){
System.out.println(toString() + " do a heavy attaked with " + weapon.getDamage() * 2 + " damages"); System.out.println(toString() + " do a heavy attaked with " + weapon.getDamage() * 2 + " damages");
target.takeDamage(2 * weapon.getDamage()); target.takeDamage((2 * weapon.getDamage()) - 10);
} }
@Override
public void takeDamage(int damage) { public void takeDamage(int damage) {
if(!armor.checkBreak()){ if(!armor.checkBreak()){
@@ -57,39 +62,37 @@ public abstract class Enemy implements Entity {
}; };
} }
@Override
public int getHp() { public int getHp() {
return hp; return hp;
} }
public int getMp() { public int getMp() {
return mp; return mp;
} }
public int getMaxHP(){ public int getMaxHP(){
return maxHp; return maxHp;
} }
public int getMaxMP(){ public int getMaxMP(){
return maxMp; return maxMp;
} }
@Override
public Weapon getWeapon() { public Weapon getWeapon() {
return weapon; return weapon;
} }
public Armor getArmor(){return armor;} public Armor getArmor(){return armor;}
@Override
public void falsepossible(){ public void falsepossible(){
ispossible = false; ispossible = false;
} }
public void truepossible(){ public void truepossible(){
ispossible=true;} ispossible=true;
}
public boolean getpossible(){ public boolean getpossible(){
return ispossible; return ispossible;
} }
public abstract void specialAbility(Entity target);
@Override @Override
public boolean isalive(){ public boolean isalive(){
@@ -99,9 +102,6 @@ public abstract class Enemy implements Entity {
@Override @Override
public abstract String toString(); public abstract String toString();
public String getName(){return "";} public String getName(){return "";}
@Override
public void repair(){} public void repair(){}
public void defend() {} public void defend() {}
public void healHp(int health){} public void healHp(int health){}
@@ -13,7 +13,7 @@ public class Goblin extends Enemy {
public void specialAbility(Entity target){ public void specialAbility(Entity target){
System.out.println("\uD83D\uDC79 use critical hit"); System.out.println("\uD83D\uDC79 use critical hit");
target.takeDamage(2 * weapon.getDamage()); target.takeDamage(2 * weapon.getDamage() - 5);
this.mp -=10; this.mp -=10;
} }
@@ -11,11 +11,13 @@ public class Assassin extends Player{
} }
public void specialAbility(Entity target){ public void specialAbility(Entity target){
System.out.println(this.getName() + "use special ability, (you are invisible now"); System.out.println(this.getName() + "use special ability, (you are invisible now) " +
"+ Damge:" +weapon.getDamage() + fistDamage );
mp -= 30; mp -= 30;
target.falsepossible(); target.falsepossible();
target.takeDamage(weapon.getDamage() + fistDamage); target.takeDamage(weapon.getDamage() + fistDamage);
} }
@@ -18,6 +18,9 @@ public abstract class Player implements Entity {
protected boolean isalive; protected boolean isalive;
protected int Xp; 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;
this.hp = hp; this.hp = hp;
@@ -33,6 +36,8 @@ public abstract class Player implements Entity {
} }
public abstract void specialAbility(Entity target);
@Override @Override
public void lightattack(Entity target){ public void lightattack(Entity target){
@@ -99,12 +104,13 @@ public abstract class Player implements Entity {
} }
@Override
public String toString(){ public String toString(){
return name+ " |Hp: " + hp +"/" + maxHP + " | Mp: " +mp +"/" + maxMP + "| Xp:" +this.Xp ; return name+ " |Hp: " + hp +"/" + maxHP + " | Mp: " +mp +"/" + maxMP + "| Xp:" +this.Xp ;
} }
public abstract void specialAbility(Entity target);
@Override
public void repair(){ public void repair(){
this.Xp +=1; this.Xp +=1;
this.maxHP +=5; this.maxHP +=5;
@@ -121,14 +127,14 @@ public abstract class Player implements Entity {
this.maxMP = 1000; this.maxMP = 1000;
this.mp = maxMP; this.mp = maxMP;
armor.repair(); armor.repair();
} }
@Override
public String getName() { public String getName() {
return name; return name;
} }
@Override
public int getHp() { public int getHp() {
return hp; return hp;
} }
@@ -138,9 +144,12 @@ public abstract class Player implements Entity {
return maxHP; return maxHP;
} }
@Override
public int getMp() { public int getMp() {
return mp; return mp;
} }
@Override
public boolean getpossible(){ return true;} public boolean getpossible(){ return true;}
@Override @Override
@@ -148,11 +157,12 @@ public abstract class Player implements Entity {
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;
} }
@@ -162,7 +172,7 @@ public abstract class Player implements Entity {
return hp > 0; return hp > 0;
} }
// we should override this function but they are for enemies
public void falsepossible(){} public void falsepossible(){}
public void truepossible(){} public void truepossible(){}
} }
@@ -13,7 +13,11 @@ public class Wizard extends Player{
System.out.println(this.getName() + "use special ability"); System.out.println(this.getName() + "use special ability");
mp -= 30; mp -= 30;
target.takeDamage(weapon.getDamage() + fistDamage); target.takeDamage(weapon.getDamage() + fistDamage);
this.healHp(30); this.hp += 30;
System.out.println(toString()+ "have got 30 Hp");
if(hp > maxHP){
hp = maxHP;
}
} }
@@ -25,7 +25,7 @@ public abstract class Armor implements Item {
public boolean checkBreak() { public boolean checkBreak() {
if(isBroke){ if(isBroke){ // if armor broke by dragon return true
return true; return true;
} }
if (durability <= 0) { if (durability <= 0) {
@@ -70,5 +70,5 @@ public abstract class Armor implements Item {
public void brokeArmor(){ public void brokeArmor(){
isBroke =true; isBroke =true;
} } // for dragon attak
} }
@@ -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() / 4); target.healHp(target.getMaxHP() / 2);
} }
} }
@@ -2,6 +2,6 @@ package org.project.item.weapons;
public class knife extends Weapon{ public class knife extends Weapon{
public knife(){ public knife(){
super(20 , 8); super(15 , 8);
} }
} }
@@ -3,6 +3,6 @@ package org.project.item.weapons;
public class wood extends Weapon{ public class wood extends Weapon{
public wood(){ public wood(){
super(15, 8); super(16, 8);
} }
} }
Binary file not shown.