Exemplo n.º 1
0
		internal void NotifyCreated(ItemRecord record)
		{
			OnRecordCreated(record);
			var evt = Created;
			if (evt != null)
			{
				evt(record);
			}
		}
Exemplo n.º 2
0
        private void LogItemEvent(GuildBankLogEntryType type, Character actor, ItemRecord record, int amount, GuildBankTab intoTab)
        {
            var entry = new GuildBankLogEntry(Bank.Guild.Id)
            {
                Type           = type,
                Actor          = actor,
                BankLog        = this,
                DestinationTab = intoTab,
                ItemEntryId    = (int)record.EntryId,
                ItemStackCount = (int)amount,
                Created        = DateTime.Now
            };

            lock (moneyLogEntries)
            {
                moneyLogEntries.Insert(entry);
            }
        }
Exemplo n.º 3
0
        private static void RemoveDrop(WorldClient client, string[] args)
        {
            if (args.Length < 2)
            {
                client.Character.Reply("Remove a drop from a monster");
                client.Character.Reply("» .drops rmdrop|rm|rd $ItemId $MonsterId");
                client.Character.Reply("- <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply("- <b>$MonsterId</b> ⇒ The ID of the monster.");
                return;
            }

            ushort     itemId = ushort.Parse(args[1]);
            ItemRecord item   = ItemRecord.GetItem(itemId);

            if (args.Length != 3)
            {
                int count = 0;
                foreach (MonsterRecord monster in MonsterRecord.Monsters)
                {
                    MonsterDrop drop = monster.Drops.Find(d => d.ItemId == itemId);
                    if (drop != null)
                    {
                        monster.Drops.Remove(drop);
                        count++;
                        client.Character.Reply($" - Removed drop from monster {monster.Name} ({monster.Id}).");

                        monster.UpdateInstantElement();
                    }
                }

                client.Character.Reply($"Removed drop '{item.Name}' ({item.Id}) from {count} monsters.");
            }
            else
            {
                ushort monsterId = ushort.Parse(args[2]);

                MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId);
                monsterRecord.Drops.RemoveAll(d => d.ItemId == itemId);

                monsterRecord.UpdateInstantElement();

                client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new Item
        /// </summary>
        internal void InitItem(ItemTemplate template, Character owner, int amount)
        {
            m_record = ItemRecord.CreateRecord();

            EntryId = m_record.EntryId = template.Id;

            Type |= ObjectTypes.Item;

            m_template = template;

            Durability      = m_template.MaxDurability;
            MaxDurability   = m_template.MaxDurability;
            Flags           = m_template.Flags;
            TextId          = m_template.PageTextId;
            Amount          = amount;
            OwningCharacter = owner;
            EntityId        = m_record.EntityId;

            // set charges to max
            if (m_template.UseSpell != null && m_template.UseSpell.HasCharges)
            {
                m_record.Charges = m_template.UseSpell.Charges;
                SetSpellCharges(m_template.UseSpell.Index, m_template.UseSpell.Charges);
            }

            var randomEnchants = m_template.RandomPrefixes;

            if (randomEnchants != null)
            {
                ApplyRandomEnchants(randomEnchants, EnchantSlot.PropSlot2, EnchantSlot.PropSlot4);
            }
            randomEnchants = m_template.RandomSuffixes;
            if (randomEnchants != null)
            {
                if (ApplyRandomEnchants(randomEnchants, EnchantSlot.PropSlot0, EnchantSlot.PropSlot2))
                {
                    RandomPropertiesId = m_enchantments[(int)EnchantSlot.PropSlot0].Entry.Id;
                }
            }

            template.NotifyCreated(m_record);
            OnInit();
        }
    public void Initialize(ItemRecord item, int quantity, Action unityAction)
    {
        this.item = item;
        Quantity  = quantity;

        image.sprite = item.Icon;
        text.text    = quantity.ToString();

        onClick = unityAction;

        if (quantity < 2)
        {
            text.gameObject.SetActive(false);
        }
        else
        {
            text.text = quantity.ToString();
        }
    }
Exemplo n.º 6
0
        public ActionResult ConfirmPay(int?addressId, int?cardId)
        {
            var cart = db.GetUserProfile(User.Identity.Name).UserData.ShoppingCart;
            //新建订单
            var order = new Order()
            {
                CreateDate = DateTime.Now, UserData = cart.UserData, ItemRecordSets = new List <ItemRecordSet>()
            };

            db.Orders.Add(order);
            //将购物车数据添加到订单并生成历史记录
            foreach (var set in cart.ItemSets)
            {
                var r = new ItemRecord {
                    Item = set.Item, HistoryPrice = set.Price, IsDigital = set.IsDigital
                };
                var rset = new ItemRecordSet {
                    ItemRecord = r, Count = set.Count
                };
                order.ItemRecordSets.Add(rset);
            }
            //查找是否数字版,添加到个人拥有的数字列表
            foreach (var set in cart.ItemSets)
            {
                if (set.IsDigital)
                {
                    cart.UserData.OwnedDigitalItems.Add(new OwnedDigitalItem {
                        Item = set.Item, UserData = cart.UserData
                    });
                }
            }
            //清空购物车数据
            var list = cart.ItemSets.ToList();

            foreach (var item in list)
            {
                db.ItemSets.Remove(item);
            }

            db.SaveChanges();

            return(RedirectToAction("Details", "Order", new { id = order.Id }));
        }
        public override void Initialize(System.IO.BinaryReader reader, RecordHeader header)
        {
            var        index      = 0;
            ItemRecord item       = null;
            var        itemChance = 0;

            while (reader.BaseStream.Position < header.DataEndPos)
            {
                var type = (SubRecordType)reader.ReadInt32();
                var size = reader.ReadInt32();

                switch (type)
                {
                case SubRecordType.Id:
                    name = reader.ReadString(size);
                    break;

                case SubRecordType.Data:
                    data = new LeveledItemRecordData(reader);
                    break;

                case SubRecordType.NextName:
                    chanceNone = reader.ReadByte();
                    break;

                case SubRecordType.Index:
                    count = reader.ReadInt32();
                    items = new Tuple <ItemRecord, int> [count];
                    break;

                case SubRecordType.ItemName:
                    item = Record.GetRecord <ItemRecord>(reader.ReadString(size));
                    break;

                case SubRecordType.IntValue:
                    itemChance   = reader.ReadInt16();
                    items[index] = new Tuple <ItemRecord, int>(item, itemChance);
                    index++;
                    break;
                }
            }
        }
Exemplo n.º 8
0
        bool IsSetCompleted(uint transmogSetId)
        {
            var transmogSetItems = Global.DB2Mgr.GetTransmogSetItems(transmogSetId);

            if (transmogSetItems.Empty())
            {
                return(false);
            }

            int[] knownPieces = new int[EquipmentSlot.End];
            for (var i = 0; i < EquipmentSlot.End; ++i)
            {
                knownPieces[i] = -1;
            }

            foreach (TransmogSetItemRecord transmogSetItem in transmogSetItems)
            {
                ItemModifiedAppearanceRecord itemModifiedAppearance = CliDB.ItemModifiedAppearanceStorage.LookupByKey(transmogSetItem.ItemModifiedAppearanceID);
                if (itemModifiedAppearance == null)
                {
                    continue;
                }

                ItemRecord item = CliDB.ItemStorage.LookupByKey(itemModifiedAppearance.ItemID);
                if (item == null)
                {
                    continue;
                }

                int transmogSlot = Item.ItemTransmogrificationSlots[(int)item.inventoryType];
                if (transmogSlot < 0 || knownPieces[transmogSlot] == 1)
                {
                    continue;
                }

                (var hasAppearance, bool isTemporary) = HasItemAppearance(transmogSetItem.ItemModifiedAppearanceID);

                knownPieces[transmogSlot] = (hasAppearance && !isTemporary) ? 1 : 0;
            }

            return(!knownPieces.Contains(0));
        }
        void DisplayItemsFoldout()
        {
            if (currentItems == null || currentItems.Length == 0)
            {
                EditorGUILayout.HelpBox("No items found.", MessageType.Info);
                return;
            }

            for (int i = 0; i < currentItems.Length; i++)
            {
                ItemRecord          itemRecord = currentItems[i] as ItemRecord;
                DaggerfallUnityItem item       = new DaggerfallUnityItem(itemRecord);

                int equippedIndex = GetEquippedIndex(itemRecord);
                //if (equippedIndex == -1)
                //    continue;

                //string savedName = itemRecord.ParsedData.name;
                //ItemGroups itemGroup = (ItemGroups)itemRecord.ParsedData.category1;
                //int itemIndex = itemRecord.ParsedData.category2;
                //ItemDescription itemDesc = itemHelper.GetItemDescription(itemGroup, itemIndex);
                ////string cat1 = ((ItemGroups)itemRecord.ParsedData.category1).ToString();
                ////string cat2 = itemRecord.ParsedData.category2.ToString();
                ////string subName = ItemHelper.ToSubCategoryName((ItemGroups)itemRecord.ParsedData.category1, itemRecord.ParsedData.category2);
                ////string other = itemRecord.ParsedData.category2.ToString();

                //string textLabel = string.Format(
                //    "{0} [mat=0x{1:X4}]",
                //    itemHelper.ResolveItemName(itemRecord.ParsedData),
                //    itemRecord.ParsedData.material);

                string textLabel = string.Format("Item [{0}]", item.LongName);

                if (equippedIndex != -1)
                {
                    textLabel = "*" + textLabel;
                }

                //string textLabel = itemHelper.GetClassicItemName(itemRecord.ParsedData);
                EditorGUILayout.LabelField(textLabel);
            }
        }
Exemplo n.º 10
0
        public async Task <Item> AddAsync(string collectionName, string data, string userId, DateTimeOffset datetime)
        {
            using (var tran = await _db.Database.BeginTransactionAsync())
            {
                var item = new Item
                {
                    Id             = Helper.CreateKey(),
                    CollectionName = collectionName,
                    CreatedAt      = datetime,
                    UpdatedAt      = datetime,
                    CreatedBy      = userId,
                    UpdatedBy      = userId,
                    IsValid        = true,
                };

                await _db.AddAsync(item);

                await _db.SaveChangesAsync();

                var record = new ItemRecord
                {
                    Id        = Helper.CreateKey(),
                    ItemId    = item.Id,
                    Data      = data,
                    CreatedAt = datetime,
                    CreatedBy = userId,
                };

                item.Data      = data;
                item.CurrentId = record.Id;

                await _db.AddAsync(record);

                await _db.SaveChangesAsync();

                tran.Commit();

                _db.Entry(item).State = EntityState.Detached;

                return(item);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// A recursive one ;)
        /// </summary>
        public int[] RemoveRecipeItem(ItemRecord record)
        {
            List <int> results = new List <int>();

            foreach (var itemRecipe in record.RecipeItemRecords)
            {
                var removed = RemoveItem(itemRecipe.ItemId);

                if (removed != null)
                {
                    results.Add(removed.Record.GetTotalPrice());
                }
                else
                {
                    results.AddRange(RemoveRecipeItem(itemRecipe));
                }
            }

            return(results.ToArray());
        }
Exemplo n.º 12
0
        public void SendMail(string subject, uint money, ItemRecord item, string body)
        {
            MailMessage mailMessage = new MailMessage(subject, body)
            {
                SenderId          = (uint)this.HouseFaction,
                ReceiverId        = this.OwnerLowId,
                MessageStationary = MailStationary.Auction,
                MessageType       = MailType.Auction,
                IncludedMoney     = money,
                LastModifiedOn    = new DateTime?(),
                SendTime          = DateTime.Now,
                DeliveryTime      = DateTime.Now
            };

            if (item != null)
            {
                mailMessage.AddItem(item);
            }
            mailMessage.Send();
        }
        int GetEquippedIndex(ItemRecord record)
        {
            if (characterRecord == null || record.RecordType != RecordTypes.Item || record.Parent == null)
            {
                return(-1);
            }

            // Try to match item RecordID with equipped item IDs
            // Item RecordID must be shifted right 8 bits
            uint[] equippedItems = characterRecord.ParsedData.equippedItems;
            for (int i = 0; i < equippedItems.Length; i++)
            {
                if (equippedItems[i] == record.RecordRoot.RecordID)
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemplo n.º 14
0
        public async Task <ItemRecord> InsertRecord(ItemRecord newRecord)
        {
            var attributes = ConvertToAttributeCollection(newRecord);

            var request = new PutItemRequest
            {
                TableName           = _tableName,
                Item                = attributes,
                ConditionExpression = $"attribute_not_exists({nameof(newRecord.Id).ToLower()})" //only create new
            };

            var response = await _dynamoClient.PutItemAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                return(newRecord);
            }

            throw new Exception($"Insert failed, server returned status {response.HttpStatusCode}");
        }
Exemplo n.º 15
0
        public void SerializeDeserializeObjTest()
        {
            // arrange
            var stream = new MemoryStream();
            var source = new ItemRecord
            {
                Name       = "Test",
                TemplateID = new Guid()
            };

            // act
            Serializer.Serialize(stream, source);
            stream.Seek(0, SeekOrigin.Begin);
            var copy = Serializer.Deserialize <ItemRecord>(stream);

            // assert
            Assert.AreNotEqual(source, copy);
            Assert.AreEqual(source.Name, copy.Name);
            Assert.AreEqual(source.TemplateID, copy.TemplateID);
        }
Exemplo n.º 16
0
        public static string GetNameString(short id, int amount)
        {
            ItemRecord data = World.Instance.EIF.GetItemRecordByID(id);

            switch (data.ID)
            {
            case 1:
                return(string.Format("{0} {1}", amount, data.Name));

            default:
                if (amount == 1)
                {
                    return(data.Name);
                }
                if (amount > 1)
                {
                    return(string.Format("{0} x{1}", data.Name, amount));
                }
                throw new Exception("There shouldn't be an item in the inventory with amount zero");
            }
        }
        private void AddItem(Update update, SubscriberRecord subscriberRecord)
        {
            var item = new ItemRecord
            {
                BotInstanceId = BotInstanceId,
                MessageId     = update.Message.MessageId,
                ChatId        = subscriberRecord.ChatId,
            };

            if (update.Message.Type == MessageType.Photo)
            {
                item.ItemType = ItemRecord.ItemTypes.IMAGE;
                item.FileId   = update.Message.Photo[update.Message.Photo.Length - 1].FileId;
                ItemsQueueRepo.Add(subscriberRecord, item);
            }
            else if (update.Message.Type == MessageType.Text)
            {
                var isUri = Uri.IsWellFormedUriString(update.Message.Text, UriKind.RelativeOrAbsolute);
                item.ItemType = ItemRecord.ItemTypes.WEB_PAGE;
                item.Text     = update.Message.Text;
            }
            else if (update.Message.Type == MessageType.Document)
            {
                switch (update.Message.Document.MimeType)
                {
                case "application/pdf":
                    item.ItemType = ItemRecord.ItemTypes.PDF_FILE;
                    item.FileId   = update.Message.Document.FileId;
                    ItemsQueueRepo.Add(subscriberRecord, item);
                    break;

                case "image/jpeg":
                case "image/png":
                    item.ItemType = ItemRecord.ItemTypes.IMAGE;
                    item.FileId   = update.Message.Document.FileId;
                    ItemsQueueRepo.Add(subscriberRecord, item);
                    break;
                }
            }
        }
Exemplo n.º 18
0
        private static void UpdateDrop(WorldClient client, string[] args)
        {
            if (args.Length < 6)
            {
                client.Character.Reply("Add a drop to a set of monsters");
                client.Character.Reply("» .drops updatedrop|ud $ItemId $MonsterId $DropRate $MinPP $MinCount $MaxCount");
                client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$DropRate</b> ⇒ The drop percent [0, 100].");
                client.Character.Reply(" - <b>$MinPP</b> ⇒ The min PP value0.");
                client.Character.Reply(" - <b>$MinCount</b> ⇒ Minimum number of dropped items.");
                client.Character.Reply(" - <b>$MaxCount</b> ⇒ Maximum number of dropped items.");

                return;
            }

            ushort itemId    = ushort.Parse(args[1]);
            ushort monsterId = ushort.Parse(args[2]);
            short  dropRate  = short.Parse(args[3]);
            int    pp        = int.Parse(args[4]);
            int    minCount  = int.Parse(args[5]);
            int    maxCount  = int.Parse(args[6]);

            ItemRecord    item          = ItemRecord.GetItem(itemId);
            MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId);
            MonsterDrop   monsterDrop   = monsterRecord.Drops.Find(d => d.ItemId == itemId);

            monsterDrop.PercentDropForGrade1 = dropRate;
            monsterDrop.PercentDropForGrade2 = (short)(dropRate + 2);
            monsterDrop.PercentDropForGrade3 = (short)(dropRate + 4);
            monsterDrop.PercentDropForGrade4 = (short)(dropRate + 6);
            monsterDrop.PercentDropForGrade5 = (short)(dropRate + 8);
            monsterDrop.Count           = minCount;
            monsterDrop.DropLimit       = maxCount;
            monsterDrop.ProspectingLock = pp;

            monsterRecord.UpdateInstantElement();

            client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}");
        }
Exemplo n.º 19
0
        /// <summary>Initializes a new Item</summary>
        internal void InitItem(ItemTemplate template, Character owner, int amount)
        {
            m_record        = ItemRecord.CreateRecord();
            EntryId         = m_record.EntryId = template.Id;
            Type           |= ObjectTypes.Item;
            m_template      = template;
            Durability      = m_template.MaxDurability;
            MaxDurability   = m_template.MaxDurability;
            Flags           = m_template.Flags;
            TextId          = m_template.PageTextId;
            Amount          = amount;
            OwningCharacter = owner;
            EntityId        = m_record.EntityId;
            if (m_template.UseSpell != null && m_template.UseSpell.HasCharges)
            {
                m_record.Charges = m_template.UseSpell.Charges;
                SetSpellCharges(m_template.UseSpell.Index, m_template.UseSpell.Charges);
            }

            template.NotifyCreated(m_record);
            OnInit();
        }
Exemplo n.º 20
0
        public IActionResult Update(long id, [FromBody] ItemRecord item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var existingItem = m_Context.Items.FirstOrDefault(t => t.Id == id);

            if (existingItem == null)
            {
                return(NotFound());
            }

            existingItem.ItemName = item.ItemName;
            existingItem.Price    = item.Price;

            m_Context.Items.Update(existingItem);
            m_Context.SaveChanges();

            return(new NoContentResult());
        }
Exemplo n.º 21
0
        public static void JoyCommand(string value, WorldClient client)
        {
            List <ushort> spells = new List <ushort>();

            var items = ItemRecord.GetItems(ItemTypeEnum.FÉE_D_ARTIFICE);

            foreach (ItemRecord item in items)
            {
                SpellRecord spell = SpellRecord.Spells.Find(x => x.Name == item.Name);

                if (spell != null)
                {
                    spells.Add(spell.Id);
                }
            }

            foreach (ushort spell in spells)
            {
                Thread.Sleep(1000);
                client.Character.SpellAnim(spell);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Créer un item mination lié a un joueur.
        /// </summary>
        /// <param name="template"></param>
        /// <param name="quantity"></param>
        /// <param name="characterId"></param>
        /// <param name="monster"></param>
        /// <param name="monsterGradeId"></param>
        /// <returns></returns>
        public static CharacterItemRecord CreateMinationItem(ItemRecord template, uint quantity, long characterId, MonsterRecord monster, sbyte monsterGradeId)
        {
            CharacterItemRecord item;

            if (monster.IsMiniBoss)
            {
                item = MinationItemMiniBossTemplate.GetCharacterItem(characterId, quantity, true);
            }
            else if (monster.IsBoss)
            {
                item = MinationItemBossTemplate.GetCharacterItem(characterId, quantity, true);
            }
            else
            {
                item = MinationItemTemplate.GetCharacterItem(characterId, quantity, true);
            }
            item.Effects.Clear();
            item.AddEffect(new EffectMination(monster.Id, monster.Name, monsterGradeId));
            item.AddEffect(new EffectMinationLevel(1, 0, 0));
            item.AddEffectInteger(EffectsEnum.Effect_Followed, monster.Id);
            return(item);
        }
Exemplo n.º 23
0
        public static void HandleMimicryObjectEraseRequest(MimicryObjectEraseRequestMessage message, WorldClient client)
        {
            CharacterItemRecord item = client.Character.Inventory.GetItem(message.hostUID);

            if (message.hostPos != 63)
            {
                client.Character.RefreshActorOnMap();
                client.Character.RefreshStats();
            }
            if (client.Character.Inventory.GetEquipedItems().Contains(item))
            {
                client.Character.Inventory.SetItemPosition(item.UId, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, 1);
            }
            item.RemoveAllEffects(EffectsEnum.Effect_ChangeAppearence1151);
            CharacterItemRecord newItem = (CharacterItemRecord)item.CloneWithoutUID();

            newItem.AppearanceId = ItemRecord.GetItem(newItem.GId).AppearanceId;
            client.Character.Inventory.RemoveItem(item, item.Quantity);
            client.Character.Inventory.AddItem(newItem, 1);
            client.Character.RefreshActorOnMap();
            client.Character.RefreshStats();
        }
Exemplo n.º 24
0
        public CharacterItemRecord Add(ushort gid, uint quantity, bool notif = true, bool refresh = true)
        {
            ItemRecord template = ItemRecord.GetItem(gid);

            if (template == null)
            {
                Character.Reply("L'item n'éxiste pas");
                return(null);
            }
            var newObjitem = template.GenerateRandomObjectItem();

            newObjitem.quantity = quantity;
            CharacterItemRecord newItem = new CharacterItemRecord(newObjitem, Character.Id);

            ItemCustomEffects.Instance.Init(newItem);
            Add(newItem, refresh);
            if (notif)
            {
                Character.Reply("Vous avez obtenu " + quantity + " " + template.Name);
            }
            return(newItem);
        }
Exemplo n.º 25
0
        public ItemSearchDocument(ItemRecord record)
        {
            Id = record.GTIN;
            // we want to do some work in setting
            // up the values that will be analyzed
            // thinking about what the user might
            // type into our search input
            Names = new[]
            {
                record.Name,
                record.BrandName
            }
            .Union(record.Name.Split(' '))
            .Union(record.BrandName.Split(' '))
            .Distinct(StringComparer.OrdinalIgnoreCase)
            .ToArray();

            Name      = record.Name;
            BrandName = record.BrandName;

            Data = record;
        }
Exemplo n.º 26
0
        public async Task <ActionResult <ItemDetail> > PostItemDetail([FromBody] dynamic item)
        {
            ItemRecord itemRecord = JsonConvert.DeserializeObject <ItemRecord>(item.ToString());

            var accessToken = Request.Headers["Authorization"].ToString().Replace("Bearer", "").Trim();
            //var otp = GetOtp(accessToken);

            var identity = HttpContext.User.Identity as ClaimsIdentity;

            // Gets list of claims.
            IEnumerable <Claim> claim = identity.Claims;

            var dataStoreId = claim
                              .Where(x => x.Type == "DataStoreId")
                              .FirstOrDefault().Value;

            var dataStoreItem = _context.DataStoreItem
                                .Where(d => d.DataStoreId == int.Parse(dataStoreId) &&
                                       d.StoreItemName == itemRecord.StoreItemName &&
                                       d.Completed == false)
                                .FirstOrDefault();

            if (dataStoreItem == null)
            {
                return(NotFound());
            }

            ItemDetail itemDetail = new ItemDetail();

            itemDetail.DataStoreItemId = dataStoreItem.Id;
            itemDetail.ItemDetailName  = itemRecord.ItemDetailName;
            itemDetail.ItemDetailValue = _protector.Protect(itemRecord.ItemDetailValue);

            _context.ItemDetail.Add(itemDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetItemDetail", new { id = itemDetail.Id }, itemDetail));
        }
Exemplo n.º 27
0
 /// <summary>
 ///
 /// </summary>
 public void LoadItems()
 {
     if (!_hasItemLoaded)
     {
         try
         {
             foreach (var itemRecord in ItemRecord.LoadAuctionedItems())
             {
                 _auctionedItems.Add(itemRecord.EntityLowId, itemRecord);
             }
             _hasItemLoaded = true;
         }
         catch (Exception e)
         {
             RealmDBMgr.OnDBError(e);
             foreach (var itemRecord in ItemRecord.LoadAuctionedItems())
             {
                 _auctionedItems.Add(itemRecord.EntityLowId, itemRecord);
             }
             _hasItemLoaded = true;
         }
     }
 }
Exemplo n.º 28
0
 /// <summary>Loads an already created item without owner</summary>
 /// <param name="record"></param>
 /// <param name="template"></param>
 internal void LoadItem(ItemRecord record, ItemTemplate template)
 {
     m_record   = record;
     EntityId   = record.EntityId;
     m_template = template;
     EntryId    = m_template.Id;
     Type      |= ObjectTypes.Item;
     SetUInt32(ItemFields.FLAGS, (uint)record.Flags);
     SetInt32(ItemFields.DURABILITY, record.Durability);
     SetInt32(ItemFields.DURATION, record.Duration);
     SetInt32(ItemFields.STACK_COUNT, record.Amount);
     SetInt32(ItemFields.PROPERTY_SEED, record.RandomSuffix);
     SetInt32(ItemFields.RANDOM_PROPERTIES_ID, record.RandomProperty);
     SetInt64(ItemFields.CREATOR, record.CreatorEntityId);
     SetInt64(ItemFields.GIFTCREATOR, record.GiftCreatorEntityId);
     ItemText = record.ItemText;
     if (m_template.UseSpell != null)
     {
         SetSpellCharges(m_template.UseSpell.Index, record.Charges);
     }
     MaxDurability = m_template.MaxDurability;
     OnLoad();
 }
Exemplo n.º 29
0
        private bool AddItemToSlot(int slot, ItemRecord item, int count = 1)
        {
            //this is ADD item - don't allow adding items that have been added already
            if (slot < 0 || m_childItems.Count(_item => _item.Slot == slot) > 0)
            {
                return(false);
            }

            List <Tuple <int, int> > points;

            if (!_fitsInSlot(slot, item.Size, out points))
            {
                return(false);
            }
            points.ForEach(point => m_filledSlots[point.Item1, point.Item2] = true);                    //flag that the spaces are taken

            m_inventoryKey.SetValue(string.Format("item{0}", slot), item.ID, RegistryValueKind.String); //update the registry
            m_childItems.Add(new EOInventoryItem(m_api, slot, item, new InventoryItem {
                amount = count, id = (short)item.ID
            }, this));                                                                                                                             //add the control wrapper for the item
            m_childItems[m_childItems.Count - 1].DrawOrder = (int)ControlDrawLayer.DialogLayer - (2 + slot % INVENTORY_ROW_LENGTH);
            return(true);
        }
Exemplo n.º 30
0
        public void TesT5()
        {
            var root = new ItemRecord {
                ID = ItemIDs.RootItemID, Name = "Sitecore"
            };
            var content1 = new ItemRecord {
                ID = Guid.NewGuid(), Name = "content", ParentID = root.ID
            };
            var content2 = new ItemRecord {
                ID = Guid.NewGuid(), Name = "content", ParentID = root.ID
            };
            var home = new ItemRecord {
                ID = Guid.NewGuid(), Name = "Home", ParentID = content2.ID
            };
            var namesCache = new ChildrenDataSet(new ItemDefinitions(root, content1, content2, home));

            // act
            Guid id;
            var  result = ItemPathResolver.TryResolvePath("/sitecore/content/home", namesCache, out id);

            Assert.IsTrue(result);
            Assert.AreEqual(home.ID, id);
        }
Exemplo n.º 31
0
        public static void HandleBuyItemRequestMessage(BuyItemRequestMessage message, LoLClient client)
        {
            ItemRecord itemRecord = ItemRecord.GetItemRecord(message.itemId);

            if (client.Hero.Stats.Gold >= itemRecord.Price)
            {
                int[] recipePrices = client.Hero.Inventory.RemoveRecipeItem(itemRecord);
                Item  itemResult   = client.Hero.Inventory.AddItem(itemRecord);

                if (itemResult != null)
                {
                    int priceTotal = itemRecord.GetTotalPrice();

                    foreach (var price in recipePrices)
                    {
                        priceTotal -= price;
                    }

                    client.Hero.RemoveGold(priceTotal);
                    client.Hero.UpdateStats();
                }
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// Checks if the given amount of the given item stack can be stored in the given slot (optionally with merging),
        /// without necessitating an Item swap. No actual store takes place.
        /// </summary>
        /// <param name="item">The <see cref="ItemRecord" /> to store.</param>
        /// <param name="amount">The amount of items from the stack to store.</param>
        /// <param name="slot">The slotId where you want to store.</param>
        /// <param name="allowMerge">Whether or not to try and merge the stacks.</param>
        /// <returns>true if no Item swap is needed.</returns>
        public bool CheckStoreItemInSlot(ItemRecord item, int amount, int slot, bool allowMerge)
        {
            if (slot >= GuildMgr.MAX_BANK_TAB_SLOTS) return false;
            if (item.Amount < amount) return false; // Cheater!

            var curItem = this[slot];
            if (curItem == null) return true;
            
            if (allowMerge && this[slot].EntryId == item.EntryId)
            {
                // try to merge the stacks.
                var freeSpace = (int)curItem.Template.MaxAmount - curItem.Amount;
                return (freeSpace >= amount);
            }

            // gonna swap
            return false;
        }
Exemplo n.º 33
0
        private void LogItemEvent(GuildBankLogEntryType type, Character actor, ItemRecord record, int amount, GuildBankTab intoTab)
        {
            var entry = new GuildBankLogEntry {
                Type = type,
                Actor = actor,
                BankLog = this,
                DestinationTab = intoTab,
                ItemEntryId = (int)record.EntryId,
                ItemStackCount = (int)amount,
                TimeStamp = DateTime.Now
            };

            MoneyLogEntries.Push(entry);
            MoneyLogEntries = EnsureStackSize(MoneyLogEntries);
        }
Exemplo n.º 34
0
 public void LogEvent(GuildBankLogEntryType type, Character member, uint money, ItemRecord item, int amount, GuildBankTab intoTab)
 {
     switch (type)
     {
         case GuildBankLogEntryType.None:
             {
                 break;
             }
         case GuildBankLogEntryType.DepositItem:
             {
                 LogItemEvent(type, member, item, amount, intoTab);
                 break;
             }
         case GuildBankLogEntryType.WithdrawItem:
             {
                 LogItemEvent(type, member, item, amount, intoTab);
                 break;
             }
         case GuildBankLogEntryType.MoveItem:
             {
                 LogItemEvent(type, member, item, amount, intoTab);
                 break;
             }
         case GuildBankLogEntryType.DepositMoney:
             {
                 LogMoneyEvent(type, member, money);
                 break;
             }
         case GuildBankLogEntryType.WithdrawMoney:
             {
                 LogMoneyEvent(type, member, money);
                 break;
             }
         case GuildBankLogEntryType.MoneyUsedForRepairs:
             {
                 LogMoneyEvent(type, member, money);
                 break;
             }
         case GuildBankLogEntryType.MoveItem_2:
             {
                 LogItemEvent(type, member, item, amount, intoTab);
                 break;
             }
         case GuildBankLogEntryType.Unknown1:
             {
                 break;
             }
         case GuildBankLogEntryType.Unknown2:
             {
                 break;
             }
         default:
             {
                 break;
             }
     } // end switch
 } // end method
Exemplo n.º 35
0
 public void LogEvent(GuildBankLogEntryType type, Character chr, ItemRecord item, int amount, GuildBankTab intoTab)
 {
     LogEvent(type, chr, 0, item, amount, intoTab);
 }
Exemplo n.º 36
0
 private void OnRecordCreated(ItemRecord record)
 {
     if (IsCharter)
     {
         if (!record.IsNew)
         {
             // this is executed in the IO-context
             PetitionRecord.LoadRecord(record.OwnerId);
         }
     }
 }
Exemplo n.º 37
0
        public EOInventoryItem(PacketAPI api, int slot, ItemRecord itemData, InventoryItem itemInventoryInfo, EOInventory inventory)
            : base(null, null, inventory)
        {
            m_api = api;
            m_itemData = itemData;
            m_inventory = itemInventoryInfo;
            Slot = slot;

            UpdateItemLocation(Slot);

            m_itemgfx = GFXLoader.TextureFromResource(GFXTypes.Items, 2 * itemData.Graphic, true);

            m_highlightBG = new Texture2D(Game.GraphicsDevice, DrawArea.Width - 3, DrawArea.Height - 3);
            Color[] highlight = new Color[(drawArea.Width - 3) * (drawArea.Height - 3)];
            for (int i = 0; i < highlight.Length; ++i) { highlight[i] = Color.FromNonPremultiplied(200, 200, 200, 60); }
            m_highlightBG.SetData(highlight);

            _initItemLabel();

            m_recentClickTimer = new Timer(
                _state => { if (m_recentClickCount > 0) Interlocked.Decrement(ref m_recentClickCount); }, null, 0, 1000);
        }
Exemplo n.º 38
0
        private bool _addItemToSlot(bool[,] filledSlots, int slot, ItemRecord item, int count = 1)
        {
            //this is ADD item - don't allow adding items that have been added already
            if (slot < 0 || m_childItems.Count(_item => _item.Slot == slot) > 0) return false;

            List<Tuple<int, int>> points;
            if (!_fitsInSlot(filledSlots, slot, item.Size, out points)) return false;
            points.ForEach(point => filledSlots[point.Item1, point.Item2] = true); //flag that the spaces are taken

            m_inventoryKey.SetValue(string.Format("item{0}", slot), item.ID, RegistryValueKind.String); //update the registry
            m_childItems.Add(new EOInventoryItem(m_api, slot, item, new InventoryItem { amount = count, id = (short)item.ID }, this)); //add the control wrapper for the item
            m_childItems[m_childItems.Count - 1].DrawOrder = (int) ControlDrawLayer.DialogLayer - (2 + slot%INVENTORY_ROW_LENGTH);
            return true;
        }
Exemplo n.º 39
0
		private void LogItemEvent(GuildBankLogEntryType type, Character actor, ItemRecord record, int amount, GuildBankTab intoTab)
		{
			var entry = new GuildBankLogEntry(Bank.Guild.Id)
			{
				Type = type,
				Actor = actor,
				BankLog = this,
				DestinationTab = intoTab,
				ItemEntryId = (int)record.EntryId,
				ItemStackCount = (int)amount,
				Created = DateTime.Now
			};

			lock (moneyLogEntries)
			{
				moneyLogEntries.Insert(entry);
			}
		}
Exemplo n.º 40
0
 /// <summary>
 /// Places the given item in the given slot (or tries mergeing at slot> if indicated).
 /// Make sure that the depositer has deposit rights to this BankTab!
 /// </summary>
 /// <param name="item">The <see cref="ItemRecord" /> to store.</param>
 /// <param name="slot">The slotId where you want to store.</param>
 /// <param name="allowMerge">Whether or not to try and merge the stacks.</param>
 /// <returns>The <see cref="ItemRecord" /> that was in the slot (or the original <see cref="ItemRecord" /> minus the items that were merged) 
 /// or null if the store/merge was successful.</returns>
 public ItemRecord StoreItemInSlot(ItemRecord item, int slot, bool allowMerge)
 {
     return StoreItemInSlot(item, item.Amount, slot, allowMerge);
 }
Exemplo n.º 41
0
        private void continuebtn_Click(object sender, EventArgs e)
        {
            //process new item into syteline

            if (ViableToDump())
            {
                ItemRecord toAdd = new ItemRecord();

                toAdd = CollectItem();

                //System.Data.SqlClient.SqlTransaction transaction = null;

                try
                {
                    //transaction = TableAdapterHelper.BeginTransaction(itemTableAdapter);

                    //itemTableAdapter.InsertNewItem(toAdd.item, toAdd.description, toAdd.qty_allocjob, toAdd.u_m, toAdd.lead_time, toAdd.lot_size, toAdd.qty_used_ytd, toAdd.qty_mfg_ytd, toAdd.abc_code, toAdd.drawing_nbr, toAdd.product_code, toAdd.p_m_t_code, toAdd.cost_method, toAdd.lst_lot_size, toAdd.unit_cost, toAdd.lst_u_cost, toAdd.avg_u_cost, toAdd.job, toAdd.suffix, toAdd.stocked, toAdd.matl_type, toAdd.family_code, toAdd.low_level, toAdd.last_inv, toAdd.days_supply, toAdd.order_min, toAdd.order_mult, toAdd.plan_code, toAdd.mps_flag, toAdd.accept_req, toAdd.change_date, toAdd.revision, toAdd.phantom_flag, toAdd.plan_flag, toAdd.paper_time, toAdd.dock_time, toAdd.asm_setup, toAdd.asm_run, toAdd.asm_matl, toAdd.asm_tool, toAdd.asm_fixture, toAdd.asm_other, toAdd.asm_fixed, toAdd.asm_var, toAdd.asm_outside, toAdd.comp_setup, toAdd.comp_run, toAdd.comp_matl, toAdd.comp_tool, toAdd.comp_fixture, toAdd.comp_other, toAdd.comp_fixed, toAdd.comp_var, toAdd.comp_outside, toAdd.sub_matl, toAdd.shrink_fact, toAdd.alt_item, toAdd.unit_weight, toAdd.weight_units, toAdd.charfld4, toAdd.cur_u_cost, toAdd.feat_type, toAdd.var_lead, toAdd.feat_str, toAdd.next_config, toAdd.feat_templ, toAdd.backflush, toAdd.charfld1, toAdd.charfld2, toAdd.charfld3, toAdd.decifld1, toAdd.decifld2, toAdd.decifld3, toAdd.logifld, toAdd.datefld, toAdd.track_ecn, toAdd.u_ws_price, toAdd.comm_code, toAdd.origin, toAdd.unit_mat_cost, toAdd.unit_duty_cost, toAdd.unit_freight_cost, toAdd.unit_brokerage_cost, toAdd.cur_mat_cost, toAdd.cur_duty_cost, toAdd.cur_freight_cost, toAdd.cur_brokerage_cost, toAdd.tax_code1, toAdd.tax_code2, toAdd.bflush_loc, toAdd.reservable, toAdd.shelf_life, toAdd.lot_prefix, toAdd.serial_prefix, toAdd.serial_length, toAdd.issue_by, toAdd.serial_tracked, toAdd.lot_tracked, toAdd.cost_type, toAdd.matl_cost, toAdd.lbr_cost, toAdd.fovhd_cost, toAdd.vovhd_cost, toAdd.out_cost, toAdd.cur_mat_cost, toAdd.cur_lbr_cost, toAdd.cur_fovhd_cost, toAdd.cur_vovhd_cost, toAdd.cur_out_cost, toAdd.avg_matl_cost, toAdd.avg_lbr_cost, toAdd.avg_fovhd_cost, toAdd.avg_vovhd_cost, toAdd.avg_out_cost, toAdd.prod_type, toAdd.rate_per_day, toAdd.mps_plan_fence, toAdd.pass_req, toAdd.lot_gen_exp, toAdd.supply_site, toAdd.prod_mix, toAdd.stat, toAdd.status_chg_user_code, toAdd.chg_date, toAdd.reason_code, toAdd.supply_whse,
                    //    toAdd.due_period, toAdd.order_max, toAdd.mrp_part, toAdd.infinite_part, toAdd.NoteExistsFlag, toAdd.RecordDate, toAdd.supply_tolerance_hrs, toAdd.exp_lead_time, toAdd.var_exp_lead, toAdd.buyer, toAdd.order_configurable, toAdd.job_configurable, toAdd.cfg_model, toAdd.co_post_config, toAdd.job_post_config, toAdd.auto_job, toAdd.auto_post, toAdd.setupgroup, toAdd.CreatedBy, toAdd.UpdatedBy, toAdd.CreateDate, toAdd.InWorkflow, toAdd.mfg_supply_switching_active, toAdd.time_fence_rule, toAdd.time_fence_value, toAdd.earliest_planned_po_receipt, toAdd.use_reorder_point, toAdd.reorder_point, toAdd.fixed_order_qty, toAdd.unit_insurance_cost, toAdd.unit_loc_frt_cost, toAdd.cur_insurance_cost, toAdd.cur_loc_frt_cost, toAdd.tax_free_matl, toAdd.tax_free_days, toAdd.safety_stock_percent, toAdd.tariff_classification, toAdd.active_for_data_integration, toAdd.rcvd_over_po_qty_tolerance, toAdd.rcvd_under_po_qty_tolerance, toAdd.include_in_net_change_planning, toAdd.kit, toAdd.print_kit_components, toAdd.safety_stock_rule, toAdd.show_in_drop_down_list, toAdd.controlled_by_external_ics, toAdd.inventory_ucl_tolerance, toAdd.inventory_lcl_tolerance, toAdd.separation_attribute, toAdd.batch_release_attribute1, toAdd.batch_release_attribute2, toAdd.batch_release_attribute3, toAdd.picture, toAdd.active_for_customer_portal, toAdd.featured, toAdd.top_seller, toAdd.overview, toAdd.preassign_lots, toAdd.preassign_serials, toAdd.attr_group, toAdd.dimension_group, toAdd.lot_attr_group, toAdd.track_pieces, toAdd.bom_last_import_date, toAdd.save_current_rev_upon_bom_import);

                    //transaction.Commit();

                    int VendCount = 0;

                    try
                    {
                        //VendCount = Convert.ToInt32(itemvendTableAdapter.CountVendors(itemtxt.Text));
                    }
                    catch { VendCount = 0; }

                    if (sourcecbo.Text == "Purchased" && VendCount == 0)
                    {
                        //add vendor

                        ItemVendorAdd form = new ItemVendorAdd(itemtxt.Text);

                        form.ShowDialog();

                        if (form.DialogResult == DialogResult.Cancel)
                        {
                            this.DialogResult = DialogResult.Cancel;
                        }

                        form.Dispose();
                    }
                }
                catch
                {
                    //transaction.Rollback();

                    this.DialogResult = DialogResult.Cancel;

                    MessageBox.Show("An error occured while trying to inject the item into Syteline.  Operations will now stop.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    this.Close();

                    this.Dispose();

                    return;
                }
                finally
                {
                   //transaction.Connection.Close();

                    //transaction.Dispose();

                    this.Close();
                }
            }
        }
Exemplo n.º 42
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            //update the draw location when the player isn't the MainPlayer (so, if they walked)
            if (!noLocUpdate && characterSkin != null && _char != null && World.Instance.MainPlayer.ActiveCharacter != null)
                drawArea = new Rectangle(
                    _char.OffsetX + 304 - World.Instance.MainPlayer.ActiveCharacter.OffsetX,
                    _char.OffsetY + 91 - World.Instance.MainPlayer.ActiveCharacter.OffsetY,
                    m_skinSourceRect.Width, m_skinSourceRect.Height);

            //update when the control is being dragged (when not in-game)
            if (EOGame.Instance.State != GameStates.PlayingTheGame &&
                PreviousMouseState.LeftButton == ButtonState.Pressed &&
                Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                Data.SetUpdate(true);
            }

            #region refresh all the textures from the GFX files or image cache
            if (Data.update)
            {
                if (Data.shield != 0)
                {
                    if (World.Instance.EIF != null)
                    {
                        shieldInfo = (ItemRecord)World.Instance.EIF.Data.Find(x => (x as ItemRecord != null) && (x as ItemRecord).DollGraphic == Data.shield && (x as ItemRecord).Type == ItemType.Shield);
                        shield = spriteSheet.GetShield(shieldInfo.SubType == ItemSubType.Arrows || shieldInfo.SubType == ItemSubType.Wings);
                    }
                }
                else
                {
                    shield = null;
                    shieldInfo = null;
                }

                if (Data.weapon != 0)
                {
                    if (World.Instance.EIF != null)
                    {
                        weaponInfo =
                            (ItemRecord)
                                World.Instance.EIF.Data.Find(
                                    x =>
                                        (x as ItemRecord != null) && (x as ItemRecord).DollGraphic == Data.weapon &&
                                        (x as ItemRecord).Type == ItemType.Weapon);
                        weapon = spriteSheet.GetWeapon(weaponInfo.SubType == ItemSubType.Ranged);
                    }
                }
                else
                {
                    weapon = null;
                    weaponInfo = null;
                }

                bool isBow = weaponInfo != null && weaponInfo.SubType == ItemSubType.Ranged;
                characterSkin = spriteSheet.GetSkin(isBow, out m_skinSourceRect);
                boots = Data.boots != 0 ? spriteSheet.GetBoots(isBow) : null;
                armor = Data.armor != 0 ? spriteSheet.GetArmor(isBow) : null;
                lock (hatHairLock)
                    hair = Data.hairstyle != 0 ? spriteSheet.GetHair(Data.hairNeedRefresh) : null;
                if (Data.hat != 0)
                {
                    lock (hatHairLock)
                        hat = spriteSheet.GetHat();
                    if(World.Instance.EIF != null)
                        hatInfo = (ItemRecord)World.Instance.EIF.Data.Find(x => (x as ItemRecord != null) && (x as ItemRecord).DollGraphic == Data.hat && (x as ItemRecord).Type == ItemType.Hat);
                }
                else
                {
                    lock (hatHairLock)
                    {
                        hat = null;
                        hatInfo = null;
                    }
                }

                maskTheHair(); //this will set the combined hat/hair texture with proper data.

                _drawCharToRenderTarget();

                Data.SetUpdate(false);
                Data.SetHairNeedRefresh(false);
            }
            #endregion

            //bring back from the dead after 2 seconds
            if (m_deadTime != null && Character.RenderData.dead && (DateTime.Now - m_deadTime.Value).TotalSeconds > 2)
            {
                m_deadTime = null;
                Character.RenderData.SetDead(false);
            }

            if (EOGame.Instance.State == GameStates.PlayingTheGame && this == World.Instance.ActiveCharacterRenderer)
            {
                //adjust SP
                if (Character.Stats != null && Character.Stats.sp < Character.Stats.maxsp &&
                    State != CharacterActionState.Attacking && (int) gameTime.TotalGameTime.TotalMilliseconds%1000 == 0)
                    Character.Stats.SetSP((short) (Character.Stats.sp + 1));

                //5-minute timeout: start sending emotes every minute
                if ((DateTime.Now - m_lastActTime).TotalMilliseconds > 300000 &&
                    (m_lastEmoteTime == null || (DateTime.Now - m_lastEmoteTime.Value).TotalMilliseconds > 60000))
                {
                    m_lastEmoteTime = DateTime.Now;
                    Character.Emote(Emote.Moon);
                    PlayerEmote();
                }

                if (m_drunkTime.HasValue && Character.IsDrunk)
                {
                    //note: these timer values (between 1-6 seconds and 30 seconds) are completely arbitrary
                    if (!m_lastEmoteTime.HasValue || (DateTime.Now - m_lastEmoteTime.Value).TotalMilliseconds > m_drunkOffset)
                    {
                        m_lastEmoteTime = DateTime.Now;
                        Character.Emote(Emote.Drunk);
                        PlayerEmote();
                        m_drunkOffset = (new Random()).Next(1000, 6000); //between 1-6 seconds
                    }

                    if ((DateTime.Now - m_drunkTime.Value).TotalMilliseconds >= 30000)
                    {
                        m_drunkTime = null;
                        Character.IsDrunk = false;
                    }
                }
            }

            #region input handling for keyboard
            //only check for a keypress if not currently acting and if this is the active character renderer
            //also only check every 1/4 of a second
            KeyboardState currentKeyState = Keyboard.GetState();
            if (Game.IsActive && _char != null && _char == World.Instance.MainPlayer.ActiveCharacter && gameTime.TotalGameTime.Milliseconds % 100 <= 25 && Dialogs.Count == 0)
            {
                EODirection direction = (EODirection)255; //first, get the direction we should try to move based on the key presses from the player
                bool attacking = false;
                if (currentKeyState.IsKeyDown(Keys.Up) && _prevKeyState.IsKeyDown(Keys.Up))
                    direction = EODirection.Up;
                else if (currentKeyState.IsKeyDown(Keys.Down) && _prevKeyState.IsKeyDown(Keys.Down))
                    direction = EODirection.Down;
                else if (currentKeyState.IsKeyDown(Keys.Left) && _prevKeyState.IsKeyDown(Keys.Left))
                    direction = EODirection.Left;
                else if (currentKeyState.IsKeyDown(Keys.Right) && _prevKeyState.IsKeyDown(Keys.Right))
                    direction = EODirection.Right;
                else if ((currentKeyState.IsKeyDown(Keys.LeftControl) || currentKeyState.IsKeyDown(Keys.RightControl)) &&
                         (_prevKeyState.IsKeyDown(Keys.LeftControl) || _prevKeyState.IsKeyDown(Keys.RightControl)))
                {
                    attacking = true;
                    direction = _char.RenderData.facing;
                    startWalkingThroughPlayerTime = null;
                }
                else
                {
                    //on 'else': code path should return without doing anything
                    _checkAndHandleEmote(currentKeyState);
                    startWalkingThroughPlayerTime = null;
                }

                byte destX, destY;
                switch (direction)
                {
                    case EODirection.Up:
                        destX = (byte) _char.X;
                        destY = (byte) (_char.Y - 1);
                        break;
                    case EODirection.Down:
                        destX = (byte) _char.X;
                        destY = (byte) (_char.Y + 1);
                        break;
                    case EODirection.Right:
                        destX = (byte) (_char.X + 1);
                        destY = (byte) _char.Y;
                        break;
                    case EODirection.Left:
                        destX = (byte) (_char.X - 1);
                        destY = (byte) _char.Y;
                        break;
                    default:
                        if (State != CharacterActionState.Walking)
                            _prevKeyState = currentKeyState; //only set this when not walking already
                        destX = destY = 255;
                        break;
                }

                if (destX > World.Instance.ActiveMapRenderer.MapRef.Width || destY > World.Instance.ActiveMapRenderer.MapRef.Height)
                {
                    //this will execute when the direction above is invalid.
                    //so, if not attacking and not walking we will hit this.
                    return;
                }

                //reset the sleeping emote time trackers
                m_lastActTime = DateTime.Now;
                m_lastEmoteTime = null;

                if (!attacking)
                {
                    //valid direction at this point
                    if (_char.RenderData.facing != direction)
                    {
                        _char.Face(direction);
                        return;
                    }

                    TileInfo info = World.Instance.ActiveMapRenderer.GetTileInfo(destX, destY);
                    switch (info.ReturnType)
                    {
                        case TileInfoReturnType.IsOtherPlayer:
                            if (NoWall) goto case TileInfoReturnType.IsTileSpec;

                            EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_KEEP_MOVING_THROUGH_PLAYER);
                            if(startWalkingThroughPlayerTime == null)
                                startWalkingThroughPlayerTime = gameTime;
                            else if ((gameTime.TotalGameTime.TotalSeconds - startWalkingThroughPlayerTime.TotalGameTime.TotalSeconds) > 3)
                            {
                                startWalkingThroughPlayerTime = null;
                                goto case TileInfoReturnType.IsTileSpec;
                            }
                            break;
                        case TileInfoReturnType.IsOtherNPC:
                            if (NoWall) goto case TileInfoReturnType.IsTileSpec;
            #if DEBUG
                            EOGame.Instance.Hud.SetStatusLabel("OTHER NPC IS HERE"); //idk what's supposed to happen here, I think nothing?
            #endif
                            break;
                        case TileInfoReturnType.IsWarpSpec:
                            if (NoWall) goto case TileInfoReturnType.IsTileSpec;
                            if (info.Warp.door != DoorSpec.NoDoor)
                            {
                                DoorSpec doorOpened;
                                if (!info.Warp.doorOpened && !info.Warp.backOff)
                                {
                                    if ((doorOpened = Character.CanOpenDoor(info.Warp)) == DoorSpec.Door)
                                        World.Instance.ActiveMapRenderer.StartOpenDoor(info.Warp, destX, destY);
                                }
                                else
                                {
                                    //normal walking
                                    if ((doorOpened = Character.CanOpenDoor(info.Warp)) == DoorSpec.Door)
                                        _chkWalk(TileSpec.None, direction, destX, destY);
                                }

                                if (doorOpened != DoorSpec.Door)
                                {
                                    string strWhichKey = "[error key?]";
                                    switch (doorOpened)
                                    {
                                        case DoorSpec.LockedCrystal:
                                            strWhichKey = "Crystal Key";
                                            break;
                                        case DoorSpec.LockedSilver:
                                            strWhichKey = "Silver Key";
                                            break;
                                        case DoorSpec.LockedWraith:
                                            strWhichKey = "Wraith Key";
                                            break;
                                    }

                                    EODialog.Show(DATCONST1.DOOR_LOCKED, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                                    ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_THE_DOOR_IS_LOCKED_EXCLAMATION,
                                        " - " + strWhichKey);
                                }
                            }
                            else if (info.Warp.levelRequirement != 0 && Character.Stats.level < info.Warp.levelRequirement)
                            {
                                EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING,
                                    DATCONST2.STATUS_LABEL_NOT_READY_TO_USE_ENTRANCE,
                                    " - LVL " + info.Warp.levelRequirement);
                            }
                            else
                            {
                                //normal walking
                                _chkWalk(TileSpec.None, direction, destX, destY);
                            }
                            break;
                        case TileInfoReturnType.IsTileSpec:
                            _chkWalk(info.Spec, direction, destX, destY);
                            break;
                    }
                }
                else if(State == CharacterActionState.Standing)
                {
                    if (Character.CanAttack)
                    {
                        TileInfo info = World.Instance.ActiveMapRenderer.GetTileInfo((byte)Character.X, (byte)Character.Y);
                        Character.Attack(Data.facing, destX, destY); //destX and destY validity check above
                        PlayerAttack(info.ReturnType == TileInfoReturnType.IsTileSpec && info.Spec == TileSpec.Water);
                    }
                    else if(Character.Weight > Character.MaxWeight)
                    {
                        EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_CANNOT_ATTACK_OVERWEIGHT);
                    }
                }

                if (State == CharacterActionState.Standing) _prevKeyState = currentKeyState; //only set this when not walking already
            }
            #endregion
        }
Exemplo n.º 43
0
		private void OnRecordCreated(ItemRecord record)
		{
			if (IsCharter)
			{
				PetitionRecord charter;
				if (!record.IsNew)
				{
					// this is executed in the IO-context
					charter = PetitionRecord.LoadRecord(record.EntityLowId);
				}
				else
				{
					charter = new PetitionRecord((uint)record.OwnerId, record.EntityLowId);
				}
			}
		}
Exemplo n.º 44
0
 /// <summary>
 /// Tries to store the given item in the given slot. No merge attempted.
 /// </summary>
 /// <param name="item">The item to store.</param>
 /// <param name="slot">The slot to store it in.</param>
 /// <returns>The <see cref="ItemRecord" /> that was in the slot (or the original <see cref="ItemRecord" /> minus the items that were merged) 
 /// or null if the store/merge was successful.</returns>
 public ItemRecord StoreItemInSlot(ItemRecord item, int slot)
 {
     return StoreItemInSlot(item, slot, false);
 }
Exemplo n.º 45
0
 private bool _addItemToSlot(int slot, ItemRecord item, int count = 1)
 {
     return _addItemToSlot(m_filledSlots, slot, item, count);
 }
Exemplo n.º 46
0
        /// <summary>
        /// Places the given amount of the given item stack in the given slot (or tries mergeing at slot if indicated).
        /// Make sure that the depositer has deposit rights to this BankTab!
        /// </summary>
        /// <param name="item">The <see cref="ItemRecord" /> to store.</param>
        /// <param name="amount">The amount of items from the stack to store.</param>
        /// <param name="slot">The slotId where you want to store.</param>
        /// <param name="allowMerge">Whether or not to try and merge the stacks.</param>
        /// <returns>The <see cref="ItemRecord" /> that was in the slot (or the original <see cref="ItemRecord" /> minus the items that were merged) 
        /// or null if the store/merge was successful.</returns>
        public ItemRecord StoreItemInSlot(ItemRecord item, int amount, int slot, bool allowMerge)
        {
            if (slot >= GuildMgr.MAX_BANK_TAB_SLOTS) return item;
            if (item.Amount < amount) return item; // Cheater!

            var curItem = this[slot];
            if (curItem == null)
            {
                // the slot is empty, rock on 
                this[slot] = item;
                return null;
            }

            if (allowMerge && this[slot].EntryId == item.EntryId)
            {
                // try to merge the stacks.
                var freeSpace = (int)curItem.Template.MaxAmount - curItem.Amount;
                freeSpace = Math.Min(freeSpace, amount);

                curItem.Amount += freeSpace;
                item.Amount -= freeSpace;

                return item.Amount > 0 ? item : null;
            }

            // gonna swap
            this[slot] = item;
            return curItem;
        }