Adding weapons and updating the Playe class.
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
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 implements Entity {
|
||||
Weapon weapon;
|
||||
private int hp;
|
||||
private int mp;
|
||||
private boolean isStunned = false;
|
||||
private int stunTurns = 0;
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
@@ -20,6 +22,27 @@ public abstract class Enemy {
|
||||
hp -= damage;
|
||||
}
|
||||
|
||||
public void setStunned(boolean stunned) {
|
||||
this.isStunned = stunned;
|
||||
if (stunned) {
|
||||
this.stunTurns = 1; //Stunned in one turn
|
||||
}
|
||||
}
|
||||
|
||||
//Decreasing the stunned turns
|
||||
public void decrementStun() {
|
||||
if (isStunned) {
|
||||
stunTurns--;
|
||||
if (stunTurns <= 0) {
|
||||
isStunned = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStunned() {
|
||||
return isStunned;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,36 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Knight extends Player implements Entity {
|
||||
public Knight(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
super(name, hp, mp, weapon, armor);
|
||||
setMaxMP(45);
|
||||
setMaxHP(45);
|
||||
|
||||
public class Knight extends Player {
|
||||
public Knight(String name, Weapon weapon, Armor armor) {
|
||||
super(name, 45, 45, weapon, armor);
|
||||
}
|
||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||
|
||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||
@Override
|
||||
public void uniqueAbility(Entity target) {
|
||||
//Checking if the mana is enough of not
|
||||
if (super.getMp() < 15) {
|
||||
System.out.println("Mana is not enough for Shield Bash!");
|
||||
return;
|
||||
}
|
||||
|
||||
//Consuming mana
|
||||
super.setMp(super.getMp()-15);
|
||||
|
||||
//Stunning the enemies
|
||||
target.takeDamage(25);
|
||||
if (target instanceof Enemy) {
|
||||
((Enemy) target).setStunned(true);
|
||||
}
|
||||
|
||||
System.out.println("💥 Shield Bash! Enemy is stunned!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public abstract class Player implements Entity {
|
||||
protected String name;
|
||||
@@ -98,6 +100,7 @@ public abstract class Player implements Entity {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void uniqueAbility(Entity target);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -129,11 +132,11 @@ public abstract class Player implements Entity {
|
||||
return armor;
|
||||
}
|
||||
|
||||
public void setMaxMP(int amount) {
|
||||
maxMP = amount;
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
}
|
||||
|
||||
public void setMaxHP(int amount) {
|
||||
maxHP = amount;
|
||||
public void setMp(int mp) {
|
||||
this.mp = mp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.item.Item;
|
||||
|
||||
//The skeleton's weapon
|
||||
public class BoneDagger extends Weapon implements Item {
|
||||
int abilityCharge;
|
||||
|
||||
public BoneDagger(int damage, int manaCost) {
|
||||
super(damage, manaCost);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.item.Item;
|
||||
|
||||
//The assassin's weapon
|
||||
public class Dagger extends Weapon implements Item {
|
||||
int abilityCharge;
|
||||
|
||||
public Dagger(int damage, int manaCost) {
|
||||
super(damage, manaCost);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.item.Item;
|
||||
|
||||
//The vampire's weapon
|
||||
public class Rapier extends Weapon implements Item {
|
||||
int abilityCharge;
|
||||
|
||||
public Rapier(int damage, int manaCost) {
|
||||
super(damage, manaCost);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,19 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
//The knight's weapon
|
||||
public class Sword extends Weapon implements Item {
|
||||
int abilityCharge;
|
||||
|
||||
public Sword() {
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
public Sword(int damage, int manaCost) {
|
||||
super(damage, manaCost);
|
||||
this.abilityCharge = 0;
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
for (Entity target : targets) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.item.Item;
|
||||
|
||||
//The goblin's weapon
|
||||
public class ToothedHook extends Weapon implements Item {
|
||||
int abilityCharge;
|
||||
|
||||
public ToothedHook(int damage, int manaCost) {
|
||||
super(damage, manaCost);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.item.Item;
|
||||
|
||||
//The wizard's weapon
|
||||
public class Wand extends Weapon implements Item {
|
||||
int abilityCharge;
|
||||
|
||||
public Wand(int damage, int manaCost) {
|
||||
super(damage, manaCost);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Item;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Weapon {
|
||||
public abstract class Weapon implements Item {
|
||||
private int damage;
|
||||
private int manaCost;
|
||||
|
||||
@@ -29,6 +29,14 @@ public abstract class Weapon {
|
||||
return manaCost;
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public void setManaCost(int manaCost) {
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user