internal void ToGround(int itemID, string to, string from) { //Console.WriteLine("moveItem: Trying to move item: from Inventory " + from + " to ground " + to); Item item = null; int inventorySlot = ItemLocationInventory.GetInventorySlotId(from); if (inventorySlot < 0) { return; } else { item = player.GetEquipment(from); if (item == null) { return; } else { if (item.Id != itemID) { Console.WriteLine("ItemMove: The item id on slot: " + inventorySlot + " does not match with " + itemID); } } } Location toGameLocation = Location.Parse(to); moveItemToGround(item, inventorySlot, toGameLocation); return; }
internal void ToInventory(int itemID, string to, ItemLocationContainer containerLoc) { int toSlotId = ItemLocationInventory.GetInventorySlotId(to); if (toSlotId < 1) { //Console.WriteLine("moveItem: The inventory location: " + to + " is invalid."); return; } moveItemToInventory(containerLoc.item, containerLoc.Slot, containerLoc.ContainerIndex, toSlotId); }
public Item GetEquipment(string location) { int slotId = ItemLocationInventory.GetInventorySlotId(location); if (slotId < 1) { Console.WriteLine("| Inventory: location " + location + " not found"); return(null); } return(playerReader.GetInventoryItem((InventoryLocation)slotId)); }
internal void ToInventory(int itemID, string to, string from) { //Console.WriteLine("moveItem: Trying to move item: from ground " + from + " to inventory " + to); Location fromGameLocation = Location.Parse(from); int inventorySlot = ItemLocationInventory.GetInventorySlotId(to); if (inventorySlot < 0) { Console.WriteLine("moveItem: Invalid inventory slot: " + inventorySlot); return; } //should check the item id on ground //if ground item.id == itemID moveItemToInventory(fromGameLocation, inventorySlot); }
private Point findPointOfItem(int itemID) { ItemLocation itemLocation = game.FindItem(itemID); if (itemLocation == null) { return(new Point(-1, -1)); } if (itemLocation.GetType() == typeof(ItemLocationContainer)) { ItemLocationContainer containerLoc = (ItemLocationContainer)itemLocation; return(client.ContainerPosition(containerLoc.Slot, containerLoc.ContainerIndex)); } if (itemLocation.GetType() == typeof(ItemLocationInventory)) { ItemLocationInventory inventoryLoc = (ItemLocationInventory)itemLocation; return(client.InventoryPosition(inventoryLoc.SlotId)); } return(new Point(-1, -1)); }
public ItemLocationInventory FindItemOnInventory(int itemId) { //search on inventory int first = (int)InventoryLocation.Head; //Console.WriteLine("First slot: " + first); int last = (int)InventoryLocation.Belt; //Console.WriteLine("Last slot: " + last); for (int i = first; i <= last; i++) { //Console.WriteLine("Asking for player for the item on slot: " + i); string slotName = ItemLocationInventory.GetInventorySlotName(i); Item item = player.GetEquipment(slotName); if (item != null) { if (item.Id == itemId) { return(new ItemLocationInventory(item, i, slotName)); } } } return(null); }
internal void ToContainer(int itemID, string to, string from) { //Console.WriteLine("moveItem: Trying to move item: from Inventory " + from + " to container " + to); Item item = null; int inventorySlot = ItemLocationInventory.GetInventorySlotId(from); if (inventorySlot < 0) { return; } else { item = player.GetEquipment(from); if (item == null) { return; } else { if (item.Id != itemID) { Console.WriteLine("ItemMove: The item id on slot: " + inventorySlot + " does not match with " + itemID); } } } Container destination = game.GetContainer(Convert.ToInt32(to)); if (destination == null) { Console.WriteLine("moveItem: Could not found a container with index: " + to); return; } moveItemToContainer(item, inventorySlot, destination); }
internal void ToInventory(int itemID, string to, string from) { //Console.WriteLine("moveItem: Trying to move item: from Inventory " + from + " to Inventory " + to); Item item = null; int fromSlot = ItemLocationInventory.GetInventorySlotId(from); if (fromSlot < 0) { return; } else { item = player.GetEquipment(from); if (item == null) { return; } else { if (item.Id != itemID) { Console.WriteLine("ItemMove: The item id on slot: " + fromSlot + " does not match with " + itemID); } } } int toSlot = ItemLocationInventory.GetInventorySlotId(to); if (toSlot < 0) { Console.WriteLine("ItemMove: Invalid slot location " + to); return; } moveItemToInventory(item, fromSlot, toSlot); }
public List <Item> FindItems(int itemId, string location) { if (ItemLocation.IsContainer(location)) { return(findItemsOnContainer(itemId, location)); } if (ItemLocation.IsInventory(location)) { ItemLocationInventory invLocation = this.FindItemOnInventory(itemId); if (invLocation == null) { return(new List <Item>()); } return(new List <Item>() { invLocation.item }); } //no location return(findItemOnAllContainers(itemId)); }
internal void MoveItems(int itemId, string to, string from) { ItemLocationContainer locationContainer = null; ItemLocationInventory locationInventory = null; if (string.IsNullOrEmpty(from)) { ItemLocation itemLocation = game.FindItem(itemId); if (itemLocation != null && itemLocation.GetType() == typeof(ItemLocationContainer)) { locationContainer = (ItemLocationContainer)itemLocation; from = "" + locationContainer.ContainerIndex; } else if (itemLocation != null && itemLocation.GetType() == typeof(ItemLocationInventory)) { locationInventory = (ItemLocationInventory)itemLocation; from = locationInventory.SlotName; } else { Console.WriteLine("MoveItems not found item: " + itemId); } } //from container if (ItemLocation.IsContainer(from)) { if (locationContainer == null) { //Console.WriteLine("moveItem: Trying to move item: from container " + from + " to: " + to); int containerIndex = ItemLocationContainer.GetContainerIndex(from); if (containerIndex < 0) { Console.WriteLine("moveItem: Invalid container index"); return; } locationContainer = game.FindItemOnContainers(itemId, containerIndex); if (locationContainer == null) { Console.WriteLine("moveItem: Item " + itemId + " not found on container index: " + containerIndex); return; } } //container to container if (ItemLocation.IsContainer(to)) { fromContainer.ToContainer(itemId, to, locationContainer); return; } //container to inventory if (ItemLocation.IsInventory(to)) { fromContainer.ToInventory(itemId, to, locationContainer); return; } //container to ground if (ItemLocation.IsGround(to)) { fromContainer.ToGround(itemId, to, locationContainer); return; } } //from inventory if (ItemLocation.IsInventory(from)) { //inventory to inventory if (ItemLocation.IsInventory(to)) { fromInventory.ToInventory(itemId, to, from); return; } //inventory to container if (ItemLocation.IsContainer(to)) { fromInventory.ToContainer(itemId, to, from); return; } //inventory to ground if (ItemLocation.IsGround(to)) { fromInventory.ToGround(itemId, to, from); return; } } //from ground if (ItemLocation.IsGround(from)) { //ground to ground if (ItemLocation.IsGround(to)) { fromGround.ToGround(itemId, to, from); return; } //ground to container if (ItemLocation.IsContainer(to)) { fromGround.ToContainer(itemId, to, from); return; } //ground to inventory if (ItemLocation.IsInventory(to)) { fromGround.ToInventory(itemId, to, from); return; } } Console.WriteLine("Item move: Invalid location: " + from + " " + to); }