update enemies
This commit is contained in:
@@ -8,7 +8,6 @@ import org.project.entity.players.Assassin;
|
||||
import org.project.entity.players.Knight;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.entity.players.Wizard;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.location.Location;
|
||||
@@ -26,9 +25,9 @@ public class Main {
|
||||
players.add(new Knight());
|
||||
players.add(new Wizard());
|
||||
ArrayList<Enemy> enemies = new ArrayList<>();
|
||||
enemies.add(new Goblin(80, 100, wp));
|
||||
enemies.add(new Skeleton(70, 100, wp));
|
||||
enemies.add(new Vampire(90, 90, wp));
|
||||
enemies.add(new Goblin());
|
||||
enemies.add(new Skeleton());
|
||||
enemies.add(new Vampire());
|
||||
ArrayList<Location> locations = new ArrayList<>();
|
||||
locations.add(new Location("Jungle", enemies));
|
||||
locations.add(new Location("China", new ArrayList<>(enemies.subList(0, 2))));
|
||||
@@ -117,20 +116,20 @@ public class Main {
|
||||
break;
|
||||
case 2:
|
||||
player.heavyAttack(enemy);
|
||||
if (player.isSuccessful()) break;
|
||||
if (player.isSuccessfulAction()) break;
|
||||
else {turn = 0; continue;}
|
||||
case 3:
|
||||
player.defend();
|
||||
if (player.isSuccessful()) break;
|
||||
if (player.isSuccessfulAction()) break;
|
||||
else {turn = 0; continue;}
|
||||
case 4:
|
||||
player.heal(10);
|
||||
if (player.isSuccessful()) break;
|
||||
if (player.isSuccessfulAction()) break;
|
||||
else {turn = 0; continue;}
|
||||
|
||||
case 5:
|
||||
player.specialAbility(enemy);
|
||||
if (player.isSuccessful()) break;
|
||||
if (player.isSuccessfulAction()) break;
|
||||
else {turn = 0; continue;}
|
||||
default:
|
||||
System.out.println("invalid choice");
|
||||
@@ -157,15 +156,15 @@ public class Main {
|
||||
switch (choice) {
|
||||
case 0:
|
||||
enemy.attack(player);
|
||||
if (enemy.isSuccessful()) break;
|
||||
if (enemy.isSuccessfulAction()) break;
|
||||
else {turn = 1; continue;}
|
||||
case 1:
|
||||
enemy.defend();
|
||||
if (enemy.isSuccessful()) break;
|
||||
if (enemy.isSuccessfulAction()) break;
|
||||
else {turn = 1; continue;}
|
||||
case 2:
|
||||
enemy.heal(10);
|
||||
if (enemy.isSuccessful()) break;
|
||||
if (enemy.isSuccessfulAction()) break;
|
||||
else {turn = 1; continue;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Knight;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
|
||||
@@ -17,7 +16,7 @@ public abstract class Enemy implements Entity {
|
||||
private double attackMultiplier = 1;
|
||||
private boolean hasKey = false;
|
||||
private static boolean keyFound = false;
|
||||
private boolean successful = true;
|
||||
private boolean successfulAction = true;
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
@@ -33,17 +32,18 @@ public abstract class Enemy implements Entity {
|
||||
if (getMP() >= weapon.getManaCost()) {
|
||||
System.out.println(this.getClass().getSimpleName() + ": attacking " + target.getClass().getSimpleName());
|
||||
double damage = getAttackMultiplier() * weapon.getDamage();
|
||||
if(((Sword)(weapon)).charge()) damage *= 1.4;
|
||||
if (target.isDefending()) {
|
||||
target.takeDamage((int) (damage * (1 - target.getDefendRate())),this);
|
||||
target.setDefending(false);
|
||||
} else {
|
||||
target.takeDamage((int) damage);
|
||||
target.takeDamage((int) damage,this);
|
||||
}
|
||||
setMP(getMP() - weapon.getManaCost());
|
||||
}
|
||||
else {
|
||||
System.out.println("not enough mana");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,12 +167,12 @@ public abstract class Enemy implements Entity {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setSuccessful (boolean successful) {
|
||||
this.successful = successful;
|
||||
public void setSuccessfulAction(boolean successfulAction) {
|
||||
this.successfulAction = successfulAction;
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
return successful;
|
||||
public boolean isSuccessfulAction() {
|
||||
return successfulAction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.item.weapons.Sword;
|
||||
|
||||
public class Goblin extends Enemy{
|
||||
public Goblin(int hp, int mp, Weapon weapon) {
|
||||
super(hp,mp,weapon);
|
||||
public Goblin() {
|
||||
super(80,100,new Sword());
|
||||
setDefendRate(.5);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Goblin extends Enemy{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Goblin extends Enemy{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package org.project.entity.enemies;
|
||||
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.item.weapons.Sword;
|
||||
|
||||
public class Skeleton extends Enemy{
|
||||
|
||||
private boolean incarnation = false;
|
||||
public Skeleton(int hp, int mp, Weapon weapon) {
|
||||
super(hp,mp,weapon);
|
||||
public Skeleton() {
|
||||
super(70,100,new Sword());
|
||||
setDefendRate(.3);
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class Skeleton extends Enemy{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Skeleton extends Enemy{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.item.weapons.Sword;
|
||||
|
||||
public class Vampire extends Enemy{
|
||||
|
||||
public Vampire(int hp, int mp, Weapon weapon) {
|
||||
super(hp,mp,weapon);
|
||||
public Vampire() {
|
||||
super(90,90,new Sword());
|
||||
setDefendRate(.7);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,11 @@ public class Vampire extends Enemy{
|
||||
setAttackMultiplier(1);
|
||||
if (target.isDefending()) {
|
||||
heal( (int) (.3 * (damage * (1 - target.getDefendRate()))));
|
||||
setMP(getMP() + 12);
|
||||
}
|
||||
else {
|
||||
heal( (int) (.3 * damage));
|
||||
setMP(getMP() + 12);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +34,7 @@ public class Vampire extends Enemy{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +46,7 @@ public class Vampire extends Enemy{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,8 @@ package org.project.entity.players;
|
||||
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.AssassinArmor;
|
||||
import org.project.item.weapons.Dagger;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Assassin extends Player {
|
||||
|
||||
@@ -44,7 +41,7 @@ public class Assassin extends Player {
|
||||
setMP(getMP() - weapon.getManaCost());
|
||||
} else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +54,7 @@ public class Assassin extends Player {
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +67,7 @@ public class Assassin extends Player {
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +79,7 @@ public class Assassin extends Player {
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,8 @@ package org.project.entity.players;
|
||||
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.weapons.Dagger;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Knight extends Player {
|
||||
|
||||
@@ -38,7 +35,7 @@ public class Knight extends Player {
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +47,7 @@ public class Knight extends Player {
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +74,7 @@ public class Knight extends Player {
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class Player implements Entity, combatOptions {
|
||||
private boolean hasGoblinKey = false;
|
||||
private boolean hasSkeletonKey = false;
|
||||
private boolean hasVampireKey = false;
|
||||
private boolean successful = true;
|
||||
private boolean successfulAction = true;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
this.name = name;
|
||||
@@ -194,12 +194,12 @@ public abstract class Player implements Entity, combatOptions {
|
||||
else { hasVampireKey = true; }
|
||||
}
|
||||
|
||||
public void setSuccessful (boolean successful) {
|
||||
this.successful = successful;
|
||||
public void setSuccessfulAction(boolean successfulAction) {
|
||||
this.successfulAction = successfulAction;
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
return successful;
|
||||
public boolean isSuccessfulAction() {
|
||||
return successfulAction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.armors.WizardArmor;
|
||||
import org.project.item.weapons.Bow;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Wizard extends Player{
|
||||
|
||||
@@ -39,7 +35,7 @@ public class Wizard extends Player{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +47,7 @@ public class Wizard extends Player{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +62,7 @@ public class Wizard extends Player{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +74,7 @@ public class Wizard extends Player{
|
||||
}
|
||||
else {
|
||||
System.out.println("Not enough MP");
|
||||
setSuccessful(false);
|
||||
setSuccessfulAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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.
Binary file not shown.
Reference in New Issue
Block a user