public BasePlayerItem[] GetItems(CharacterInventoryPositionEnum position) { return(( from entry in base.Items.Values where entry.Position == position select entry).ToArray <BasePlayerItem>()); }
/// <summary> /// Permet de déséquiper un item /// </summary> /// <param name="item"></param> /// <param name="quantity"></param> private void UnequipItem(CharacterItemRecord item, uint quantity) { if (item.PositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { CharacterItemRecord sameItem = GetSameItem(item.GId, item.Effects); CharacterInventoryPositionEnum lastPosition = item.PositionEnum; if (sameItem != null) { if (item.UId != sameItem.UId) { item.PositionEnum = CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED; sameItem.Quantity += quantity; sameItem.UpdateElement(); this.UpdateItemQuantity(sameItem); this.RemoveItem(item.UId, item.Quantity); } else { Character.ReplyError("Error while moving item"); } } else { item.PositionEnum = CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED; item.UpdateElement(); } OnItemMoved(item, lastPosition); } }
/// <summary> /// Appelée lorsque la position d'un item a été modifié /// </summary> /// <param name="item"></param> /// <param name="lastPosition"></param> private void OnItemMoved(CharacterItemRecord item, CharacterInventoryPositionEnum lastPosition) { bool flag = lastPosition != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED; bool flag2 = item.IsEquiped(); if (flag2 && !flag) { ItemEffectsProvider.AddEffects(Character, item.Effects); } if (!flag2 && flag) { ItemEffectsProvider.RemoveEffects(Character, item.Effects); } if (item.AppearanceId != 0) { UpdateLook(item, flag2); } if (item.Template.HasSet) // Si il y a une panoplie { int num = CountItemSetEquiped(item.Template.ItemSet); if (flag2) //Si on vient d'équiper l'objet { ApplyItemSetEffects(item.Template.ItemSet, num, flag2); } else { ApplyItemSetEffects(item.Template.ItemSet, num, flag2); } } }
/// <summary> /// Permet d'équiper un item /// </summary> /// <param name="item"></param> /// <param name="position"></param> /// <param name="quantity"></param> private void EquipItem(CharacterItemRecord item, CharacterInventoryPositionEnum position, uint quantity) { CharacterItemRecord equiped = GetEquipedItem(position); CharacterInventoryPositionEnum lastPosition = item.PositionEnum; if (equiped != null) { UnequipItem(equiped, quantity); OnObjectMoved(equiped, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); } if (item.Quantity == 1) { item.PositionEnum = position; } else { CharacterItemRecord newItem = item.Cut(quantity, position); AddItem(newItem); UpdateItemQuantity(item); } item.UpdateElement(); OnItemMoved(item, lastPosition); foreach (var item2 in GetEquipedItems()) { if (item != item2 && !CriteriaProvider.EvaluateCriterias(Character.Client, item2.Template.Criteria)) { SetItemPosition(item2.UId, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, item2.Quantity); } } }
public bool CanMove(Item item, CharacterInventoryPositionEnum position, int quantity) { if (Owner.IsFighting() && Owner.Fight.Phase != FightPhase.Placement) { return(false); } if (!HasItem(item)) { //logger.Error("Cannot move item {0} because the item is not own", item.Name); return(false); } if (quantity > item.Quantity) { //logger.Error("Cannot move item {0} because the moved quantity ({1}) is greater than the actual item quantity", item.Name, quantity, item.Quantity); return(false); } if (position != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && quantity != 1) { //logger.Error("Cannot equip item {0} because the moved quantity > 1", item.Name); return(false); } if (position != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && m_itemsPositioningRules.ContainsKey(item.SuperType) && !m_itemsPositioningRules[item.SuperType].Contains(position)) { //logger.Error("Cannot equip item {0} to {1} because the excepted position is {2}", item.Name, position, m_itemsPositioningRules[item.SuperType][0]); return(false); } return(true); }
/// <summary> /// A trouver = TextInformationMessage (Vous avez dus lacher votre arme a deux mains pour pouvoir équiper) /// </summary> /// <param name="position"></param> /// <param name="item"></param> public void CheckTwoHandeds(CharacterInventoryPositionEnum position, CharacterItemRecord item) { if (position == CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON) { if (WeaponRecord.GetWeapon(item.GId).TwoHanded) { CharacterItemRecord shield = GetEquipedItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD); if (shield != null) { UnequipItem(shield, shield.Quantity); OnObjectMoved(shield, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 79); } } } else if (position == CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD) { CharacterItemRecord weapon = GetEquipedItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON); if (weapon != null && WeaponRecord.GetWeapon(weapon.GId).TwoHanded) { UnequipItem(weapon, weapon.Quantity); OnObjectMoved(weapon, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 78); } } }
public void NotifyItemMoved(BasePlayerItem item, CharacterInventoryPositionEnum lastPosition) { this.OnItemMoved(item, lastPosition); Inventory.ItemMovedEventHandler itemMoved = this.ItemMoved; if (itemMoved != null) { itemMoved(this, item, lastPosition); } }
public bool Move(Item item, CharacterInventoryPositionEnum position, int quantity) { if (!CanMove(item, position, quantity)) { return(false); } Owner.Bot.SendToServer(new ObjectSetPositionMessage(item.Guid, (byte)position, quantity)); return(true); }
/// <summary> /// Verifie que deux items (Anneaux , Dofus) n'ont pas été équipée en même temps /// </summary> /// <param name="item"></param> /// <param name="position"></param> /// <param name="checker"></param> /// <returns></returns> bool CheckStacks(CharacterItemRecord item, CharacterInventoryPositionEnum position, CharacterInventoryPositionEnum[] checker) { foreach (CharacterInventoryPositionEnum pos in checker) { var current = GetEquipedItem(pos); if (current != null && current.GId == item.GId) { return(true); } } return(false); }
public CharacterItemRecord Cut(uint quantity, CharacterInventoryPositionEnum newItempos) { CharacterItemRecord newItem = (CharacterItemRecord)this.CloneWithoutUID(); this.PositionEnum = newItempos; this.Quantity = quantity; newItem.Quantity -= quantity; this.UpdateElement(); return(newItem); }
private void OnItemMoved(BasePlayerItem item, CharacterInventoryPositionEnum lastPosition) { m_itemsByPosition[lastPosition].Remove(item); m_itemsByPosition[item.Position].Add(item); var wasEquiped = lastPosition != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED; var isEquiped = item.IsEquiped(); if (wasEquiped && !isEquiped || !wasEquiped && isEquiped) { ApplyItemEffects(item, false); } if (!item.OnEquipItem(wasEquiped)) { return; } if (item.Template.ItemSet != null && !(wasEquiped && isEquiped)) { var count = CountItemSetEquiped(item.Template.ItemSet); if (count >= 0) { ApplyItemSetEffects(item.Template.ItemSet, count + (wasEquiped ? 1 : -1), false); } if (count > 0) { ApplyItemSetEffects(item.Template.ItemSet, count, true, false); } InventoryHandler.SendSetUpdateMessage(Owner.Client, item.Template.ItemSet); } if (lastPosition == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && !item.AreConditionFilled(Owner)) { BasicHandler.SendTextInformationMessage(Owner.Client, TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 19); MoveItem(item, lastPosition); } InventoryHandler.SendObjectMovementMessage(Owner.Client, item); InventoryHandler.SendInventoryWeightMessage(Owner.Client); if (isEquiped || wasEquiped) { CheckItemsCriterias(); } Owner.UpdateLook(item); Owner.RefreshStats(); }
public bool Unequip(CharacterInventoryPositionEnum position) { var item = GetEquipedItem(position); if (item != null) { SetItemPosition(item.UId, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, item.Quantity); return(true); } else { return(false); } }
private void OnItemMoved(BasePlayerItem item, CharacterInventoryPositionEnum lastPosition) { this.m_itemsByPosition[lastPosition].Remove(item); this.m_itemsByPosition[item.Position].Add(item); bool flag = lastPosition != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED; bool flag2 = item.IsEquiped(); if ((flag && !flag2) || (!flag && flag2)) { this.ApplyItemEffects(item, false); } if (item.OnEquipItem(flag)) { if (item.Template.ItemSet != null && (!flag || !flag2)) { int num = this.CountItemSetEquiped(item.Template.ItemSet); if (num >= 0) { this.ApplyItemSetEffects(item.Template.ItemSet, num + (flag ? 1 : -1), false, true); } if (num > 0) { this.ApplyItemSetEffects(item.Template.ItemSet, num, true, false); } InventoryHandler.SendSetUpdateMessage(this.Owner.Client, item.Template.ItemSet); } if (lastPosition == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && !item.AreConditionFilled(this.Owner)) { BasicHandler.SendTextInformationMessage(this.Owner.Client, TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 19); this.MoveItem(item, lastPosition); } InventoryHandler.SendObjectMovementMessage(this.Owner.Client, item); InventoryHandler.SendInventoryWeightMessage(this.Owner.Client); if (lastPosition != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { this.CheckItemsCriterias(); } if ((flag2 || flag) && item.AppearanceId != 0u) { this.Owner.UpdateLook(true); } this.Owner.RefreshActor(); this.Owner.RefreshStats(); } }
public void DissociateCompatibility(CharacterItemRecord item, CharacterInventoryPositionEnum pos) { EffectInteger effect = item.FirstEffect <EffectInteger>(EffectsEnum.Effect_ChangeApparence1176); if (effect != null) { AddItem(effect.Value, item.Quantity); if (item.PositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { UpdateItemAppearence(item, item.Template.AppearanceId); } else { item.AppearanceId = item.Template.AppearanceId; } item.RemoveAllEffects(EffectsEnum.Effect_ChangeApparence1176); if (item.PositionEnum == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { if (!CheckPassiveStacking(item)) { OnItemModified(item); } } else { OnItemModified(item); } RefreshWeight(); Character.RefreshActorOnMap(); Character.RefreshStats(); } }
public Item GetItem(CharacterInventoryPositionEnum position) { throw new NotImplementedException(); }
public Inventory(Character owner) { System.Collections.Generic.Dictionary <ItemSuperTypeEnum, CharacterInventoryPositionEnum[]> dictionary = new System.Collections.Generic.Dictionary <ItemSuperTypeEnum, CharacterInventoryPositionEnum[]>(); System.Collections.Generic.Dictionary <ItemSuperTypeEnum, CharacterInventoryPositionEnum[]> arg_167_0 = dictionary; ItemSuperTypeEnum arg_167_1 = ItemSuperTypeEnum.SUPERTYPE_AMULET; CharacterInventoryPositionEnum[] value = new CharacterInventoryPositionEnum[1]; arg_167_0.Add(arg_167_1, value); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_WEAPON, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_WEAPON_8, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_CAPE, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_CAPE }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_HAT, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_HAT }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_RING, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.INVENTORY_POSITION_RING_LEFT, CharacterInventoryPositionEnum.INVENTORY_POSITION_RING_RIGHT }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_BOOTS, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_BOOTS }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_BELT, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_BELT }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_PET, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_PETS }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_DOFUS, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.INVENTORY_POSITION_DOFUS_1, CharacterInventoryPositionEnum.INVENTORY_POSITION_DOFUS_2, CharacterInventoryPositionEnum.INVENTORY_POSITION_DOFUS_3, CharacterInventoryPositionEnum.INVENTORY_POSITION_DOFUS_4, CharacterInventoryPositionEnum.INVENTORY_POSITION_DOFUS_5, CharacterInventoryPositionEnum.INVENTORY_POSITION_DOFUS_6 }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_SHIELD, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD }); dictionary.Add(ItemSuperTypeEnum.SUPERTYPE_BOOST, new CharacterInventoryPositionEnum[] { CharacterInventoryPositionEnum.INVENTORY_POSITION_BOOST_FOOD }); this.m_itemsPositioningRules = dictionary; this.Owner = owner; this.InitializeEvents(); }
public static void ExoCommand(string value, WorldClient client) { if (!client.Character.Inventory.Exist(TokenId, ExoTokenQuantity)) { client.Character.Reply("Vous devez posséder " + ExoTokenQuantity + "x <b>[Ticket Doré]</b>"); return; } var splitted = value.Split(null); if (splitted.Count() < 2) { client.Character.Reply("indentifieur invalide, .exo [pa,pm,po] [anneau1,anneau2,coiffe,cape,ceinture,bottes,amulette]"); return; } string type = splitted[0]; string position = splitted[1]; EffectsEnum effect = 0; CharacterInventoryPositionEnum pos = CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED; switch (type) { case "pa": effect = EffectsEnum.Effect_AddAP_111; break; case "pm": effect = EffectsEnum.Effect_AddMP_128; break; case "po": effect = EffectsEnum.Effect_AddRange; break; default: client.Character.Reply("indentifieur invalide, .exo [pa,pm,po] [anneau1,anneau2,coiffe,cape,ceinture,bottes,amulette]"); return; } switch (position) { case "anneau1": pos = CharacterInventoryPositionEnum.INVENTORY_POSITION_RING_LEFT; break; case "anneau2": pos = CharacterInventoryPositionEnum.INVENTORY_POSITION_RING_RIGHT; break; case "coiffe": pos = CharacterInventoryPositionEnum.ACCESSORY_POSITION_HAT; break; case "cape": pos = CharacterInventoryPositionEnum.ACCESSORY_POSITION_CAPE; break; case "ceinture": pos = CharacterInventoryPositionEnum.ACCESSORY_POSITION_BELT; break; case "bottes": pos = CharacterInventoryPositionEnum.ACCESSORY_POSITION_BOOTS; break; case "amulette": pos = CharacterInventoryPositionEnum.ACCESSORY_POSITION_AMULET; break; default: client.Character.Reply("indentifieur invalide, .exo [pa,pm,po] [anneau1,anneau2,coiffe,cape,ceinture,bottes,amulette]"); break; } CharacterItemRecord item = client.Character.Inventory.GetEquipedItems().FirstOrDefault(x => x.PositionEnum == pos); if (item == null) { client.Character.Reply("Vous devez équiper un item a cet emplacement."); return; } if (item.FirstEffect <EffectInteger>(effect) != null) { client.Character.Reply("L'effet est déja présent..."); return; } client.Character.Inventory.SetItemPosition(item.UId, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, item.Quantity); var token = client.Character.Inventory.GetFirstItem(TokenId, ExoTokenQuantity); client.Character.Inventory.RemoveItem(token.UId, ExoTokenQuantity); item.AddEffectInteger(effect, 1); client.Character.Inventory.OnItemModified(item); client.Character.Reply("L'item a été exo."); client.Character.SpellAnim(2158); }
public void ChangeLivingObjectSkin(CharacterItemRecord item, ushort skinIndex, CharacterInventoryPositionEnum characterInventoryPositionEnum) { if (item.Quantity > 1) { return; } EffectInteger effect = item.FirstEffect <EffectInteger>(EffectsEnum.Effect_LivingObjectSkin); if (effect != null) { LivingObjectRecord record = LivingObjectRecord.IsLivingObject(item.GId) ? LivingObjectRecord.GetLivingObjectDatas(item.GId) : LivingObjectRecord.GetLivingObjectDatas(item.FirstEffect <EffectDice>(EffectsEnum.Effect_LivingObjectId).Const); if (record.Skinnable) { ushort skin = record.GetSkin(skinIndex); if (characterInventoryPositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { this.UpdateItemAppearence(item, skin); } else { item.AppearanceId = skin; } Character.RefreshActorOnMap(); } effect.Value = skinIndex; OnItemModified(item); RefreshWeight(); item.UpdateElement(); } else { Character.ReplyError("unable to modify item skin..he is not a valid living object."); } }
public bool HasItem(CharacterInventoryPositionEnum position) { return(Items.Any(x => x.Position == position)); }
/// <summary> /// Permet de définir la nouvelle position d'un item /// </summary> /// <param name="uid"></param> /// <param name="position"></param> /// <param name="quantity"></param> public void SetItemPosition(uint uid, CharacterInventoryPositionEnum position, uint quantity) { var item = GetItem(uid); if (item != null) { if (position != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { if (Character.Level < item.Template.Level) { OnError(ObjectErrorEnum.LEVEL_TOO_LOW); return; } if (!CriteriaProvider.EvaluateCriterias(Character.Client, item.Template.Criteria)) { OnError(ObjectErrorEnum.CRITERIONS); return; } if (DofusPositions.Contains((CharacterInventoryPositionEnum)item.Position) && DofusPositions.Contains(position)) { return; } if (CheckStacks(item, position, RingPositions) && item.Template.HasSet) { OnError(ObjectErrorEnum.CANNOT_EQUIP_HERE); return; } if (CheckStacks(item, position, DofusPositions)) { OnError(ObjectErrorEnum.CANNOT_EQUIP_HERE); return; } if (item.PositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { OnError(ObjectErrorEnum.CANNOT_EQUIP_HERE); return; } if (item.Template.TypeEnum == ItemTypeEnum.OBJET_VIVANT) { ItemTypeEnum livingObjectCategory = (ItemTypeEnum)(item.FirstEffect <EffectInteger>(EffectsEnum.Effect_LivingObjectCategory).Value); var targeted = GetEquipedItem(position); if (targeted == null) { OnLivingObjectEquipedDirectly(); return; } if (targeted.Template.TypeEnum != livingObjectCategory) { OnError(ObjectErrorEnum.SYMBIOTIC_OBJECT_ERROR); return; } if (targeted.IsAssociated) { OnError(ObjectErrorEnum.SYMBIOTIC_OBJECT_ERROR); return; } if (item.Quantity > 1) { CharacterItemRecord newItem = item.Cut(1, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); this.AssociateLiving(item, targeted); AddItem(newItem); UpdateItemQuantity(item); } else { this.AssociateLiving(item, targeted); } return; } if (item.Template.TypeEnum == ItemTypeEnum.OBJET_D_APPARAT) { var targeted = GetEquipedItem(position); if (targeted == null) { OnError(ObjectErrorEnum.CANNOT_EQUIP_HERE); return; } if (targeted.Template.TypeId != item.FirstEffect <EffectInteger>(EffectsEnum.Effect_Associate).Value) { return; } if (targeted.IsAssociated) { OnError(ObjectErrorEnum.SYMBIOTIC_OBJECT_ERROR); return; } if (item.Quantity > 1) { CharacterItemRecord newItem = item.Cut(1, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); this.AssociateCompatibility(item, targeted); AddItem(newItem); UpdateItemQuantity(item); } else { this.AssociateCompatibility(item, targeted); } return; } if (item.HasEffect <EffectMination>()) { EffectMination effect = item.FirstEffect <EffectMination>(); var monster = effect.GetTemplate(); var level = monster.GetGrade(effect.GradeId).Level; level = (ushort)(level > 200 ? 200 : level); if (level > Character.Level) { Character.Reply("Vous devez être niveau " + level + " pour équiper cette pierre."); return; } if (monster.IsBoss && Character.Level < 180) { Character.Reply("Vous devez être niveau 180 pour équiper un boss de donjon."); return; } if (monster.IsMiniBoss && Character.Level < 150) { Character.Reply("Vous devez être niveau 150 pour équiper un miniboss."); return; } Character.SpellAnim(6021); } if (item.Template.TypeEnum == ItemTypeEnum.MONTILIER || item.Template.TypeEnum == ItemTypeEnum.FAMILIER) { if (HasMountEquiped && Mount.Toggled) { ToggleMount(); } } this.CheckTwoHandeds(position, item); EquipItem(item, position, quantity); } else { if (item.PositionEnum == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { OnError(ObjectErrorEnum.CANNOT_EQUIP_HERE); return; } else { UnequipItem(item, quantity); } } OnObjectMoved(item, position); RefreshWeight(); Character.RefreshActorOnMap(); Character.RefreshStats(); } }
public BasePlayerItem TryGetItem(ItemTemplate template, System.Collections.Generic.IEnumerable <EffectBase> effects, CharacterInventoryPositionEnum position, BasePlayerItem except) { System.Collections.Generic.IEnumerable <BasePlayerItem> source = from entry in base.Items.Values where entry != except && entry.Template.Id == template.Id && entry.Position == position && effects.CompareEnumerable(entry.Effects) select entry; return(source.FirstOrDefault <BasePlayerItem>()); }
public BasePlayerItem TryGetItem(CharacterInventoryPositionEnum position) { return(base.Items.Values.FirstOrDefault((BasePlayerItem entry) => entry.Position == position)); }
public void MoveItem(BasePlayerItem item, CharacterInventoryPositionEnum position) { if (base.HasItem(item) && position != item.Position) { CharacterInventoryPositionEnum position2 = item.Position; BasePlayerItem basePlayerItem; if (position != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && (basePlayerItem = this.TryGetItem(position)) != null) { if (basePlayerItem.AllowFeeding) { if (basePlayerItem.Feed(item)) { this.RemoveItem(item, true); return; } return; } else { if (item.AllowDropping) { if (item.Drop(basePlayerItem)) { this.RemoveItem(item, true); return; } return; } else { if (this.CanEquip(item, position, false)) { this.MoveItem(basePlayerItem, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); } } } } if (this.CanEquip(item, position, true) && base.HasItem(item)) { if (position != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { this.UnEquipedDouble(item); } if (item.Stack > 1u) { this.CutItem(item, item.Stack - 1u); } item.Position = position; BasePlayerItem basePlayerItem2; if (position == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && this.IsStackable(item, out basePlayerItem2) && basePlayerItem2 != null) { this.NotifyItemMoved(item, position2); this.StackItem(basePlayerItem2, item.Stack); this.RemoveItem(item, true); } else { this.NotifyItemMoved(item, position2); } } } }
public bool CanEquip(BasePlayerItem item, CharacterInventoryPositionEnum position, bool send = true) { bool result; if (this.Owner.IsInFight() && this.Owner.Fight.State != FightState.Placement) { result = false; } else { if (position == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED) { result = true; } else { if (!this.GetItemPossiblePositions(item).Contains(position)) { result = false; } else { if (item.Template.Level > (uint)this.Owner.Level) { if (send) { BasicHandler.SendTextInformationMessage(this.Owner.Client, TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 3); } result = false; } else { BasePlayerItem basePlayerItem = this.TryGetItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON); if (item.Template.Type.ItemType == ItemTypeEnum.SHIELD && basePlayerItem != null && basePlayerItem.Template.TwoHanded) { if (send) { BasicHandler.SendTextInformationMessage(this.Owner.Client, TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 78); } result = false; } else { BasePlayerItem basePlayerItem2 = this.TryGetItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD); if (item.Template is WeaponTemplate && item.Template.TwoHanded && basePlayerItem2 != null) { if (send) { BasicHandler.SendTextInformationMessage(this.Owner.Client, TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 79); } result = false; } else { result = true; } } } } } } return(result); }
public bool Move(Item item, CharacterInventoryPositionEnum position) { throw new NotImplementedException(); }
public CharacterItemRecord GetItemByPosition(CharacterInventoryPositionEnum position) { return(Items.Find(x => x.Position == (byte)position)); }
/// <summary> /// Récupère un item équipé en fonction de sa position. /// </summary> /// <param name="position"></param> /// <returns></returns> private CharacterItemRecord GetEquipedItem(CharacterInventoryPositionEnum position) { return(GetItems().FirstOrDefault(x => x.PositionEnum == position)); }
public IEnumerable<Item> GetItems(CharacterInventoryPositionEnum position) { return m_items.Where(item => item.Position == position); }
public IEnumerable <Item> GetItems(CharacterInventoryPositionEnum position) { return(m_items.Where(item => item.Position == position)); }
public bool CanMove(Item item, CharacterInventoryPositionEnum position, int quantity) { if (Owner.IsFighting() && Owner.Fight.Phase != FightPhase.Placement) return false; if (!HasItem(item)) { //logger.Error("Cannot move item {0} because the item is not own", item.Name); return false; } if (quantity > item.Quantity) { //logger.Error("Cannot move item {0} because the moved quantity ({1}) is greater than the actual item quantity", item.Name, quantity, item.Quantity); return false; } if (position != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && quantity != 1) { //logger.Error("Cannot equip item {0} because the moved quantity > 1", item.Name); return false; } if (position != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && m_itemsPositioningRules.ContainsKey(item.SuperType) && !m_itemsPositioningRules[item.SuperType].Contains(position)) { //logger.Error("Cannot equip item {0} to {1} because the excepted position is {2}", item.Name, position, m_itemsPositioningRules[item.SuperType][0]); return false; } return true; }
public bool Move(Item item, CharacterInventoryPositionEnum position) { return(Move(item, position, item.Quantity)); }
public bool Move(Item item, CharacterInventoryPositionEnum position) { return Move(item, position, item.Quantity); }
public Item GetEquippedItem(CharacterInventoryPositionEnum position) { return(Items.FirstOrDefault(x => x.Position == position)); }
public bool Move(Item item, CharacterInventoryPositionEnum position, int quantity) { if (!CanMove(item, position, quantity)) return false; Owner.Bot.SendToServer(new ObjectSetPositionMessage(item.Guid, (byte)position, quantity)); return true; }
public bool HasItem(CharacterInventoryPositionEnum position) { return Items.Any(x => x.Position == position); }
public Item GetEquippedItem(CharacterInventoryPositionEnum position) { return Items.FirstOrDefault(x => x.Position == position); }