Minor changes

Fixed magic weapons using the wrong sound
Made some changes to better detect the weapon used to attack
This commit is contained in:
2018-03-20 11:05:15 +01:00
parent 30ba612e56
commit 6ad8eb93d7
9 changed files with 71 additions and 36 deletions

View File

@@ -29,6 +29,7 @@ import inf101.v18.rogue101.map.IMapView;
import inf101.v18.rogue101.map.MapReader;
import inf101.v18.rogue101.objects.*;
import inf101.v18.rogue101.shared.NPC;
import inf101.v18.rogue101.states.Attack;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
@@ -182,8 +183,7 @@ public class Game implements IGame {
if (!map.has(loc, target)) {
throw new IllegalMoveException("Target isn't there!");
}
//TODO: Detect the weapon used, and use its sound
IWeapon weapon = (IWeapon) currentActor.getItem(IWeapon.class);
IWeapon weapon = (IWeapon) currentActor.getItem(IMeleeWeapon.class);
if (weapon != null) {
NPC.playSound(weapon.getSound());
} else {
@@ -209,9 +209,16 @@ public class Game implements IGame {
}
@Override
public ILocation rangedAttack(GridDirection dir, IItem target) {
public ILocation rangedAttack(GridDirection dir, IItem target, Attack type) {
ILocation loc = currentLocation;
IWeapon weapon = (IWeapon) currentActor.getItem(IWeapon.class);
IWeapon weapon = null;
switch (type) {
case MAGIC:
weapon = (IWeapon) currentActor.getItem(IMagicWeapon.class);
break;
case RANGED:
weapon = (IWeapon) currentActor.getItem(IRangedWeapon.class);
}
if (weapon != null) {
NPC.playSound(weapon.getSound());
} else {

View File

@@ -12,6 +12,7 @@ import inf101.v18.rogue101.objects.IItem;
import inf101.v18.rogue101.objects.IActor;
import inf101.v18.rogue101.objects.INonPlayer;
import inf101.v18.rogue101.objects.IPlayer;
import inf101.v18.rogue101.states.Attack;
/**
* Game interface
@@ -320,7 +321,7 @@ public interface IGame {
* A target item, which should in some square in the given direction
* @return Your new location if the attack resulted in you moving (unlikely)
*/
ILocation rangedAttack(GridDirection dir, IItem target);
ILocation rangedAttack(GridDirection dir, IItem target, Attack type);
/**
* @return A random generator