Adds a new type of NPC
This commit is contained in:
@@ -17,6 +17,7 @@ import inf101.v18.grid.GridDirection;
|
||||
import inf101.v18.grid.IGrid;
|
||||
import inf101.v18.grid.ILocation;
|
||||
import inf101.v18.rogue101.Main;
|
||||
import inf101.v18.rogue101.enemies.Girl;
|
||||
import inf101.v18.rogue101.examples.Carrot;
|
||||
import inf101.v18.rogue101.items.Manga;
|
||||
import inf101.v18.rogue101.examples.Rabbit;
|
||||
@@ -258,6 +259,7 @@ public class Game implements IGame {
|
||||
itemFactories.put("C", Carrot::new);
|
||||
itemFactories.put("R", Rabbit::new);
|
||||
itemFactories.put("M", Manga::new);
|
||||
itemFactories.put("G", Girl::new);
|
||||
itemFactories.put(".", Dust::new);
|
||||
}
|
||||
|
||||
@@ -435,7 +437,21 @@ public class Game implements IGame {
|
||||
|
||||
@Override
|
||||
public ILocation rangedAttack(GridDirection dir, IItem target) {
|
||||
return currentLocation;
|
||||
ILocation loc = currentLocation;
|
||||
int damage = (currentActor.getAttack() + random.nextInt(20) + 1)
|
||||
/ loc.gridDistanceTo(map.getLocation(target)); //Close attacks will take more damage.
|
||||
if (damage >= target.getDefence() + 10) {
|
||||
int actualDamage = target.handleDamage(this, target, damage);
|
||||
formatMessage("%s hits %s for %d damage", currentActor.getName(), target.getName(), actualDamage);
|
||||
} else {
|
||||
displayMessage("The attack missed.");
|
||||
}
|
||||
map.clean(loc);
|
||||
if (target.isDestroyed() && map.has(currentLocation.go(dir), target)) {
|
||||
return move(dir);
|
||||
} else {
|
||||
return currentLocation;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user