Dev commands, BuildingManager, ChatManager, ForgeManager, NPCManager, NPC, Warehouse, WorkOrder and ManageNPCMsg now call CObjectTemplate.lookup instead of ItemTemplate.templates.get. Forge production cost reads getItemResourceCosts(). Only the DB loader and linkCacheTemplates still use the legacy class (removed in Task 1.8). Removes the static_item_templates ParityCheck comparator. Final parity (offline p17.py, 7586 rows): every id has a cache template, 0 item_type differences, 0 item_resource_costs differences (84 ITEMs have costs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
4.2 KiB
Java
116 lines
4.2 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
|
|
package engine.devcmd.cmds;
|
|
|
|
import engine.devcmd.AbstractDevCmd;
|
|
import engine.mbEnums.ItemType;
|
|
import engine.objects.*;
|
|
import engine.parsers.objects.CObjectTemplate;
|
|
|
|
import java.text.DecimalFormat;
|
|
import java.util.ArrayList;
|
|
|
|
public class PrintInventoryCmd extends AbstractDevCmd {
|
|
|
|
public PrintInventoryCmd() {
|
|
super("printinventory");
|
|
}
|
|
|
|
@Override
|
|
protected void _doCmd(PlayerCharacter pc, String[] words,
|
|
AbstractGameObject target) {
|
|
|
|
if (target == null || (!(target instanceof AbstractCharacter) && !(target instanceof Corpse))) {
|
|
target = pc;
|
|
}
|
|
|
|
|
|
String type = target.getClass().getSimpleName();
|
|
String name = "";
|
|
ArrayList<Item> inventory = null;
|
|
Item gold = null;
|
|
DecimalFormat df = new DecimalFormat("###,###,###,##0");
|
|
|
|
if (target instanceof AbstractCharacter) {
|
|
AbstractCharacter tar = (AbstractCharacter) target;
|
|
|
|
name = tar.getFirstName();
|
|
|
|
if (tar instanceof Mob) {
|
|
Mob mob = (Mob) tar;
|
|
MobBase mb = mob.getMobBase();
|
|
if (mb != null) {
|
|
name = mb.getFirstName();
|
|
}
|
|
} else if (tar instanceof NPC) {
|
|
NPC npc = (NPC) tar;
|
|
Contract contract = npc.getContract();
|
|
if (contract != null) {
|
|
if (contract.isTrainer()) {
|
|
name = tar.getName() + ", " + contract.getName();
|
|
} else {
|
|
name = tar.getName() + " the " + contract.getName();
|
|
}
|
|
}
|
|
}
|
|
|
|
CharacterItemManager cim = tar.charItemManager;
|
|
inventory = cim.getInventory(); //this list can contain gold when tar is a PC that is dead
|
|
gold = cim.getGoldInventory();
|
|
throwbackInfo(pc, " Weight : " + (cim.getInventoryWeight() + cim.getEquipWeight()));
|
|
} else if (target instanceof Corpse) {
|
|
Corpse corpse = (Corpse) target;
|
|
name = "of " + corpse.getName();
|
|
inventory = corpse.getInventory();
|
|
}
|
|
|
|
throwbackInfo(pc, "Inventory for " + type + ' ' + name + " (" + target.getObjectUUID() + ')');
|
|
|
|
int goldCount = 0;
|
|
|
|
for (Item item : inventory) {
|
|
CObjectTemplate template = CObjectTemplate.lookup(item.templateID);
|
|
|
|
if (item.template.getItemType().equals(ItemType.GOLD) == false) {
|
|
|
|
String chargeInfo = "";
|
|
int chargeMax = template.getItemInitialCharges();
|
|
|
|
if (chargeMax > 0) {
|
|
int charges = item.chargesRemaining;
|
|
chargeInfo = " charges: " + charges + '/' + chargeMax;
|
|
}
|
|
throwbackInfo(pc, " " + template.getItemBaseName() + ", count: " + item.getNumOfItems() + chargeInfo);
|
|
} else
|
|
goldCount += item.getNumOfItems();
|
|
}
|
|
if (gold != null) {
|
|
goldCount += gold.getNumOfItems();
|
|
}
|
|
|
|
if (goldCount > 0 || gold != null) {
|
|
throwbackInfo(pc, " Gold, count: " + df.format(goldCount));
|
|
} else {
|
|
throwbackInfo(pc, " NULL Gold");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected String _getHelpString() {
|
|
return "Returns the player's current inventory";
|
|
}
|
|
|
|
@Override
|
|
protected String _getUsageString() {
|
|
return "' /printinventory'";
|
|
}
|
|
|
|
}
|