Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfffe13cd5 | ||
|
|
dcfbcbbdab |
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>
|
||||||
@@ -9,7 +9,21 @@ public class Main {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO: ADD LOCATIONS TO YOUR GAME
|
// TODO: ADD LOCATIONS TO YOUR GAME
|
||||||
List<Location> locations = new ArrayList<>();
|
List<Location> locations = new ArrayList<>();
|
||||||
|
Location forest = new Location("Forest");
|
||||||
|
Location cave = new Location("Cave");
|
||||||
|
|
||||||
|
forest.addLocation(cave);
|
||||||
|
cave.addLocation(forest);
|
||||||
|
|
||||||
|
locations.add(forest);
|
||||||
|
locations.add(cave);
|
||||||
|
|
||||||
// TODO: IMPLEMENT GAMEPLAY
|
// TODO: IMPLEMENT GAMEPLAY
|
||||||
|
System.out.println("Game started!");
|
||||||
|
System.out.println("Locations created: ");
|
||||||
|
|
||||||
|
for (Location loc : locations) {
|
||||||
|
System.out.println("- " + loc.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,53 @@
|
|||||||
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;
|
protected Weapon weapon;
|
||||||
|
|
||||||
private int hp;
|
private int hp;
|
||||||
|
private int maxHP;
|
||||||
|
|
||||||
private int mp;
|
private int mp;
|
||||||
|
private int maxMP;
|
||||||
|
|
||||||
public Enemy(int hp, int mp, Weapon weapon) {
|
public Enemy(int hp, int mp, Weapon weapon) {
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
|
this.maxHP= hp;
|
||||||
|
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.maxMP= mp;
|
||||||
|
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
hp -= damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
hp -= damage;
|
||||||
|
if (hp < 0) hp = 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void heal(int health){
|
||||||
|
hp+= health;
|
||||||
|
if (hp>maxHP){
|
||||||
|
hp=maxHP;
|
||||||
|
}
|
||||||
|
}
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
public int getMaxHP(){
|
||||||
|
return maxHP;
|
||||||
|
}
|
||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
public int getMaxMP(){
|
||||||
|
return maxMP;
|
||||||
|
}
|
||||||
public Weapon getWeapon() {
|
public Weapon getWeapon() {
|
||||||
return weapon;
|
return weapon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,51 @@
|
|||||||
package org.project.entity.enemies;
|
package org.project.entity.enemies;
|
||||||
|
|
||||||
|
import org.project.entity.Entity;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Skeleton {
|
public class Skeleton extends Enemy {
|
||||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
|
||||||
}
|
private boolean hasRevived;
|
||||||
|
|
||||||
|
public Skeleton() {
|
||||||
|
|
||||||
|
super(
|
||||||
|
80,
|
||||||
|
30,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
this.hasRevived = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attack(Entity target) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void defend() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillMana(int mana) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skeleton revive ability (once per battle)
|
||||||
|
@Override
|
||||||
|
public void takeDamage(int damage) {
|
||||||
|
|
||||||
|
super.takeDamage(damage);
|
||||||
|
|
||||||
|
if (getHp() <= 0 && !hasRevived) {
|
||||||
|
|
||||||
|
hasRevived = true;
|
||||||
|
|
||||||
|
System.out.println("Skeleton revived!");
|
||||||
|
|
||||||
|
heal(getMaxHP() / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,22 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.armors.KnightArmor;
|
||||||
|
import org.project.item.weapons.Sword;
|
||||||
|
import org.project.item.weapons.Weapon;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public class Knight {
|
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
public class Knight extends Player{
|
||||||
|
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
||||||
|
public Knight(String name) {
|
||||||
|
super(
|
||||||
|
name,
|
||||||
|
120,
|
||||||
|
60,
|
||||||
|
new Sword(),
|
||||||
|
new KnightArmor()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -18,7 +18,7 @@ public abstract class Player {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
this.maxMP = mp;
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
this.armor = armor;
|
this.armor = armor;
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,7 @@ public abstract class Player {
|
|||||||
@Override
|
@Override
|
||||||
public void defend() {
|
public void defend() {
|
||||||
// TODO
|
// TODO
|
||||||
|
System.out.println(name+ "is defending!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package org.project.item.armors;
|
|||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Armor {
|
public abstract class Armor {
|
||||||
|
|
||||||
private int defense;
|
private int defense;
|
||||||
private int maxDefense;
|
private int maxDefense;
|
||||||
|
|
||||||
private int durability;
|
private int durability;
|
||||||
private int maxDurability;
|
private int maxDurability;
|
||||||
|
|
||||||
@@ -11,7 +13,12 @@ public abstract class Armor {
|
|||||||
|
|
||||||
public Armor(int defense, int durability) {
|
public Armor(int defense, int durability) {
|
||||||
this.defense = defense;
|
this.defense = defense;
|
||||||
|
this.maxDefense = defense;
|
||||||
|
|
||||||
this.durability = durability;
|
this.durability = durability;
|
||||||
|
this.maxDurability =durability;
|
||||||
|
|
||||||
|
this.isBroke=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkBreak() {
|
public void checkBreak() {
|
||||||
@@ -23,9 +30,15 @@ public abstract class Armor {
|
|||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
||||||
public void repair() {
|
public void repair() {
|
||||||
|
if (!isBroke){
|
||||||
|
System.out.println("Armor is not broken.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
isBroke = false;
|
isBroke = false;
|
||||||
defense = maxDefense;
|
defense = maxDefense;
|
||||||
durability = maxDurability;
|
durability = maxDurability;
|
||||||
|
System.out.println("Armor repaired!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefense() {
|
public int getDefense() {
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
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 CONSTRUCTO
|
||||||
|
public KnightArmor(){
|
||||||
|
super(
|
||||||
|
15,
|
||||||
|
120
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package org.project.item.consumables;
|
package org.project.item.consumables;
|
||||||
|
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Consumable {
|
public abstract class Consumable implements Item {
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
*/
|
*/
|
||||||
|
public abstract void use();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,25 @@ 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 abstract class Flask extends Consumable {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN.
|
||||||
*/
|
*/
|
||||||
|
public Flask(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: UPDATE USE METHOD
|
// TODO: UPDATE USE METHOD
|
||||||
@Override
|
@Override
|
||||||
public void use(Entity target) {
|
public void use(Entity target) {
|
||||||
target.heal(target.getMaxHP() / 10);
|
int healAmount = target.getMaxHP() / 10;
|
||||||
|
target.heal(healAmount);
|
||||||
|
System.out.println("Flask used! Healed"+ healAmount+ "HP.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void use() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ 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.
|
||||||
*/
|
*/
|
||||||
@@ -13,14 +14,33 @@ public class Sword {
|
|||||||
int abilityCharge;
|
int abilityCharge;
|
||||||
|
|
||||||
public Sword() {
|
public Sword() {
|
||||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
|
||||||
|
super(
|
||||||
|
25, // damage
|
||||||
|
10 // manaCost
|
||||||
|
);
|
||||||
|
|
||||||
|
this.abilityCharge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||||
public void uniqueAbility(ArrayList<Entity> targets) {
|
public void uniqueAbility(ArrayList<Entity> targets) {
|
||||||
|
|
||||||
abilityCharge += 2;
|
abilityCharge += 2;
|
||||||
|
|
||||||
|
System.out.println("Sword Unique Ability Activated!");
|
||||||
|
|
||||||
|
int damage = getDamage();
|
||||||
|
|
||||||
|
// BONUS EFFECT: charged attack
|
||||||
|
if (abilityCharge >= 4) {
|
||||||
|
damage *= 2;
|
||||||
|
abilityCharge = 0;
|
||||||
|
System.out.println("POWER STRIKE!");
|
||||||
|
}
|
||||||
|
|
||||||
for (Entity target : targets) {
|
for (Entity target : targets) {
|
||||||
target.takeDamage(getDamage());
|
target.takeDamage(damage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
package org.project.item.weapons;
|
package org.project.item.weapons;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
|
import org.project.item.Item;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
// TODO: UPDATE IMPLEMENTATION
|
||||||
public abstract class Weapon {
|
public abstract class Weapon implements Item {
|
||||||
|
|
||||||
private int damage;
|
private int damage;
|
||||||
private int manaCost;
|
private int manaCost;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
|
||||||
*/
|
*/
|
||||||
@@ -24,12 +25,10 @@ public abstract class Weapon {
|
|||||||
public int getDamage() {
|
public int getDamage() {
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getManaCost() {
|
public int getManaCost() {
|
||||||
return manaCost;
|
return manaCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@@ -5,13 +5,29 @@ import org.project.entity.enemies.Enemy;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Location {
|
public class Location {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private ArrayList<Enemy> enemies;
|
private ArrayList<Enemy> enemies;
|
||||||
|
|
||||||
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {
|
private ArrayList<Location> connectedLocations;
|
||||||
this.locations = locations;
|
|
||||||
this.enemies = enemies;
|
public Location(String name) {
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
this.enemies = new ArrayList<>();
|
||||||
|
this.connectedLocations = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add enemy to location
|
||||||
|
public void addEnemy(Enemy enemy) {
|
||||||
|
enemies.add(enemy);
|
||||||
|
}
|
||||||
|
|
||||||
|
// connect locations (for movement system)
|
||||||
|
public void addLocation(Location location) {
|
||||||
|
connectedLocations.add(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -19,10 +35,10 @@ public class Location {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Location> getLocations() {
|
public ArrayList<Location> getLocations() {
|
||||||
return locations;
|
return connectedLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Enemy> getEnemies() {
|
public ArrayList<Enemy> getEnemies() {
|
||||||
return enemies;
|
return enemies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user