Skip to content
Snippets Groups Projects
Commit b98fd234 authored by Chris Kearney's avatar Chris Kearney
Browse files

migrated del command to new format, and reverted back to old loot command which works fine

parent 63081955
No related branches found
No related tags found
No related merge requests found
...@@ -22,14 +22,8 @@ public class DelCommand extends Command { ...@@ -22,14 +22,8 @@ public class DelCommand extends Command {
@Override @Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
execCommand(ctx, e, new CommandRunnable() { execCommand(ctx, e, () -> {
@Override if (originalMessageParts.size() <= 1) {
public void run() {
}
});
try {
if (originalMessageParts.size() <= 1) {
write(returnAllSettings()); write(returnAllSettings());
return; return;
} }
...@@ -37,9 +31,7 @@ public class DelCommand extends Command { ...@@ -37,9 +31,7 @@ public class DelCommand extends Command {
String desiredSettingName = originalMessageParts.get(0); String desiredSettingName = originalMessageParts.get(0);
player.removePlayerSetting(desiredSettingName); player.removePlayerSetting(desiredSettingName);
write("Setting removed.\r\n"); write("Setting removed.\r\n");
} finally { });
super.messageReceived(ctx, e);
}
} }
private String returnAllSettings() { private String returnAllSettings() {
......
...@@ -28,7 +28,7 @@ public class LootCommand extends Command { ...@@ -28,7 +28,7 @@ public class LootCommand extends Command {
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
execCommand(ctx, e, () -> { execCommand(ctx, e, () -> {
if (originalMessageParts.size() > 1) { if (originalMessageParts.size() > 1) {
player.getInventory().forEach(item -> { for (Item item : player.getInventory()) {
if (item.getItemTypeId() == Item.CORPSE_ID_RESERVED) { if (item.getItemTypeId() == Item.CORPSE_ID_RESERVED) {
Loot loot = item.getLoot(); Loot loot = item.getLoot();
if (loot != null) { if (loot != null) {
...@@ -38,18 +38,19 @@ public class LootCommand extends Command { ...@@ -38,18 +38,19 @@ public class LootCommand extends Command {
player.incrementGold(gold); player.incrementGold(gold);
} }
Set<Item> items = lootManager.lootItemsReturn(loot); Set<Item> items = lootManager.lootItemsReturn(loot);
items.forEach(i -> { for (Item i: items) {
gameManager.acquireItem(player, i.getItemId()); gameManager.acquireItem(player, i.getItemId());
write("You looted " + i.getItemName() + " from a " + item.getItemName() + ".\r\n"); write("You looted " + i.getItemName() + " from a " + item.getItemName() + ".\r\n");
}); }
if (gold < 0 && items.size() == 0) { if (gold < 0 && items.size() == 0) {
write("You looted nothing from " + item.getItemName() + "\r\n"); write("You looted nothing from " + item.getItemName() + "\r\n");
} }
} }
player.removeInventoryId(item.getItemId()); player.removeInventoryId(item.getItemId());
entityManager.removeItem(item); entityManager.removeItem(item);
return;
} }
}); }
} }
}); });
} }
......
...@@ -71,7 +71,7 @@ public class NpcTestHarness { ...@@ -71,7 +71,7 @@ public class NpcTestHarness {
int npcWins = 0; int npcWins = 0;
totalFightRounds = 0; totalFightRounds = 0;
int totalIterations = 100000; int totalIterations = 1000;
for (int i = 0; i < totalIterations; i++) { for (int i = 0; i < totalIterations; i++) {
String username = UUID.randomUUID().toString(); String username = UUID.randomUUID().toString();
Player player = createRandomPlayer(username); Player player = createRandomPlayer(username);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment