Minor changes
Adds new method for containers for finding first item of a class Adds health potions Allows the user to use potions
This commit is contained in:
@@ -20,6 +20,7 @@ import inf101.v18.rogue101.Main;
|
||||
import inf101.v18.rogue101.enemies.Boss;
|
||||
import inf101.v18.rogue101.enemies.Girl;
|
||||
import inf101.v18.rogue101.examples.Carrot;
|
||||
import inf101.v18.rogue101.examples.Manga;
|
||||
import inf101.v18.rogue101.items.*;
|
||||
import inf101.v18.rogue101.examples.Rabbit;
|
||||
import inf101.v18.rogue101.map.GameMap;
|
||||
@@ -91,9 +92,9 @@ public class Game implements IGame {
|
||||
}
|
||||
|
||||
// Prints some helpful information.
|
||||
String[] info = {"Controls:", "WASD or arrow keys for movement", "E to pick up an item", "Q to drop an item", "1-0 to choose an item (10=0)", "N to change name", "ENTER to confirm", "R to use a ranged attack", "F to use a magic attack"};
|
||||
String[] info = {"Controls:", "WASD or arrow keys for movement", "E to pick up an item", "Q to drop an item", "1-0 to choose an item (10=0)", "N to change name", "ENTER to confirm", "R to use a ranged attack", "F to use a magic attack", "C to use a potion"};
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
this.printer.printAt(map.getWidth() + 2, 1 + i, info[i]);
|
||||
this.printer.printAt(Main.COLUMN_MAP_END + 2, 1 + i, info[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,10 +133,6 @@ public class Game implements IGame {
|
||||
*/
|
||||
private int getAttack() {
|
||||
int damage = currentActor.getAttack() + random.nextInt(20) + 1;
|
||||
IWeapon weapon = (IWeapon)currentActor.getItem(IWeapon.class);
|
||||
if (weapon != null) {
|
||||
damage += weapon.getWeaponDamage();
|
||||
}
|
||||
IBuffItem buff = (IBuffItem)currentActor.getItem(IBuffItem.class);
|
||||
if (buff != null) {
|
||||
damage += buff.getBuffDamage();
|
||||
@@ -167,6 +164,10 @@ public class Game implements IGame {
|
||||
*/
|
||||
private int getDamage(IItem target) {
|
||||
int damage = currentActor.getDamage();
|
||||
IWeapon weapon = (IWeapon)currentActor.getItem(IWeapon.class);
|
||||
if (weapon != null) {
|
||||
damage += weapon.getWeaponDamage();
|
||||
}
|
||||
IActor actor = (IActor) target;
|
||||
IBuffItem item = (IBuffItem) actor.getItem(IBuffItem.class);
|
||||
if (item != null) {
|
||||
@@ -181,7 +182,7 @@ public class Game implements IGame {
|
||||
if (!map.has(loc, target)) {
|
||||
throw new IllegalMoveException("Target isn't there!");
|
||||
}
|
||||
//TODO: Detect the weapon used
|
||||
//TODO: Detect the weapon used, and use its sound
|
||||
IWeapon weapon = (IWeapon) currentActor.getItem(IWeapon.class);
|
||||
if (weapon != null) {
|
||||
NPC.playSound(weapon.getSound());
|
||||
@@ -279,14 +280,7 @@ public class Game implements IGame {
|
||||
map.clean(currentLocation);
|
||||
return false;
|
||||
} else if (currentActor instanceof IPlayer) {
|
||||
if (currentActor.isDestroyed()) {
|
||||
// a dead human player gets removed from the game
|
||||
//This never actually triggers, because of map.clean();
|
||||
/*displayMessage("YOU DIE!!!");
|
||||
map.remove(currentLocation, currentActor);
|
||||
currentActor = null;
|
||||
currentLocation = null;*/
|
||||
} else {
|
||||
if (!currentActor.isDestroyed()) {
|
||||
// For the human player, we need to wait for input, so we just return.
|
||||
// Further keypresses will cause keyPressed() to be called, and once the human
|
||||
// makes a move, it'll lose its movement point and doTurn() will be called again
|
||||
@@ -315,6 +309,7 @@ public class Game implements IGame {
|
||||
currentLocation = null;
|
||||
actors = new ArrayList<>();
|
||||
loadMap("gameover.txt");
|
||||
NPC.playSound("audio/Dying-SoundBible.com-1255481835.wav");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,6 +391,7 @@ public class Game implements IGame {
|
||||
itemFactories.put("B", Boss::new);
|
||||
itemFactories.put("s", Staff::new);
|
||||
itemFactories.put("b", Bow::new);
|
||||
itemFactories.put("H", HealthPotion::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user