Start mobequip refactor

This commit is contained in:
2024-03-18 10:01:29 -04:00
parent 0590ae64e7
commit 61c4cb1361
56 changed files with 198 additions and 377 deletions
@@ -97,7 +97,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
ArrayList<Item> sellInventory = null;
if (npc != null) {
man = npc.getCharItemManager();
man = npc.charItemManager;
Contract contract = npc.getContract();
if (player != null) {
float barget = player.getBargain();
@@ -149,7 +149,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
for (Item Item : sellInventory) {
try {
Item.serializeForVendor(Item, writer, sellPercent);
Item._serializeForVendor(Item, writer, sellPercent);
} catch (SerializationException se) {
continue;
}
+1 -1
View File
@@ -81,7 +81,7 @@ public class LootMsg extends ClientNetMsg {
else if (this.Item != null)
try {
Item._serializeForClientMsg(this.Item, writer, false);
} catch (SerializationException e) {
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+1 -1
View File
@@ -82,7 +82,7 @@ public class RefineMsg extends ClientNetMsg {
//update player
pc.applyBonuses();
pc.getCharItemManager().RemoveEquipmentFromLackOfSkill(pc, true);
pc.charItemManager.RemoveEquipmentFromLackOfSkill(pc, true);
//echo refine message back
@@ -57,7 +57,7 @@ public class ShowBankInventoryMsg extends ClientNetMsg {
@Override
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
ArrayList<Item> bank = pc.getCharItemManager().getBank();
ArrayList<Item> bank = pc.charItemManager.getBank();
writer.put((byte) 1); // static value
Item.putList(writer, bank, false, pc.getObjectUUID());
+8 -8
View File
@@ -72,12 +72,12 @@ public class TrainMsg extends ClientNetMsg {
if (origin.trainLock.tryLock()) {
try {
Item gold = playerCharacter.getCharItemManager().getGoldInventory();
Item gold = playerCharacter.charItemManager.getGoldInventory();
if (gold == null)
return;
if (!gold.validForInventory(origin, playerCharacter, playerCharacter.getCharItemManager()))
if (!gold.validForInventory(origin, playerCharacter, playerCharacter.charItemManager))
return;
boolean canTrain = false;
@@ -190,7 +190,7 @@ public class TrainMsg extends ClientNetMsg {
float profitCost = cost * npc.getSellPercent(playerCharacter);
profitCost += .5f;
if (profitCost > playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems())
if (profitCost > playerCharacter.charItemManager.getGoldInventory().getNumOfItems())
return;
Building b = npc.getBuilding();
if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
@@ -201,16 +201,16 @@ public class TrainMsg extends ClientNetMsg {
return;
}
if (playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems() - profitCost < 0)
if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() - profitCost < 0)
return;
if (playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems() - profitCost > MBServerStatics.PLAYER_GOLD_LIMIT)
if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() - profitCost > MBServerStatics.PLAYER_GOLD_LIMIT)
return;
//attempt to train
if (sk.train(playerCharacter)) {
playerCharacter.getCharItemManager().buyFromNPC(b, (int) profitCost, (int) (profitCost - cost));
playerCharacter.charItemManager.buyFromNPC(b, (int) profitCost, (int) (profitCost - cost));
dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
@@ -253,7 +253,7 @@ public class TrainMsg extends ClientNetMsg {
float cost = (int) cp.getTrainingCost(playerCharacter, npc);
float profitCost = cost * npc.getSellPercent(playerCharacter);
profitCost += .5f;
if (profitCost > playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems()) {
if (profitCost > playerCharacter.charItemManager.getGoldInventory().getNumOfItems()) {
// ChatManager.chatSystemError(pc, "You do not have enough gold to train this skill.");
return;
}
@@ -269,7 +269,7 @@ public class TrainMsg extends ClientNetMsg {
}
if (cp.train(playerCharacter)) {
if (!playerCharacter.getCharItemManager().buyFromNPC(b, (int) profitCost, (int) (profitCost - cost)))
if (!playerCharacter.charItemManager.buyFromNPC(b, (int) profitCost, (int) (profitCost - cost)))
ChatManager.chatSystemError(playerCharacter, "Failed to Withdrawl gold from inventory. Contact CCR");
//train succeeded
+2 -5
View File
@@ -15,10 +15,7 @@ import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.client.Protocol;
import engine.objects.AbstractWorldObject;
import engine.objects.CharacterItemManager;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
import engine.objects.*;
/**
* Update gold in inventory and/or bank
@@ -76,7 +73,7 @@ public class UpdateGoldMsg extends ClientNetMsg {
public void configure() {
if (this.looter != null && this.looter.getObjectType() == GameObjectType.PlayerCharacter) {
itemManager = ((PlayerCharacter) looter).getCharItemManager();
itemManager = ((PlayerCharacter) looter).charItemManager;
goldInventory = itemManager.getGoldInventory();
this.tradeGold = itemManager.getGoldTrading();
goldBank = itemManager.getGoldBank();
@@ -63,7 +63,7 @@ public class UpdateTradeWindowMsg extends ClientNetMsg {
ArrayList<Item> trading1 = new ArrayList<>();
for (int itemID : pc1.getCharItemManager().getTrading()) {
for (int itemID : pc1.charItemManager.getTrading()) {
Item item = Item.getFromCache(itemID);
if (item == null)
continue;
@@ -71,7 +71,7 @@ public class UpdateTradeWindowMsg extends ClientNetMsg {
}
ArrayList<Item> trading2 = new ArrayList<>();
for (int itemID : pc2.getCharItemManager().getTrading()) {
for (int itemID : pc2.charItemManager.getTrading()) {
Item item = Item.getFromCache(itemID);
if (item == null)
continue;
@@ -607,7 +607,7 @@ public class VendorDialogMsg extends ClientNetMsg {
if (ac == null)
return;
CharacterItemManager itemManager = playerCharacter.getCharItemManager();
CharacterItemManager itemManager = playerCharacter.charItemManager;
if (itemManager == null)
return;
@@ -660,7 +660,7 @@ public class VendorDialogMsg extends ClientNetMsg {
if (cc == null)
return;
CharacterItemManager itemManager = playerCharacter.getCharItemManager();
CharacterItemManager itemManager = playerCharacter.charItemManager;
if (itemManager == null)
return;