Browse Source

Itembase refactored out.

combat-2
MagicBot 9 months ago
parent
commit
266e4214d4
  1. 34
      src/engine/devcmd/cmds/MakeItemCmd.java

34
src/engine/devcmd/cmds/MakeItemCmd.java

@ -31,7 +31,9 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -31,7 +31,9 @@ public class MakeItemCmd extends AbstractDevCmd {
AbstractGameObject target) {
if (words[0].equals("resources")) {
for (int ibID : Warehouse.getMaxResources().keySet()) {
if (ibID == 7)
continue;
@ -41,7 +43,6 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -41,7 +43,6 @@ public class MakeItemCmd extends AbstractDevCmd {
if (!pc.getCharItemManager().hasRoomInventory(weight)) {
throwbackError(pc, "Not enough room in inventory for any more of this item");
pc.getCharItemManager().updateInventory();
return;
}
@ -102,16 +103,23 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -102,16 +103,23 @@ public class MakeItemCmd extends AbstractDevCmd {
numItems = (numItems > 5000) ? 5000 : numItems;
}
int itembaseID;
int templateID;
ItemTemplate template;
try {
itembaseID = Integer.parseInt(words[0]);
} catch (NumberFormatException e) {
itembaseID = ItemBase.getIDByName(words[0].toLowerCase());
if (itembaseID == 0) {
templateID = Integer.parseInt(words[0]);
template = ItemTemplate.itemTemplates.get(words[0].toLowerCase());
if (template == null) {
throwbackError(pc, "Supplied type " + words[0]
+ " failed to parse to an Integer");
return;
}
if (template.item_type == ItemType.GOLD) {
this.throwbackInfo(pc, "use /addgold to add gold.");
return;
}
} catch (Exception e) {
throwbackError(pc,
"An unknown exception occurred when trying to use createitem command for type "
@ -119,10 +127,6 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -119,10 +127,6 @@ public class MakeItemCmd extends AbstractDevCmd {
return; // NaN
}
if (itembaseID == 7) {
this.throwbackInfo(pc, "use /addgold to add gold.");
return;
}
String prefix = "";
String suffix = "";
@ -173,10 +177,10 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -173,10 +177,10 @@ public class MakeItemCmd extends AbstractDevCmd {
return;
}
}
ItemTemplate template = ItemTemplate.itemTemplates.get(itembaseID);
template = ItemTemplate.itemTemplates.get(templateID);
if (template == null) {
throwbackError(pc, "Unable to find itembase of ID " + itembaseID);
throwbackError(pc, "Unable to find itembase of ID " + templateID);
return;
}
@ -207,7 +211,7 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -207,7 +211,7 @@ public class MakeItemCmd extends AbstractDevCmd {
return;
}
Item item = new Item(itembaseID);
Item item = new Item(templateID);
item.ownerID = pc.getObjectUUID();
item.ownerType = OwnerType.PlayerCharacter;
@ -239,12 +243,12 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -239,12 +243,12 @@ public class MakeItemCmd extends AbstractDevCmd {
@Override
protected String _getHelpString() {
return "Creates an item of type 'itembaseID' with a prefix and suffix";
return "Creates an item of type templateID with a prefix and suffix";
}
@Override
protected String _getUsageString() {
return "'./makeitem itembaseID PrefixID SuffixID [quantity] [numResources]'";
return "'./makeitem templateID PrefixID SuffixID [quantity] [numResources]'";
}
}

Loading…
Cancel
Save