public void CreateStackOnASpecificItem() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); Inventory.AddItemToPocket(ItemInstance.Create(1013, 0, 990)); Inventory.AddItemToPocket(ItemInstance.Create(1013, 0)); Assert.IsTrue(Inventory.Values.First(item => item.Slot == 1).Amount == 991); }
public void MoveWeaponToPocket() { var weapon = Inventory.AddItemToPocket(ItemInstance.Create(1, 0)).First(); var item = Inventory.MoveInPocket(weapon.Slot, weapon.Type, PocketType.Wear); Assert.IsTrue(item.Type == PocketType.Wear); }
public void MoveFashionToSpecialistPocket() { var fashion = Inventory.AddItemToPocket(ItemInstance.Create(924, 0)).First(); var item = Inventory.MoveInPocket(fashion.Slot, fashion.Type, PocketType.Specialist); Assert.IsNull(item); }
public void MoveSpecialistToFashionPocket() { var specialist = Inventory.AddItemToPocket(ItemInstance.Create(912, 0)).First(); var item = Inventory.MoveInPocket(specialist.Slot, specialist.Type, PocketType.Costume); Assert.IsNull(item); }
public void CreateItemWhenSlotFilled() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); var items = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 29)); Assert.IsTrue(items.First().Amount == 999 && items.Last().Amount == 20); }
public void MoveFashionToFashionPocket() { var fashion = Inventory.AddItemToPocket(ItemInstance.Create(924, 0)).First(); var item = Inventory.MoveInPocket(fashion.Slot, fashion.Type, PocketType.Costume); Assert.IsTrue(item.Type == PocketType.Costume); }
public void CreateItemWhenSlotMax() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 999)); var items = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0)); Assert.IsTrue(items.First().Amount == 1); }
public void LoadAnNonExistingItem() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); var item = Inventory.LoadBySlotAndType <ItemInstance>(1, PocketType.Main); Assert.IsNull(item); }
public void LoadItemOnAnNotEmptySlot() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); var item = Inventory.LoadBySlotAndType <ItemInstance>(0, PocketType.Main); Assert.IsTrue(item.ItemVNum == 1012 && item.Amount == 990); }
public void CreateDoesntStackOnWrontItem() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); Inventory.AddItemToPocket(ItemInstance.Create(1013, 0, 990)); Inventory.AddItemToPocket(ItemInstance.Create(1013, 0, 19)); Assert.IsTrue(Inventory.Values.First(item => item.Slot == 0).Amount == 990); }
public void CreateItemAndStackIt() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0)); var item = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0)).First(); Assert.IsTrue(item.Amount == 2 && item.ItemVNum == 1012); }
public void MoveSpecialistToSpecialistPocket() { var specialist = Inventory.AddItemToPocket(ItemInstance.Create(912, 0)).First(); var item = Inventory.MoveInPocket(specialist.Slot, specialist.Type, PocketType.Specialist); Assert.IsTrue(item.Type == PocketType.Specialist); }
public void MoveHalfSlot() { var item = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 999)).First(); Inventory.MoveItem(item.Type, item.Slot, 499, 1, out var originItem, out var destinationItem); Assert.IsTrue(originItem?.Amount == 500 && originItem.Slot == 0); Assert.IsTrue(destinationItem?.Amount == 499 && destinationItem.Slot == 1); }
public void CreateMoreItemThanInventoryPlace() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990), slot: 0); Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990), slot: 1); Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990), slot: 2); var items = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 99)); Assert.IsTrue(Inventory.Values.All(item => item.Amount == 990) && items.Count == 0); }
public void CreateItemAndFillMultiSlot() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990), slot: 0); Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990), slot: 1); Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990), slot: 2); var items = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 27)); Assert.IsTrue(items.All(item => item.Amount == 999) && items.Count == 3); }
public void DeleteFromTypeAndSlot() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); Assert.IsTrue(Inventory.Count == 2); var item = Inventory.DeleteFromTypeAndSlot(PocketType.Main, 0); Assert.IsNotNull(item); Assert.IsTrue(Inventory.Count == 1); }
public void Delete() { Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); var items = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0, 990)); Assert.IsTrue(Inventory.Count == 2); var item = Inventory.DeleteById(items.First().Id); Assert.IsNotNull(item); Assert.IsTrue(Inventory.Count == 1); }
private void OnItemPlaced(object sender, ItemEventArgs args) { GameObject itemGameObject = ItemInstance.Create(args.Item, itemParent); itemGameObject.transform.localScale = new Vector3(0.5f, 0.5f, 1); itemGameObjects.Add(args.Item, itemGameObject); SpriteRenderer spriteRenderer = itemGameObject.GetComponent <SpriteRenderer>(); spriteRenderer.sprite = SpriteManager.Get("Item", args.Item.Type); spriteRenderer.sortingLayerName = "Item"; args.Item.Changed += OnItemChanged; }
private ItemInstance getHeroAvatarItemInstance(Player player, ItemType itemType, Dictionary <ItemType, string> itemOverrides) { ItemInstance instance = player.ActiveCharacter.getEquippedItemOfType(itemType); if (!itemOverrides.ContainsKey(itemType)) { return(instance); } string str = itemOverrides[itemType]; if (string.IsNullOrEmpty(str)) { return(instance); } if (!GameLogic.Binder.ItemResources.containsResource(str)) { return(instance); } return(ItemInstance.Create(GameLogic.Binder.ItemResources.getResource(str), player, -1)); }
public void CreateItem(CreateItemPacket createItemPacket) { if (createItemPacket != null) { var vnum = createItemPacket.VNum; sbyte rare = 0; short boxEffect = 999; byte upgrade = 0, design = 0; short amount = 1; if (vnum == 1046) { return; // cannot create gold as item, use $Gold instead } var iteminfo = ServerManager.Instance.Items.Find(item => item.VNum == vnum); if (iteminfo != null) { if (iteminfo.IsColored || iteminfo.Effect == boxEffect) { if (createItemPacket.DesignOrAmount.HasValue) { design = (byte)createItemPacket.DesignOrAmount.Value; } rare = createItemPacket.Upgrade.HasValue && iteminfo.Effect == boxEffect ? (sbyte)createItemPacket.Upgrade.Value : rare; } else if (iteminfo.Type == PocketType.Equipment) { if (createItemPacket.Upgrade.HasValue) { if (iteminfo.EquipmentSlot != EquipmentType.Sp) { upgrade = createItemPacket.Upgrade.Value; } else { design = createItemPacket.Upgrade.Value; } if (iteminfo.EquipmentSlot != EquipmentType.Sp && upgrade == 0 && iteminfo.BasicUpgrade != 0) { upgrade = iteminfo.BasicUpgrade; } } if (createItemPacket.DesignOrAmount.HasValue) { if (iteminfo.EquipmentSlot == EquipmentType.Sp) { upgrade = (byte)createItemPacket.DesignOrAmount.Value; } else { rare = (sbyte)createItemPacket.DesignOrAmount.Value; } } } if (createItemPacket.DesignOrAmount.HasValue && !createItemPacket.Upgrade.HasValue) { amount = createItemPacket.DesignOrAmount.Value > _worldConfiguration.MaxItemAmount ? _worldConfiguration.MaxItemAmount : createItemPacket.DesignOrAmount.Value; } var inv = Session.Character.Inventory.AddItemToPocket(ItemInstance.Create(vnum, Session.Character.CharacterId, amount: amount, rare: rare, upgrade: upgrade, design: design)); if (inv.Count > 0) { Session.SendPacket(inv.GeneratePocketChange()); var firstItem = inv.First(); var wearable = Session.Character.Inventory.LoadBySlotAndType <WearableInstance>(firstItem.Slot, firstItem.Type); if (wearable != null) { switch (wearable.Item.EquipmentSlot) { case EquipmentType.Armor: case EquipmentType.MainWeapon: case EquipmentType.SecondaryWeapon: wearable.SetRarityPoint(); break; case EquipmentType.Boots: case EquipmentType.Gloves: wearable.FireResistance = (short)(wearable.Item.FireResistance * upgrade); wearable.DarkResistance = (short)(wearable.Item.DarkResistance * upgrade); wearable.LightResistance = (short)(wearable.Item.LightResistance * upgrade); wearable.WaterResistance = (short)(wearable.Item.WaterResistance * upgrade); break; } } Session.SendPacket(Session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey(LanguageKey.ITEM_ACQUIRED, Session.Account.Language)}: {iteminfo.Name} x {amount}", SayColorType.Green)); } else { Session.SendPacket(new MsgPacket() { Message = Language.Instance.GetMessageFromKey(LanguageKey.NOT_ENOUGH_PLACE, Session.Account.Language), Type = 0 }); } } else { Session.SendPacket(new MsgPacket() { Message = Language.Instance.GetMessageFromKey(LanguageKey.NO_ITEM, Session.Account.Language), Type = 0 }); } } else { Session.SendPacket(Session.Character.GenerateSay(CreateItemPacket.ReturnHelp(), SayColorType.Yellow)); } }
public static ItemInstance CreateNewMysteryItemInstance(Player player, string shopEntryId) { return(ItemInstance.Create(GetRandomMysteryItem(player, shopEntryId), player, -1)); }
public void CreateItem() { var item = Inventory.AddItemToPocket(ItemInstance.Create(1012, 0)).First(); Assert.IsTrue(item.Amount == 1 && item.ItemVNum == 1012 && item.Type == PocketType.Main); }