complete weapons package
This commit is contained in:
@@ -1,4 +1,33 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Dagger {
|
||||
import org.project.entity.Entity;
|
||||
|
||||
public class Dagger extends Weapon{
|
||||
|
||||
private static final double CRIT_CHANCE = 0.3;
|
||||
|
||||
public Dagger() {
|
||||
super(3, "Poison Dagger", 8);
|
||||
}
|
||||
|
||||
public void uniqueAbility(Entity target) {
|
||||
if (target.isAlive())
|
||||
{
|
||||
int damage = this.getDamage();
|
||||
boolean isCrit = Math.random() < CRIT_CHANCE;
|
||||
|
||||
if (isCrit)
|
||||
{
|
||||
damage *= 2;
|
||||
System.out.println("⚡ CRITICAL HIT!");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("🗡️ " + this.getName() + " struck for " + damage + " damage.");
|
||||
}
|
||||
|
||||
target.takeDamage(damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,25 @@ 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 class Sword extends Weapon{
|
||||
|
||||
public Sword() {
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
super(1, "Iron sword", 10);
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
for (Entity target : targets) {
|
||||
target.takeDamage(getDamage());
|
||||
int boostedDamage = this.getDamage() * 2;
|
||||
|
||||
System.out.println("🗡️ " + this.getName() + " glows with power!");
|
||||
|
||||
for (Entity target : targets)
|
||||
{
|
||||
if (target.isAlive())
|
||||
{
|
||||
target.takeDamage(boostedDamage);
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + boostedDamage + " deep slash damage!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Wand {
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Wand extends Weapon{
|
||||
public Wand() {
|
||||
super(2, "Wooden wand", 5);
|
||||
}
|
||||
|
||||
public void uniqueAbility(ArrayList<Enemy> targets)
|
||||
{
|
||||
for (Enemy target : targets)
|
||||
{
|
||||
target.takeDamage(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,37 @@
|
||||
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;
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||
*/
|
||||
|
||||
public Weapon(int damage, int manaCost) {
|
||||
public Weapon(int id, String name, int damage) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.damage = damage;
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
target.takeDamage(damage);
|
||||
System.out.println("🏹 " + name + " is equipped!");
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public int getManaCost() {
|
||||
return manaCost;
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user