192 lines
4.6 KiB
Java
192 lines
4.6 KiB
Java
package inf101.v18.rogue101.enemies;
|
|
|
|
import inf101.v18.grid.GridDirection;
|
|
import inf101.v18.rogue101.game.IGame;
|
|
import inf101.v18.rogue101.objects.IItem;
|
|
import inf101.v18.rogue101.objects.INonPlayer;
|
|
import inf101.v18.rogue101.shared.NPC;
|
|
import inf101.v18.rogue101.states.Age;
|
|
import inf101.v18.rogue101.states.Occupation;
|
|
import inf101.v18.rogue101.states.Personality;
|
|
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
public class Girl implements INonPlayer {
|
|
private final String name = randomName();
|
|
private final Age age = Age.getRandom();
|
|
private final Personality personality = Personality.getRandom();
|
|
private final Occupation occupation = Occupation.getRandom();
|
|
private int maxhp;
|
|
private int hp;
|
|
private int attack;
|
|
private int defence;
|
|
private int visibility;
|
|
private IItem equipped;
|
|
private static final Random random = new Random();
|
|
|
|
public Girl() {
|
|
setStats();
|
|
}
|
|
|
|
private void setStats() {
|
|
switch (age) {
|
|
case TODDLER:
|
|
maxhp = 100;
|
|
attack = 10;
|
|
defence = 50;
|
|
visibility = 1;
|
|
break;
|
|
case CHILD:
|
|
maxhp = 150;
|
|
attack = 20;
|
|
defence = 40;
|
|
visibility = 2;
|
|
break;
|
|
case TEEN:
|
|
maxhp = 200;
|
|
attack = 25;
|
|
defence = 30;
|
|
visibility = 3;
|
|
break;
|
|
case ADULT:
|
|
maxhp = 250;
|
|
attack = 30;
|
|
defence = 20;
|
|
visibility = 4;
|
|
break;
|
|
case ELDER:
|
|
maxhp = 200;
|
|
attack = 15;
|
|
defence = 35;
|
|
visibility = 2;
|
|
break;
|
|
}
|
|
if (occupation == Occupation.MAGE) {
|
|
attack += 10; //Knights are quite powerful.
|
|
}
|
|
if (occupation == Occupation.MAGE) {
|
|
attack += 5; // Mages have lesser range than bowsmen, but more damage.
|
|
}
|
|
maxhp += (int)(random.nextGaussian() * 10);
|
|
hp = maxhp;
|
|
attack += (int)(random.nextGaussian() * 5);
|
|
defence += (int)(random.nextGaussian() * 5);
|
|
}
|
|
|
|
private String randomName() {
|
|
//TODO: Choose from a list of names, or generate name.
|
|
return "Girl";
|
|
}
|
|
|
|
@Override
|
|
public void doTurn(IGame game) {
|
|
if (equipped == null) {
|
|
//TODO: Check if there is a item on the ground to pick up.
|
|
}
|
|
|
|
boolean attack = false;
|
|
switch (personality) {
|
|
case CALM:
|
|
if (hp < maxhp) {
|
|
attack = true;
|
|
}
|
|
break;
|
|
case AFRAID:
|
|
if (NPC.flee(game)) {
|
|
return;
|
|
} else {
|
|
attack = true;
|
|
}
|
|
break;
|
|
case AGRESSIVE:
|
|
attack = true;
|
|
break;
|
|
}
|
|
if (attack) {
|
|
switch (occupation) {
|
|
case KNIGHT:
|
|
if (NPC.tryAttack(game)) {
|
|
return;
|
|
}
|
|
break;
|
|
case MAGE:
|
|
if (NPC.tryAttackRanged(game, 2)) {
|
|
return;
|
|
}
|
|
case BOWSMAN:
|
|
if (NPC.tryAttackRanged(game, 4)) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
List<GridDirection> possibleMoves = game.getPossibleMoves();
|
|
if (!possibleMoves.isEmpty()) {
|
|
Collections.shuffle(possibleMoves);
|
|
game.move(possibleMoves.get(0));
|
|
}
|
|
}
|
|
|
|
public Occupation getOccupation() {
|
|
return occupation;
|
|
}
|
|
|
|
@Override
|
|
public int getAttack() {
|
|
return attack;
|
|
}
|
|
|
|
@Override
|
|
public int getDamage() {
|
|
return 5;
|
|
}
|
|
|
|
@Override
|
|
public int getCurrentHealth() {
|
|
return hp;
|
|
}
|
|
|
|
@Override
|
|
public int getDefence() {
|
|
return defence;
|
|
}
|
|
|
|
@Override
|
|
public int getMaxHealth() {
|
|
return maxhp;
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return 8;
|
|
}
|
|
|
|
@Override
|
|
public String getPrintSymbol() {
|
|
return "𓀠";
|
|
}
|
|
|
|
@Override
|
|
public String getSymbol() {
|
|
return "G";
|
|
}
|
|
|
|
@Override
|
|
public int getVision() {
|
|
return visibility;
|
|
}
|
|
|
|
@Override
|
|
public int handleDamage(IGame game, IItem source, int amount) {
|
|
hp -= amount;
|
|
return amount;
|
|
}
|
|
}
|