Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Java-Ring/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

462 changes: 459 additions & 3 deletions Java-Ring/src/main/java/org/project/Main.java

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions Java-Ring/src/main/java/org/project/entity/Entity.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
package org.project.entity;

import org.project.object.weapons.Weapon;

public interface Entity {
void attack(Entity target);
void reset();

void defend();
void attack(Entity target);

void heal(int health);

void fillMana(int mana);
void Special(Entity target);

void takeDamage(int damage);



//getters
Weapon getWeapon();
int getHP();
int getMaxHP();
int getLevel();
boolean isDefending();
boolean isDead();

int getMaxMP();
//setters
void DefendStatusChange();

/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
}
}
90 changes: 76 additions & 14 deletions Java-Ring/src/main/java/org/project/entity/enemies/Enemy.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,97 @@
package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.object.weapons.Weapon;
import java.lang.Math;

// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy {
import static java.lang.Math.min;

public abstract class Enemy implements Entity {
Weapon weapon;
private int lvl;
private int hp;
private int mp;

public Enemy(int hp, int mp, Weapon weapon) {
this.hp = hp;
this.mp = mp;
private final int MaxHP;
private boolean IsDefending=false;
protected boolean IsDead=false;

//constructor
public Enemy(int lvl,double hpMult, Weapon weapon) {
this.lvl=lvl;
this.hp = (int)(lvl*hpMult)*100;
this.MaxHP = this.hp;
this.weapon = weapon;
}

// TODO: (BONUS) UPDATE THE FORMULA OF TAKING DAMAGE
//resets player's status each round
@Override
public void reset()
{
this.IsDefending=false;
}

//taking damage
@Override
public void takeDamage(int damage) {
hp -= damage;
if(!IsDefending) {
hp -= damage;
}
else {
hp -= damage/(int)(Math.sqrt(lvl)*2);
}
if(this.hp <= 0) {
IsDead=true;
this.hp = 0;
}
}

public int getHp() {
return hp;
//attack
@Override
public void attack(Entity target) {
int damage = (int)((getWeapon().getDamage())*(Math.sqrt(getLevel())));
target.takeDamage(damage);
}

public int getMp() {
return mp;
//heal
@Override
public void heal(int health) {
hp = min(hp + health, MaxHP);
}


//getter methods
@Override
public boolean isDefending(){
return IsDefending;
}
@Override
public int getHP() {
return hp;
}
public int getLevel(){
return lvl;
}
public int getMaxHP() {
return MaxHP;
}
public Weapon getWeapon() {
return weapon;
}
}
public boolean isDead() {
return IsDead;
}
public boolean isResurrected()
{
return false;
}
//getting enemy status
abstract public String getStatus();

//setter methods
public void setLevel(int lvl){
this.lvl=lvl;
}
public void DefendStatusChange() {
IsDefending = !IsDefending;
}

}
57 changes: 53 additions & 4 deletions Java-Ring/src/main/java/org/project/entity/enemies/Skeleton.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
package org.project.entity.enemies;

// TODO: UPDATE IMPLEMENTATION
public class Skeleton {
// TODO: DESIGN ENEMY'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
}
import org.project.entity.Entity;
import org.project.object.weapons.Weapon;

import static java.lang.Math.min;

public class Skeleton extends Enemy {

private boolean Resurrected = false;
public final static int BaseAttack = 25;
//constructor
public Skeleton(int lvl, Weapon weapon) {
super(lvl,1.25, weapon);
}
//Special Ability
@Override
public void Special(Entity target) {
if(super.IsDead && !Resurrected)
{
if(super.getLevel() == 1)
Resurrected = true;
else {
Resurrected = false;
super.setLevel(super.getLevel()/2);
}

super.IsDead = false;
this.heal(super.getMaxHP()/4);
}
}

//get status shows resurrected
@Override
public String getStatus() {
return "Skeleton" + " lvl." + getLevel()+ ": "
+ "HP (" + getHP() + "/" + getMaxHP() + ") |"
+ "Defending : " + "(" + isDefending() + ")" + " | Resurrected: " + Resurrected;
}
@Override
public String toString(){
return "Skeleton" + " lvl." + getLevel();
}




//getter for resurrected
@Override
public boolean isResurrected()
{
return this.Resurrected;
}

}
33 changes: 30 additions & 3 deletions Java-Ring/src/main/java/org/project/entity/players/Knight.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
package org.project.entity.players;

import org.project.entity.Entity;
import org.project.object.armors.Armor;
import org.project.object.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 static int BaseAttack = 90;

//constructor
public Knight(String name, Weapon weapon, Armor armor) {
super(name, 1000, 100, weapon, armor);
}
//uses mana for special ability
@Override
public void Special(Entity target) {
if(super.getMp() >= 50) {
super.setMp(super.getMp() - 50);
target.takeDamage(5*BaseAttack);
System.out.printf("%s uses Holy Strike on %s!%n", getName(), target.getClass().getSimpleName());
}
else {
System.out.println("Not enough mana to perform Holy Strike!");
}
}
//leveling up mechanism
@Override
public void levelUP(){
BaseAttack = BaseAttack + (int)(20*Math.sqrt(super.getLevel()+1));
super.levelUP();
}
}
Loading