knight java
This commit is contained in:
@@ -3,9 +3,6 @@ package org.project.item;
|
||||
import org.project.entity.Entity;
|
||||
|
||||
public interface Item {
|
||||
void use(Entity target);
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
void use(Entity target);
|
||||
}
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Armor {
|
||||
private int defense;
|
||||
private int maxDefense;
|
||||
private int durability;
|
||||
private int maxDurability;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Item;
|
||||
|
||||
private boolean isBroke;
|
||||
public abstract class Armor {
|
||||
protected int defense;
|
||||
protected int maxDefense;
|
||||
protected int durability;
|
||||
protected int maxDurability;
|
||||
protected boolean isBroke;
|
||||
|
||||
public Armor(int defense, int durability) {
|
||||
this.defense = defense;
|
||||
this.durability = durability;
|
||||
this.isBroke = false;
|
||||
}
|
||||
|
||||
public void checkBreak() {
|
||||
if (durability <= 0) {
|
||||
isBroke = true;
|
||||
defense = 0;
|
||||
System.out.println("\u001B[31m Armor broke! \u001B[0m");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
||||
public void repair() {
|
||||
isBroke = false;
|
||||
defense = maxDefense;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
public class ClothArmor extends Armor{
|
||||
public ClothArmor(int defense, int durability) {
|
||||
super(3, 10);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
public class KnightArmor extends Armor {
|
||||
public KnightArmor(int defense, int durability) {
|
||||
super(8, 20);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
public class LeatherArmor extends Armor{
|
||||
public LeatherArmor(int defense, int durability) {
|
||||
super(5, 15);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,20 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Consumable {
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Item;
|
||||
|
||||
public abstract class Consumable implements Item {
|
||||
protected int healAmount;
|
||||
protected int manaAmount;
|
||||
|
||||
public Consumable(){
|
||||
this.healAmount = healAmount;
|
||||
this.manaAmount = manaAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(Entity target){
|
||||
target.heal(healAmount);
|
||||
target.fillMana(manaAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package org.project.item.consumables;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Item;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Flask {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||
*/
|
||||
public class Flask implements Item {
|
||||
|
||||
// TODO: UPDATE USE METHOD
|
||||
@Override
|
||||
public void use(Entity target) {
|
||||
target.heal(target.getMaxHP() / 10);
|
||||
int healAmount = target.getMaxHP() /10;
|
||||
target.heal(healAmount);
|
||||
target.fillMana(10);
|
||||
System.out.println("\u001B[32m Flask used! Healed " + healAmount + "HP and restored 10 mana! \u001B[0m");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Claw extends Weapon{
|
||||
public Claw(int damage, int manaCost) {
|
||||
super(20, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Dagger extends Weapon{
|
||||
public Dagger(int damage, int manaCost) {
|
||||
super(14, 0);
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,15 @@ import org.project.entity.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
public class Sword extends Weapon{
|
||||
|
||||
int abilityCharge;
|
||||
|
||||
public Sword() {
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
super(15 , 0);
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||
abilityCharge += 2;
|
||||
for (Entity target : targets) {
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
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;
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||
*/
|
||||
|
||||
public Weapon(int damage, int manaCost) {
|
||||
this.damage = damage;
|
||||
this.manaCost = manaCost;
|
||||
@@ -29,7 +25,4 @@ public abstract class Weapon {
|
||||
return manaCost;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.project.item.weapons;
|
||||
|
||||
public class Wood extends Weapon {
|
||||
public Wood(int damage, int manaCost) {
|
||||
super(12, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user