Compare commits
10
Commits
main
...
afc563822e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afc563822e | ||
|
|
74d11ad284 | ||
|
|
adaaf565b8 | ||
|
|
c315d5f9ed | ||
|
|
021a147dcf | ||
|
|
8decc4d7d8 | ||
|
|
e14965a649 | ||
|
|
494f97935e | ||
|
|
8894866b68 | ||
|
|
95c9181cf3 |
@@ -1,21 +1,32 @@
|
||||
package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
void attack(Entity target);
|
||||
public abstract class Entity {
|
||||
|
||||
void defend();
|
||||
private int hp;
|
||||
private final int maxHP;
|
||||
|
||||
void heal(int health);
|
||||
|
||||
void fillMana(int mana);
|
||||
public Entity(int maxHP) {
|
||||
this.hp = maxHP;
|
||||
this.maxHP = maxHP;
|
||||
}
|
||||
|
||||
void takeDamage(int damage);
|
||||
public boolean isAlive() {
|
||||
return hp > 0;
|
||||
}
|
||||
|
||||
int getMaxHP();
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP)
|
||||
hp = maxHP;
|
||||
}
|
||||
|
||||
int getMaxMP();
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage;
|
||||
if(hp<0) hp = 0;
|
||||
}
|
||||
|
||||
public int getMaxHP() {return maxHP;}
|
||||
public int getHP() {return hp;}
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
public class Dragon {
|
||||
}
|
||||
@@ -1,34 +1,41 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Enemy {
|
||||
Weapon weapon;
|
||||
private int hp;
|
||||
private int mp;
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
public abstract class Enemy extends Entity {
|
||||
|
||||
this.weapon = weapon;
|
||||
protected final EnemyStats stats;
|
||||
private boolean stunned;
|
||||
|
||||
public Enemy(EnemyStats stats) {
|
||||
super(stats.maxHP);
|
||||
this.stats = stats;
|
||||
stunned = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage;
|
||||
super.takeDamage(damage);
|
||||
System.out.println("Your attack dealt " + damage + " damage to the enemy!");
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
public void attack(Player target) {
|
||||
if(!stunned) {
|
||||
System.out.println(getType() + " attacked you!");
|
||||
target.takeDamage(stats.damage);
|
||||
}
|
||||
|
||||
else {
|
||||
System.out.println("The enemy was stunned and missed its turn!");
|
||||
stunned = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
}
|
||||
public abstract String getType();
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
public int getXpReward() {return stats.xpReward;}
|
||||
public boolean isStunned() { return stunned; }
|
||||
public void setStunned(boolean stunned) {this.stunned = stunned; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
public class EnemyStats {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
public class Goblin {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
public class Vampire {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Assassin extends Player{
|
||||
|
||||
public Assassin(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) {
|
||||
super(name, hp, maxHP, mp, maxMP, weapon, armor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
|
||||
if(reduceMana(getWeapon().getManaCost())){ //checking if the player has enough Mana
|
||||
|
||||
setDefensing(true); //dodging the next incoming attack
|
||||
target.takeDamage(getWeapon().getDamage() * 2); // causing more damage than normal
|
||||
System.out.println(getName() + " (Assassin \uD83D\uDDE1\uFE0F) turned invisible.");
|
||||
}
|
||||
else{
|
||||
System.out.println(getName() + " (Assassin \uD83D\uDDE1\uFE0F) dose not have enough Mana\n" +
|
||||
"Choose another action...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,33 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Knight {
|
||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
|
||||
public class Knight extends Player {
|
||||
|
||||
public Knight(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) {
|
||||
super(name, hp, maxHP, mp, maxMP, weapon, armor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {//heavy attack
|
||||
|
||||
if(reduceMana(getWeapon().getManaCost())) { //checking if the player has enough Mana
|
||||
target.takeDamage(getWeapon().getDamage()); //causing damage
|
||||
|
||||
if (target instanceof Enemy) {
|
||||
Enemy enemy = (Enemy) target;
|
||||
enemy.setStunned(true); //stun the enemy
|
||||
}
|
||||
|
||||
System.out.println(getName() + " (Knight ⚔️) performed a shield bash that stunned the enemy.");
|
||||
}
|
||||
else{
|
||||
System.out.println(getName() + " (Knight ⚔️) dose not have enough Mana\n" +
|
||||
"Choose another action...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,50 +4,35 @@ import org.project.entity.Entity;
|
||||
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 Armor armor;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
private boolean defensing;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
public Player(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) {
|
||||
super(weapon, hp, maxHP);
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.weapon = weapon;
|
||||
this.maxMP = maxMP;
|
||||
this.armor = armor;
|
||||
|
||||
defensing = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
public void lightAttack(Entity target) {
|
||||
target.takeDamage(super.getWeapon().getDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.getDefense();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
if(!isDefensing()){
|
||||
super.takeDamage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillMana(int mana) {
|
||||
mp += mana;
|
||||
if (mp > maxMP) {
|
||||
@@ -55,35 +40,24 @@ public abstract class Player {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public boolean reduceMana(int amount) {
|
||||
if(mp - amount >= 0) {
|
||||
mp -= amount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
}
|
||||
public String getName() { return name; }
|
||||
|
||||
@Override
|
||||
public int getMaxMP() {
|
||||
return maxMP;
|
||||
}
|
||||
public int getMp() { return mp; }
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
public int getMaxMP() { return maxMP; }
|
||||
|
||||
public Armor getArmor() {
|
||||
return armor;
|
||||
}
|
||||
public Armor getArmor() { return armor; }
|
||||
|
||||
public boolean isDefensing() { return defensing; }
|
||||
public void setDefensing(boolean defensing) {this.defensing = defensing; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
public class PlayerStats {
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Wizard extends Player{
|
||||
|
||||
public Wizard(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) {
|
||||
super(name, hp, maxHP, mp, maxMP, weapon, armor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) { //heavy attack
|
||||
|
||||
Weapon weapon = super.getWeapon();
|
||||
|
||||
if(reduceMana(weapon.getManaCost())){ //checking if the player has enough Mana
|
||||
|
||||
target.takeDamage(weapon.getDamage()); //causing damage
|
||||
heal(20); //replenishing HP
|
||||
System.out.println(getName() + " (Wizard \uD83E\uDDD9\u200D♂\uFE0F) cast a devastating spell");
|
||||
}
|
||||
else{
|
||||
System.out.println(getName() + " (Wizard \uD83E\uDDD9\u200D♂\uFE0F) dose not have enough Mana\n" +
|
||||
"Choose another action...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.project.item;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
public interface Item {
|
||||
void use(Entity target);
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Armor {
|
||||
private int defense;
|
||||
private int maxDefense;
|
||||
private int durability;
|
||||
private int maxDurability;
|
||||
|
||||
private boolean isBroke;
|
||||
|
||||
public Armor(int defense, int durability) {
|
||||
this.defense = defense;
|
||||
this.durability = durability;
|
||||
}
|
||||
|
||||
public void checkBreak() {
|
||||
if (durability <= 0) {
|
||||
isBroke = true;
|
||||
defense = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
||||
public void repair() {
|
||||
isBroke = false;
|
||||
defense = maxDefense;
|
||||
durability = maxDurability;
|
||||
}
|
||||
|
||||
public int getDefense() {
|
||||
return defense;
|
||||
}
|
||||
|
||||
public int getDurability() {
|
||||
return durability;
|
||||
}
|
||||
|
||||
public boolean isBroke() {
|
||||
return isBroke;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Consumable {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Flask {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||
*/
|
||||
|
||||
// TODO: UPDATE USE METHOD
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
target.heal(target.getMaxHP() / 10);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
int abilityCharge;
|
||||
|
||||
public Sword() {
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
for (Entity target : targets) {
|
||||
target.takeDamage(getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Weapon {
|
||||
private int damage;
|
||||
private int manaCost;
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||
*/
|
||||
|
||||
public Weapon(int damage, int manaCost) {
|
||||
this.damage = damage;
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
target.takeDamage(damage);
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public int getManaCost() {
|
||||
return manaCost;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user