Add ./fillwarehouse dev command
Sets every resource in the warehouse of the city the player stands in, either to an optional amount or, by default, to each resource's deposit limit. Makes forge and work order testing practical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ac522a2e0
commit
c616afa33b
2 files changed
+98
No files matched your search
@@ -0,0 +1,97 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2026
|
||||
// https://www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.mbEnums;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.City;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Warehouse;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class FillWarehouseCmd extends AbstractDevCmd {
|
||||
|
||||
public FillWarehouseCmd() {
|
||||
super("fillwarehouse");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
City city;
|
||||
Warehouse warehouse;
|
||||
int amount = Integer.MAX_VALUE;
|
||||
HashMap<mbEnums.ResourceType, Integer> oldResources;
|
||||
|
||||
if (words.length > 1) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (words.length == 1 && !words[0].isEmpty()) {
|
||||
try {
|
||||
amount = Integer.parseInt(words[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
throwbackError(pc, "Amount must be a number, " + words[0] + " is invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount < 0) {
|
||||
throwbackError(pc, "Amount must be 0 or more");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
city = ZoneManager.getCityAtLocation(pc.getLoc());
|
||||
|
||||
if (city == null) {
|
||||
throwbackError(pc, "You are not standing in a city");
|
||||
return;
|
||||
}
|
||||
|
||||
warehouse = city.warehouse;
|
||||
|
||||
if (warehouse == null) {
|
||||
throwbackError(pc, city.getCityName() + " has no warehouse");
|
||||
return;
|
||||
}
|
||||
|
||||
oldResources = new HashMap<>(warehouse.resources);
|
||||
|
||||
for (mbEnums.ResourceType resourceType : mbEnums.ResourceType.values())
|
||||
warehouse.resources.put(resourceType, Math.min(amount, resourceType.deposit_limit));
|
||||
|
||||
if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) {
|
||||
warehouse.resources.putAll(oldResources);
|
||||
throwbackError(pc, "Failed to update the warehouse in the database");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.chatSayInfo(pc, "Filled the " + city.getCityName() + " warehouse"
|
||||
+ (amount == Integer.MAX_VALUE ? " to each deposit limit" : " with " + amount + " of each resource (capped at the deposit limit)"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets every resource in the warehouse of the city you are standing in";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' ./fillwarehouse [amount]' (no amount fills each resource to its deposit limit)";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,6 +101,7 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
|
||||
DevCmdManager.registerDevCmd(new SetInvulCmd());
|
||||
DevCmdManager.registerDevCmd(new MakeItemCmd());
|
||||
DevCmdManager.registerDevCmd(new FillWarehouseCmd());
|
||||
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
|
||||
// Admin
|
||||
|
||||
|
||||
Reference in new issue
Block a user