Adding weapons and updating the Playe class.
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public abstract class Enemy implements Entity {
|
||||||
public abstract class Enemy {
|
|
||||||
Weapon weapon;
|
Weapon weapon;
|
||||||
private int hp;
|
private int hp;
|
||||||
private int mp;
|
private int mp;
|
||||||
|
private boolean isStunned = false;
|
||||||
|
private int stunTurns = 0;
|
||||||
|
|
||||||
public Enemy(int hp, int mp, Weapon weapon) {
|
public Enemy(int hp, int mp, Weapon weapon) {
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
@@ -20,6 +22,27 @@ public abstract class Enemy {
|
|||||||
hp -= damage;
|
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() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,36 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
import org.project.entity.enemies.Enemy;
|
||||||
import org.project.item.armors.Armor;
|
import org.project.item.armors.Armor;
|
||||||
import org.project.item.weapons.Weapon;
|
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) {
|
public class Knight extends Player {
|
||||||
super(name, hp, mp, weapon, armor);
|
public Knight(String name, Weapon weapon, Armor armor) {
|
||||||
setMaxMP(45);
|
super(name, 45, 45, weapon, armor);
|
||||||
setMaxHP(45);
|
|
||||||
}
|
}
|
||||||
// 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.armors.Armor;
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
public abstract class Player implements Entity {
|
public abstract class Player implements Entity {
|
||||||
protected String name;
|
protected String name;
|
||||||
@@ -98,6 +100,7 @@ public abstract class Player implements Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void uniqueAbility(Entity target);
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -129,11 +132,11 @@ public abstract class Player implements Entity {
|
|||||||
return armor;
|
return armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxMP(int amount) {
|
public void setHp(int hp) {
|
||||||
maxMP = amount;
|
this.hp = hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHP(int amount) {
|
public void setMp(int mp) {
|
||||||
maxHP = amount;
|
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;
|
package org.project.item.weapons;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
//The knight's weapon
|
||||||
public class Sword {
|
public class Sword extends Weapon implements Item {
|
||||||
/*
|
|
||||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int abilityCharge;
|
int abilityCharge;
|
||||||
|
|
||||||
public Sword() {
|
public Sword(int damage, int manaCost) {
|
||||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
super(damage, manaCost);
|
||||||
|
this.abilityCharge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
|
||||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||||
abilityCharge += 2;
|
abilityCharge += 2;
|
||||||
for (Entity target : targets) {
|
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;
|
package org.project.item.weapons;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public abstract class Weapon implements Item {
|
||||||
public abstract class Weapon {
|
|
||||||
private int damage;
|
private int damage;
|
||||||
private int manaCost;
|
private int manaCost;
|
||||||
|
|
||||||
@@ -29,6 +29,14 @@ public abstract class Weapon {
|
|||||||
return manaCost;
|
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
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user