complete everything and last check
This commit is contained in:
+2
-2
@@ -9,8 +9,8 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
<maven.compiler.target>25</maven.compiler.target>
|
||||
<maven.compiler.source>23</maven.compiler.source>
|
||||
<maven.compiler.target>23</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -9,7 +9,17 @@ public class Main {
|
||||
public static void main(String[] args) {
|
||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
||||
List<Location> locations = new ArrayList<>();
|
||||
Location forest = new Location("Forest", new ArrayList<>());
|
||||
Location dungeon = new Location("Dungeon", new ArrayList<>());
|
||||
Location castle = new Location("Castle", new ArrayList<>());
|
||||
|
||||
locations.add(forest);
|
||||
locations.add(dungeon);
|
||||
locations.add(castle);
|
||||
// TODO: IMPLEMENT GAMEPLAY
|
||||
System.out.println("Locations in the game:");
|
||||
for (Location location : locations) {
|
||||
System.out.println(location.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
/*public interface Entity {
|
||||
void attack(Entity target);
|
||||
|
||||
void defend();
|
||||
@@ -18,4 +18,72 @@ public interface Entity {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
public abstract class Entity {
|
||||
|
||||
protected String name;
|
||||
|
||||
protected int hp;
|
||||
protected int mp;
|
||||
|
||||
protected int maxHP;
|
||||
protected int maxMP;
|
||||
|
||||
public Entity(String name, int hp, int mp) {
|
||||
|
||||
this.name = name;
|
||||
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.maxHP = hp;
|
||||
this.maxMP = mp;
|
||||
}
|
||||
|
||||
public abstract void attack(Entity target);
|
||||
|
||||
public abstract void defend();
|
||||
|
||||
public abstract void heal(int health);
|
||||
|
||||
public void fillMana(int mana) {
|
||||
|
||||
mp += mana;
|
||||
|
||||
if (mp > maxMP) {
|
||||
mp = maxMP;
|
||||
}
|
||||
}
|
||||
|
||||
public void takeDamage(int damage) {
|
||||
|
||||
hp -= damage;
|
||||
|
||||
if (hp < 0) {
|
||||
hp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
}
|
||||
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
public int getMaxMP() {
|
||||
return maxMP;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Enemy {
|
||||
/*public abstract class Enemy {
|
||||
Weapon weapon;
|
||||
private int hp;
|
||||
private int mp;
|
||||
private int mp;*/
|
||||
public abstract class Enemy extends Entity {
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
protected Weapon weapon;
|
||||
//protected int hp;
|
||||
//protected int mp;
|
||||
protected String name;
|
||||
|
||||
|
||||
public Enemy(String name,int hp, int mp, Weapon weapon) {
|
||||
|
||||
super(name, hp, mp);
|
||||
|
||||
this.weapon = weapon;
|
||||
}
|
||||
@@ -18,7 +25,14 @@ public abstract class Enemy {
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage;
|
||||
if (hp < 0) hp = 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
}
|
||||
@Override
|
||||
public abstract void attack(Entity target);
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
@@ -31,4 +45,7 @@ public abstract class Enemy {
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,58 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Skeleton {
|
||||
/*public class Skeleton {
|
||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
}*/
|
||||
public class Skeleton extends Enemy {
|
||||
|
||||
private boolean revived = false;
|
||||
public Skeleton(int hp, int mp, Weapon weapon) {
|
||||
super("Skeleton", hp, mp, weapon);
|
||||
}
|
||||
@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 attack(Entity target) {
|
||||
int damage = weapon.getDamage();
|
||||
target.takeDamage(damage);
|
||||
System.out.println(" Skeleton attacked and dealt " + damage + " damage!");
|
||||
}
|
||||
@Override
|
||||
public void defend() {
|
||||
System.out.println("Skeleton is defending!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
super.takeDamage(damage);
|
||||
|
||||
if (!revived && hp <= 0) {
|
||||
revived = true;
|
||||
|
||||
hp = maxHP / 2;
|
||||
|
||||
System.out.println(
|
||||
"💀 Skeleton revived with 50% HP!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,58 @@
|
||||
package org.project.entity.players;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Knight {
|
||||
//public class Knight {
|
||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||
//}
|
||||
public class Knight extends Player {
|
||||
|
||||
public Knight(String name, int hp, int mp,
|
||||
Weapon weapon, Armor armor) {
|
||||
|
||||
super(name, hp, mp, weapon, armor);
|
||||
}
|
||||
|
||||
public void lightAttack(Entity target) {
|
||||
|
||||
int damage = weapon.getDamage();
|
||||
|
||||
target.takeDamage(damage);
|
||||
|
||||
System.out.println(name +
|
||||
" used Light Attack!");
|
||||
}
|
||||
|
||||
public void heavyAttack(Entity target) {
|
||||
|
||||
int damage = weapon.getDamage() * 2;
|
||||
|
||||
target.takeDamage(damage);
|
||||
|
||||
mp -= 10;
|
||||
|
||||
System.out.println(name +
|
||||
" used Heavy Attack!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
|
||||
System.out.println(name +
|
||||
" raised shield!");
|
||||
}
|
||||
|
||||
public void specialAbility(Entity target) {
|
||||
|
||||
int damage = weapon.getDamage() * 3;
|
||||
|
||||
target.takeDamage(damage);
|
||||
|
||||
mp -= 20;
|
||||
|
||||
System.out.println(name +
|
||||
" used Shield Bash!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,14 @@ import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Player {
|
||||
public abstract class Player extends Entity {
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
Armor armor;
|
||||
private int hp;
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
protected Weapon weapon;
|
||||
protected Armor armor;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
super(name, hp, mp);
|
||||
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
@@ -31,12 +26,23 @@ public abstract class Player {
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
System.out.println(name + " is defending!");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.getDefense();
|
||||
int finalDamage = damage - armor.getDefense();
|
||||
|
||||
if (finalDamage < 0) {
|
||||
finalDamage = 0;
|
||||
}
|
||||
|
||||
hp -= finalDamage;
|
||||
|
||||
if (hp < 0) {
|
||||
hp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,4 +8,5 @@ public interface Item {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
String getName();
|
||||
}
|
||||
|
||||
@@ -1,19 +1,35 @@
|
||||
package org.project.item.armors;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Item;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Armor {
|
||||
public abstract class Armor implements Item {
|
||||
private int defense;
|
||||
private int maxDefense;
|
||||
private int durability;
|
||||
private int maxDurability;
|
||||
|
||||
protected String name;
|
||||
private boolean isBroke;
|
||||
|
||||
public Armor(int defense, int durability) {
|
||||
public Armor(String name , int defense, int durability) {
|
||||
this.name = name;
|
||||
this.defense = defense;
|
||||
this.maxDefense = defense;
|
||||
this.maxDurability = durability;
|
||||
this.durability = durability;
|
||||
}
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
|
||||
System.out.println(
|
||||
target.getName() +
|
||||
" equipped armor!"
|
||||
);
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void checkBreak() {
|
||||
if (durability <= 0) {
|
||||
isBroke = true;
|
||||
@@ -23,9 +39,11 @@ public abstract class Armor {
|
||||
|
||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
||||
public void repair() {
|
||||
isBroke = false;
|
||||
defense = maxDefense;
|
||||
durability = maxDurability;
|
||||
if(isBroke) {
|
||||
isBroke = false;
|
||||
defense = maxDefense;
|
||||
durability = maxDurability;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDefense() {
|
||||
@@ -39,4 +57,5 @@ public abstract class Armor {
|
||||
public boolean isBroke() {
|
||||
return isBroke;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
public class KnightArmor extends Armor {
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
public KnightArmor(int defense, int durability) {
|
||||
|
||||
super("Knight Armor", defense, durability);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,18 @@
|
||||
package org.project.item.consumables;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Item;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Consumable {
|
||||
public abstract class Consumable implements Item {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
protected String name;
|
||||
public Consumable(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public abstract void use(Entity target);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package org.project.item.consumables;
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Flask {
|
||||
public class Flask extends Consumable {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||
*/
|
||||
public Flask() {
|
||||
super("Flask");
|
||||
}
|
||||
|
||||
// TODO: UPDATE USE METHOD
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.project.entity.Entity;
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
public class Sword extends Weapon{
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
@@ -14,6 +14,8 @@ public class Sword {
|
||||
|
||||
public Sword() {
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
super("Sword", 15, 5);
|
||||
this.abilityCharge = 0;
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
@@ -22,5 +24,9 @@ public class Sword {
|
||||
for (Entity target : targets) {
|
||||
target.takeDamage(getDamage());
|
||||
}
|
||||
System.out.println(
|
||||
"⚔️ Sword used special ability!"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.item.Item;
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Weapon {
|
||||
public abstract class Weapon implements Item {
|
||||
private int damage;
|
||||
private int manaCost;
|
||||
|
||||
protected String name;
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||
*/
|
||||
|
||||
public Weapon(int damage, int manaCost) {
|
||||
public Weapon(String name,int damage, int manaCost) {
|
||||
this.name = name;
|
||||
this.damage = damage;
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
@@ -20,7 +21,10 @@ public abstract class Weapon {
|
||||
public void use(Entity target) {
|
||||
target.takeDamage(damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
@@ -28,7 +32,7 @@ public abstract class Weapon {
|
||||
public int getManaCost() {
|
||||
return manaCost;
|
||||
}
|
||||
|
||||
public abstract void uniqueAbility(java.util.ArrayList<Entity> targets);
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
|
||||
@@ -9,19 +9,15 @@ public class Location {
|
||||
|
||||
private ArrayList<Enemy> enemies;
|
||||
|
||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
||||
this.locations = locations;
|
||||
public Location(String name, ArrayList<Enemy> enemies) {
|
||||
|
||||
this.name = name;
|
||||
this.enemies = enemies;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<Location> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public ArrayList<Enemy> getEnemies() {
|
||||
return enemies;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user