+ 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="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</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>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package org.project.entity;
|
package org.project.entity;
|
||||||
|
|
||||||
public interface Entity {
|
public interface Entity {
|
||||||
void attack(Entity target);
|
// void attack(Entity target);
|
||||||
|
|
||||||
|
|
||||||
void defend();
|
void defend();
|
||||||
|
|
||||||
@@ -11,10 +12,20 @@ public interface Entity {
|
|||||||
|
|
||||||
void takeDamage(int damage);
|
void takeDamage(int damage);
|
||||||
|
|
||||||
|
void specialAbility(Entity target);
|
||||||
|
|
||||||
|
void stun();
|
||||||
|
|
||||||
int getMaxHP();
|
int getMaxHP();
|
||||||
|
|
||||||
int getMaxMP();
|
int getMaxMP();
|
||||||
|
|
||||||
|
boolean isStunned();
|
||||||
|
|
||||||
|
void stun(boolean value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
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;
|
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
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Enemy {
|
public abstract class Enemy implements Entity {
|
||||||
Weapon weapon;
|
Weapon weapon;
|
||||||
private int hp;
|
private int hp;
|
||||||
private int mp;
|
private int mp;
|
||||||
|
private boolean stunned = false;
|
||||||
|
|
||||||
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,16 @@ public abstract class Enemy {
|
|||||||
hp -= damage;
|
hp -= damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stun(boolean value) {
|
||||||
|
stunned = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStunned() {
|
||||||
|
return stunned;
|
||||||
|
}
|
||||||
|
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
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;
|
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
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Knight {
|
public class Knight extends Player {
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
|
||||||
|
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;
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Player {
|
public abstract class Player implements Entity {
|
||||||
protected String name;
|
protected String name;
|
||||||
Weapon weapon;
|
Weapon weapon;
|
||||||
Armor armor;
|
Armor armor;
|
||||||
@@ -13,34 +13,53 @@ public abstract class Player {
|
|||||||
private int maxHP;
|
private int maxHP;
|
||||||
private int mp;
|
private int mp;
|
||||||
private int maxMP;
|
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.name = name;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
|
||||||
|
this.maxHP = maxHP;
|
||||||
|
this.maxMP = maxMP;
|
||||||
|
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
this.armor = armor;
|
this.armor = armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void lightAttack(Entity target){
|
||||||
public void attack(Entity target) {
|
target.takeDamage(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void heavyAttack(Entity target){
|
||||||
target.takeDamage(weapon.getDamage());
|
target.takeDamage(weapon.getDamage());
|
||||||
|
mp -= weapon.getManaCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void defend() {
|
public void defend() {
|
||||||
// TODO
|
this.mp -= 5;
|
||||||
|
isDefending = true;
|
||||||
|
System.out.println("Defending...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
|
if (!isDefending) {
|
||||||
hp -= damage - armor.getDefense();
|
hp -= damage - armor.getDefense();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Defended the attack.");
|
||||||
|
isDefending = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void heal(int health) {
|
public void heal(int health) {
|
||||||
|
mp -= 10;
|
||||||
hp += health;
|
hp += health;
|
||||||
if (hp > maxHP) {
|
if (hp > maxHP) {
|
||||||
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() {
|
public String getName() {
|
||||||
return name;
|
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;
|
package org.project.item.armors;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class KnightArmor {
|
public class KnightArmor extends Armor{
|
||||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ package org.project.item.consumables;
|
|||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Flask {
|
public class Flask extends Consumable {
|
||||||
/*
|
/*
|
||||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.project.entity.Entity;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Sword {
|
public class Sword extends Weapon {
|
||||||
/*
|
/*
|
||||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user