+ Added classes : Assassin, Dragon, Goblin, Vampire, Wizard
+ Implemented inheritance structure + Implemented 5 methods of Player actions
This commit is contained in:
Generated
+5
@@ -16,5 +16,10 @@
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://mirror-maven.runflare.com/maven2" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +1,8 @@
|
||||
package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
void attack(Entity target);
|
||||
// void attack(Entity target);
|
||||
|
||||
|
||||
void defend();
|
||||
|
||||
@@ -11,10 +12,20 @@ public interface Entity {
|
||||
|
||||
void takeDamage(int damage);
|
||||
|
||||
void specialAbility(Entity target);
|
||||
|
||||
void stun();
|
||||
|
||||
int getMaxHP();
|
||||
|
||||
int getMaxMP();
|
||||
|
||||
boolean isStunned();
|
||||
|
||||
void stun(boolean value);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
public class Dragon extends Enemy{
|
||||
}
|
||||
@@ -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 stunned = false;
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
@@ -20,6 +22,16 @@ public abstract class Enemy {
|
||||
hp -= damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stun(boolean value) {
|
||||
stunned = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStunned() {
|
||||
return stunned;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
public class Goblin extends Enemy{
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
public class Vampire extends Enemy{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
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 mp, Weapon weapon, Armor armor){
|
||||
super(name, hp, mp, weapon, armor, 300,50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
System.out.println("Turning invisible...");
|
||||
this.defend();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,20 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Knight {
|
||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||
public class Knight extends Player {
|
||||
|
||||
public Knight(String name, int hp, int mp, Weapon weapon, Armor armor){
|
||||
super(name, hp, mp, weapon, armor, 400,40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
System.out.println("Performing shield bash...");
|
||||
target.stun(true);
|
||||
target.takeDamage(50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Player {
|
||||
public abstract class Player implements Entity {
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
Armor armor;
|
||||
@@ -13,34 +13,53 @@ public abstract class Player {
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
private boolean isDefending = false;
|
||||
private boolean stunned;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor,int maxHP, int maxMP) {
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.maxHP = maxHP;
|
||||
this.maxMP = maxMP;
|
||||
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
public void lightAttack(Entity target){
|
||||
target.takeDamage(10);
|
||||
}
|
||||
|
||||
public void heavyAttack(Entity target){
|
||||
target.takeDamage(weapon.getDamage());
|
||||
mp -= weapon.getManaCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
this.mp -= 5;
|
||||
isDefending = true;
|
||||
System.out.println("Defending...");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.getDefense();
|
||||
if (!isDefending) {
|
||||
hp -= damage - armor.getDefense();
|
||||
}
|
||||
else {
|
||||
System.out.println("Defended the attack.");
|
||||
isDefending = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
mp -= 10;
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
@@ -55,6 +74,15 @@ public abstract class Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stun() {
|
||||
stunned = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStunned() {
|
||||
return stunned;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
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 mp, Weapon weapon, Armor armor){
|
||||
super(name, hp, mp, weapon, armor, 500,30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
System.out.println("Casting spell...");
|
||||
target.takeDamage(30);
|
||||
this.heal(10);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
public class KnightArmor extends Armor{
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package org.project.item.consumables;
|
||||
import org.project.entity.Entity;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Flask {
|
||||
public class Flask extends Consumable {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.project.entity.Entity;
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
public class Sword extends Weapon {
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user