示例#1
0
        public void CreateBaseFileTest(FileType fileType, ItemType?expected)
        {
            var baseFile = CreateBaseFile(fileType);
            var actual   = DatItem.Create(baseFile);

            Assert.Equal(expected, actual?.ItemType);
        }
        public async Task <Player[]> GetAll(
            int?minScore,
            PlayerTag?tag,
            ItemType?itemType,
            int?itemCount
            )
        {
            var playerList = await playerRepository.GetAll();

            var playerSelection = playerList.Where(player => true);

            if (minScore != null)
            {
                playerSelection = playerSelection.Where(player => player.Score >= minScore);
            }

            if (tag != null)
            {
                playerSelection = playerSelection.Where(player => player.Tag == tag);
            }

            if (itemType != null)
            {
                playerSelection = playerSelection.Where(player => player.Items.Any(item => item.Type == itemType));
            }

            if (itemCount != null)
            {
                playerSelection = playerSelection.Where(player => player.Items.Count >= itemCount);
            }

            return(playerSelection.ToArray());
        }
示例#3
0
        public override FileSystemItem GetItemInfo(string path, ItemType?type, bool swallowException)
        {
            if (path == _drive.Path)
            {
                return(_drive);
            }
            var entry = GetEntry(path);

            if (entry == null)
            {
                return(null);
            }

            var item = CreateModel(entry);

            if (type != null)
            {
                if ((type == ItemType.File && item.Type != ItemType.File) ||
                    (type != ItemType.File && item.Type != ItemType.Directory))
                {
                    return(null);
                }
                item.Type = type.Value;
            }
            return(item);
        }
示例#4
0
        public int?AddFavorite(int favoriteUserId, int favoriteItemId, ItemType?favoriteItemType)
        {
            if (favoriteItemType == null)
            {
                favoriteItemType = itemRepository.ItemTypeForItemId(favoriteItemId);
            }

            int?itemId = itemRepository.GenerateItemId(ItemType.Favorite);

            if (itemId == null)
            {
                return(null);
            }

            Favorite fav = new Favorite()
            {
                FavoriteId = itemId, FavoriteUserId = favoriteUserId, FavoriteItemId = favoriteItemId, FavoriteItemTypeId = (int)favoriteItemType
            };

            fav.TimeStamp = DateTime.UtcNow.ToUnixTime();

            this.database.InsertObject <Favorite>(fav);

            return(itemId);
        }
示例#5
0
    void UpdateInventory()//updates the inventory when changes are made
    {
        ItemType?type = sortType == "All" || sortType == "" ? null : (ItemType?)System.Enum.Parse(typeof(ItemType), sortType);

        int filterCount = 0;

        for (int i = 0; i < inv.Count; i++)
        {
            var item = inv[i];
            if (type == null || item.Type == (ItemType)type)
            {
                int index       = i;
                var displaySlot = inventoryDisplays[filterCount];
                displaySlot.itemImage.color  = Color.white;
                displaySlot.itemImage.sprite = item.Icon;
                displaySlot.button.onClick.RemoveAllListeners();
                displaySlot.button.onClick.AddListener(() => SelectItem(index));
                filterCount++;
            }
        }
        for (int i = filterCount; i < inventoryDisplays.Length; i++)
        {
            var displaySlot = inventoryDisplays[i];
            displaySlot.itemImage.color = new Color(0, 0, 0, 0);
            displaySlot.button.onClick.RemoveAllListeners();
        }
    }
示例#6
0
 public void SetItemType(ItemType?newType)
 {
     type = newType;
     if (newType == null)
     {
         itemImage.color = new Color(1, 1, 1, 0);
     }
     else
     {
         var type = newType.Value;
         itemImage.color  = Color.white;
         itemImage.sprite = Item.GetSpriteForItem(type);
         var size = Item.GetItemInventorySize(type);
         var rt   = itemImage.rectTransform;
         if (size == 1)
         {
             rt.offsetMax = Vector2.zero;
             rt.offsetMin = Vector2.zero;
         }
         else
         {
             rt.offsetMax = new Vector2(50, 0);
             rt.offsetMin = new Vector2(0, -50);
         }
     }
 }
示例#7
0
        /// <summary>
        /// Tries to add or replace an item in the inventory.
        /// </summary>
        /// <param name="itemType"><see cref="Enums.ItemType"/>; <c>Null</c> for coins</param>
        /// <param name="quantity">Quantity.</param>
        /// <returns><c>True</c> if the item has been added; <c>False</c> otherwise.</returns>
        internal int TryAdd(ItemType?itemType, int quantity)
        {
            if (!itemType.HasValue)
            {
                int toReachLimit = Constants.Inventory.COINS_LIMIT - Coins;
                if (toReachLimit == 0 || toReachLimit < quantity)
                {
                    Coins += toReachLimit;
                    return(quantity - toReachLimit);
                }
                else
                {
                    Coins += quantity;
                    return(0);
                }
            }

            int remaining = 0;

            if (_items.Any(item => item.BaseItem.Type == itemType.Value))
            {
                remaining = _items.First(item => item.BaseItem.Type == itemType.Value).TryStore(quantity, _maxQuantityByItem[itemType.Value]);
            }
            else
            {
                _items.Add(new InventoryItem(itemType.Value, quantity));
                SetItemMaxQuantity(itemType.Value, Item.GetItem(itemType.Value).InitialMaximalQuantity);
            }
            return(remaining);
        }
        public IEnumerable <Item> GetLatest(ItemType?type, DateTime?fromDate, DateTime?toDate, int?limit)
        {
            var query = this.Items.AsQueryable();

            if (type.HasValue)
            {
                query = query.Where(i => i.ItemType == type.Value);
            }

            if (fromDate.HasValue)
            {
                query = query.Where(i => i.Published > fromDate.Value);
            }

            if (toDate.HasValue)
            {
                query = query.Where(i => i.Published < toDate.Value);
            }

            query = query.OrderByDescending(i => i.Published);

            if (limit.HasValue)
            {
                query = query.Take(limit.Value);
            }

            return(query.ToList());
        }
示例#9
0
        /// <summary>
        /// 取得(內頁、列表頁)
        /// </summary>
        /// <param name="routeName">Name of the route.</param>
        /// <param name="viewName">Name of the view.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <returns></returns>
        public CiResult <object> Get(string routeName, ref string viewName, ItemType?itemType = null)
        {
            //(Update ViewCount)
            var data = service.GetByRoteName(routeName, ApplicationHelper.DefaultLanguage, addViewCount: true);

            return(ShowItem(data, ref viewName, itemType));
        }
示例#10
0
        public OrderLineQuery WithType(ItemType?value = null,
                                       ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral,
                                       EnumOperator @operator      = EnumOperator.Equal)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case EnumOperator.Equal:
                Entities = Entities.Where(ol => ol.Type == value);
                return(this);

            case EnumOperator.NotEqual:
                Entities = Entities.Where(ol => ol.Type != value);
                return(this);

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
示例#11
0
 public ItemDataMod(int id,
                    string itemName,
                    ItemType?itemType,
                    string itemDescription,
                    int?energyDefinitionID,
                    SpriteInfo itemSpriteInfo,
                    PuzzleAffectionType?affectionType,
                    int?tooltipColorIndex,
                    ItemGiveConditionType?giveConditionType,
                    int?girlDefinitionID,
                    bool?difficultyExclusive,
                    SettingDifficulty?difficulty,
                    bool?storeSectionPreference,
                    int?storeCost,
                    ItemFoodType?foodType,
                    bool?noStaminaCost,
                    ItemShoesType?shoesType,
                    ItemUniqueType?uniqueType,
                    ItemDateGiftType?dateGiftType,
                    bool?dateGiftAilment,
                    int?abilityDefinitionID,
                    int?useCost,
                    EditorDialogTriggerTab?baggageGirl,
                    int?cutsceneDefinitionID,
                    int?ailmentDefinitionID,
                    string categoryDescription,
                    string costDescription,
                    int?notifierHeaderIndex,
                    bool isAdditive = false)
     : base(id, isAdditive)
 {
     ItemName               = itemName;
     ItemType               = itemType;
     ItemDescription        = itemDescription;
     EnergyDefinitionID     = energyDefinitionID;
     ItemSpriteInfo         = itemSpriteInfo;
     AffectionType          = affectionType;
     TooltipColorIndex      = tooltipColorIndex;
     GiveConditionType      = giveConditionType;
     GirlDefinitionID       = girlDefinitionID;
     DifficultyExclusive    = difficultyExclusive;
     Difficulty             = difficulty;
     StoreSectionPreference = storeSectionPreference;
     StoreCost              = storeCost;
     FoodType               = foodType;
     NoStaminaCost          = noStaminaCost;
     ShoesType              = shoesType;
     UniqueType             = uniqueType;
     DateGiftType           = dateGiftType;
     DateGiftAilment        = dateGiftAilment;
     AbilityDefinitionID    = abilityDefinitionID;
     UseCost              = useCost;
     BaggageGirl          = baggageGirl;
     CutsceneDefinitionID = cutsceneDefinitionID;
     AilmentDefinitionID  = ailmentDefinitionID;
     CategoryDescription  = categoryDescription;
     CostDescription      = costDescription;
     NotifierHeaderIndex  = notifierHeaderIndex;
 }
示例#12
0
 public ExplorerItemModel(ItemType?type, string label, object obj, string imagePath = null)
 {
     Type      = type;
     Label     = label;
     Children  = new ObservableCollection <ExplorerItemModel>();
     Object    = obj;
     ImagePath = imagePath;
 }
        public bool ItemEvaluate(Item newItem, PriceGroup priceGroup, bool updatePrice = false)
        {
            if (!CheckItemCanEvaluate(newItem))
            {
                return(false);
            }

            Item oldItem = itemId >= 0 ? Item.GetById(itemId) : null;

            if (ItemName != newItem.Name)
            {
                ItemCode  = newItem.Code;
                ItemName  = newItem.Name;
                ItemName2 = newItem.Name2;
            }

            Item = newItem;
            if (oldItem == null || newItem.Id != oldItem.Id)
            {
                ItemId      = newItem.Id;
                ItemGroupId = newItem.GroupId;
                VatGroup    = newItem.GetVATGroup();
                itemType    = newItem.Type;

                if (string.IsNullOrEmpty(newItem.MUnit))
                {
                    MesUnit [] units = MesUnit.GetByItem(newItem);
                    MUnitName = units == null?Translator.GetString("pcs.") : units [0].Name;
                }
                else
                {
                    MUnitName = newItem.MUnit;
                }

                if (oldItem == null)
                {
                    ResetQuantity();
                }
            }

            if (oldItem == null || newItem.Id != oldItem.Id || updatePrice)
            {
                UpdatePrices(newItem, priceGroup);
                VATEvaluate();
                TotalEvaluate();
            }

            var afterHandler = AfterItemEvaluate;

            if (afterHandler != null)
            {
                afterHandler(this, new AfterItemEvaluateArgs {
                    Item = newItem
                });
            }

            return(true);
        }
示例#14
0
        public void GenerateRelatedItems(int number = 0, ItemType?type = null)
        {
            Items = new List <Item>();
            // ensure no null reference.
            // todo handle this better
            if (number == 0 && MundaneAmount == null)
            {
                MundaneAmount = new Dice(0, 0);
            }
            var         amount   = number == 0 ? MundaneAmount.Roll() : number;
            List <Item> genItems = new List <Item>(amount);

            //if (type.HasValue)
            //{

            //    ItemType swType = type.Value;

            //    switch (swType)
            //    {
            //        case ItemType.Ammo:
            //            genItems.AddRange(Ammunition);
            //            break;
            //        case ItemType.Armor:
            //            genItems.AddRange(Armor);
            //            genItems.AddRange(LightArmor);
            //            genItems.AddRange(MediunArmor);
            //            break;
            //        case ItemType.Weapon:
            //            genItems.AddRange(Weapons);
            //            break;
            //        case ItemType.Gear:
            //            genItems.AddRange(AdventuringGear);
            //            break;
            //        default:
            //            break;
            //    }
            //}
            //else
            //{
            //    genItems = StaticData.Instance.AllItems;
            //}
            genItems = StaticData.RangedWeapons.Select(p => p.Value).ToList();
            var ran = new Random();

            for (int i = 0; i < amount; i++)
            {
                var tempItem = genItems[ran.Next(0, genItems.Count)];
                if (tempItem.RelatedItems.Count > 0)
                {
                    // TODO limit amount generated when generating related items
                    foreach (var relIt in tempItem.RelatedItems)
                    {
                        Items.Add(StaticData.Instance.AllCombinedItems[relIt]);
                    }
                }
                Items.Add(tempItem);
            }
        }
示例#15
0
        /// <summary>
        /// Returns copy of item definition.
        /// </summary>
        public ItemDefinition GenerateAny(ItemRarity?rarity = null, ItemType?type = null)
        {
            var items = new List <ItemDefinition>();

            rarity ??= GenerateRarity();
            type ??= GenerateType();
            items = data.TypeToRarityItemCollection[type.Value][rarity.Value];

            return(items[ItemRandom.Next(items.Count)].CreateCopy());
        }
示例#16
0
        public override FileSystemItem GetItemInfo(string path, ItemType?type, bool swallowException)
        {
            NotifyTransferStarted(false);
            try
            {
                var itemName = LocateDirectory(path);
                var item     = FtpClient.GetListing().FirstOrDefault(i => i.Name == itemName);
                NotifyTransferFinished();
                if (item == null)
                {
                    return(null);
                }
                if (type != null)
                {
                    FtpFileSystemObjectType ftpItemType;
                    switch (type)
                    {
                    case ItemType.File:
                        ftpItemType = FtpFileSystemObjectType.File;
                        break;

                    case ItemType.Directory:
                    case ItemType.Drive:
                        ftpItemType = FtpFileSystemObjectType.Directory;
                        break;

                    case ItemType.Link:
                        ftpItemType = FtpFileSystemObjectType.Link;
                        break;

                    default:
                        throw new NotSupportedException("Invalid item type:" + type);
                    }
                    if (item.Type != ftpItemType)
                    {
                        return(null);
                    }
                }
                var m = CreateModel(item, path);
                if (type != null)
                {
                    m.Type = type.Value;
                }
                return(m);
            }
            catch
            {
                NotifyTransferFinished();
                if (swallowException)
                {
                    return(null);
                }
                throw;
            }
        }
示例#17
0
 Item GetItemUnderCursor(ItemType?type = null)
 {
     foreach (Item itemObj in placedItems)
     {
         if (itemObj.pos == current.pos && (type == null || type == itemObj.type))
         {
             return(itemObj);
         }
     }
     return(null);
 }
示例#18
0
        public override FileSystemItem GetItemInfo(string itemPath, ItemType?type, bool swallowException)
        {
            var fake = C.Fake <FileSystemItem>();

            fake.Path = itemPath;
            if (type != null)
            {
                fake.Type = type.Value;
            }
            return(fake);
        }
 protected override void Because_of()
 {
     try
     {
         m_ReturnedItemType = m_App.GetItemType (m_Item);
     }
     catch (Exception ex)
     {
         m_Because_of_Exception = ex;
     }
 }
示例#20
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="id"><see cref="Sprite.Id"/></param>
 /// <param name="x"><see cref="Sprite.X"/></param>
 /// <param name="y"><see cref="Sprite.Y"/></param>
 /// <param name="width"><see cref="Sprite.Width"/></param>
 /// <param name="height"><see cref="Sprite.Height"/></param>
 /// <param name="itemType"><see cref="ItemType"/></param>
 /// <param name="quantity"><see cref="Quantity"/></param>
 /// <param name="timeBeforeDisapear"><see cref="_timeManager"/> lifetime, in milliseconds.</param>
 internal PickableItem(int id, double x, double y, double width, double height,
                       ItemType?itemType, int quantity, double?timeBeforeDisapear)
     : base(id, x, y, width, height, RenderType.Image, new[] { itemType.HasValue?itemType.Value.ToString() : nameof(Filename.Coin) })
 {
     ItemType = itemType;
     Quantity = quantity;
     if (timeBeforeDisapear.HasValue)
     {
         _timeManager = new Elapser(this, ElapserUse.PickableItemLifetime, timeBeforeDisapear.Value);
     }
 }
示例#21
0
 /// <summary>
 /// Builds an instance from enemy's loot.
 /// </summary>
 /// <param name="enemy"><see cref="Enemy"/></param>
 /// <param name="itemType"><see cref="Enums.ItemType"/>; <c>Null</c> for coin.</param>
 /// <param name="quantity">Quantity looted.</param>
 /// <returns><see cref="PickableItem"/></returns>
 internal static PickableItem Loot(Enemy enemy, ItemType?itemType, int quantity)
 {
     return(new PickableItem(
                0,
                enemy.X + (enemy.Width / 2) - (Constants.Item.LOOT_WIDTH / 2),
                enemy.Y + (enemy.Height / 2) - (Constants.Item.LOOT_HEIGHT / 2),
                Constants.Item.LOOT_WIDTH,
                Constants.Item.LOOT_HEIGHT,
                itemType,
                quantity,
                Constants.Item.LOOT_LIFETIME));
 }
示例#22
0
        public TreeNodeModel(ProviderServiceBase service, AccountModelBase account, ItemType?nodeType)
        {
            Service  = service;
            Account  = account;
            Children = new ObservableCollection <TreeNodeModel>();
            NodeType = nodeType;

            if (Service != null && Account != null)
            {
                _shared = ServiceLocator.Instance.GetService <SharedService>();
                _shared.ApplicationConfiguration.PropertyChanged += OnApplicationConfigChanged;
            }
        }
示例#23
0
 public override FileSystemItem GetItemInfo(string path, ItemType?type, bool swallowException)
 {
     if (path.EndsWith("\\") && Directory.Exists(path))
     {
         return(GetDirectoryInfo(path, type));
     }
     if (File.Exists(path))
     {
         return(GetFileInfo(path));
     }
     path += Slash;
     return(Directory.Exists(path) ? GetDirectoryInfo(path, type) : null);
 }
示例#24
0
    //method to handle item filtering
    //if filter is not emply, add item to filter
    //call updateUI method
    public void UpdateFilters(int itemTypeIndex)
    {
        if (itemTypeIndex == 0)
        {
            filter = null;
        }
        else
        {
            filter = (ItemType)itemTypeIndex;
        }

        UpdateUi();
    }
示例#25
0
        public void GenerateMundaneItems(int number = 0, ItemType?type = null)
        {
            MundaneItems = new List <string>();
            // ensure no null reference.
            // todo handle this better
            if (number == 0 && MundaneAmount == null)
            {
                MundaneAmount = new Dice(0, 0);
            }
            List <string> genItems = new List <string>();

            if (type.HasValue)
            {
                ItemType swType = type.Value;

                switch (swType)
                {
                case ItemType.Ammo:
                    genItems.AddRange(Ammunition);
                    break;

                case ItemType.Armor:
                    genItems.AddRange(Armor);
                    genItems.AddRange(LightArmor);
                    genItems.AddRange(MediunArmor);
                    break;

                case ItemType.Weapon:
                    genItems.AddRange(Weapons);
                    break;

                case ItemType.Gear:
                    genItems.AddRange(AdventuringGear);
                    break;

                default:
                    break;
                }
            }
            else
            {
                genItems = StaticData.Instance.AllItems;
            }
            var ran    = new Random();
            var amount = number == 0 ? MundaneAmount.Roll() : number;

            for (int i = 0; i < amount; i++)
            {
                MundaneItems.Add(genItems[ran.Next(0, genItems.Count)]);
            }
        }
示例#26
0
        private bool TryAddExceptionIfItemsHaveDifferentCount(
            ICollection <TestletMustHaveFixedNumberOfItemsException> exceptions,
            int expectedCount,
            IReadOnlyList <Item> items,
            ItemType?ofType = default)
        {
            if (items.Count != expectedCount)
            {
                exceptions.Add(new TestletMustHaveFixedNumberOfItemsException(expectedCount, ofType));
                return(true);
            }

            return(false);
        }
示例#27
0
        public virtual IPagedList <Item> SearchItems(
            int pageIndex           = 0,
            int pageSize            = int.MaxValue,
            IList <int> categoryIds = null,
            ItemType?itemType       = null,
            string keywords         = null
            )
        {
            if (categoryIds != null && categoryIds.Contains(0))
            {
                categoryIds.Remove(0);
            }

            // товары через linq запросы
            var query = _itemRepository.Table.Where(i => i.User.Id == _workContext.CurrentUser.Id);

            query = query.Where(i => !i.Deleted);

            if (itemType.HasValue)
            {
                var itemTypeId = (int)itemType.Value;
                query = query.Where(i => i.ItemTypeId == itemTypeId);
            }

            // поиск по ключевым словам
            if (!String.IsNullOrWhiteSpace(keywords))
            {
                query = from i in query
                        where (i.Name.Contains(keywords))
                        select i;
            }

            if (categoryIds != null && categoryIds.Any())
            {
                query = from i in query
                        from ic in i.ItemCategories.Where(ic => categoryIds.Contains(ic.CategoryId))
                        select i;
            }

            query = from i in query
                    group i by i.Id
                    into iGroup
                    orderby iGroup.Key
                    select iGroup.FirstOrDefault();

            var items = new PagedList <Item>(query, pageIndex, pageSize);

            return(items);
        }
示例#28
0
        public MockEnvironment Delete(string tfsPath, ItemType?itemType = null, ChangeType?changeType = null)
        {
            _item = new Mock <IItem>();
            _item.Setup(i => i.ChangesetId).Returns(_changeset.Object.ChangesetId);
            _item.Setup(i => i.HashValue).Returns(new byte[] { });
            _item.Setup(i => i.ItemType).Returns(itemType ?? ItemType.File);
            _item.Setup(i => i.ServerItem).Returns(tfsPath);

            _change = new Mock <IChange>();
            _change.Setup(c => c.ChangeType).Returns(changeType ?? ChangeType.Delete);
            _change.Setup(c => c.Item).Returns(_item.Object);
            _changes.Add(_change.Object);

            return(this);
        }
示例#29
0
        public static Item CreateItem(int level, ItemType?itemType = null)
        {
            var      rnd  = new Random();
            ItemType type = itemType ?? (ItemType)rnd.Next(0, 2);
            int      mult = (type == ItemType.Food) ? 2 : 1;

            return(new Item()
            {
                ItemType = type,
                ItemName = itemList[type][rnd.Next(0, itemList[type].Length)],
                Damage = rnd.Next(5 + level * 5, 15 + level * 5) * mult,
                Value = 0,
                ItemLevel = level
            });
        }
        public static ItemDescriptor GetItemDescriptor(Guid id, ItemType?type = null)
        {
            foreach (var desc in ItemDescriptors)
            {
                if (desc.Id.Equals(id))
                {
                    return(desc);
                }
            }

            var desc2 = new ItemDescriptor(id, type ?? ItemType.Unknown, null);

            ItemDescriptors.Add(desc2);
            return(desc2);
        }
示例#31
0
        private FileSystemItem GetDirectoryInfo(string path, ItemType?type = null)
        {
            if (!path.EndsWith("\\"))
            {
                path += Slash;
            }
            var dirInfo = new FileInfo(path);

            return(new FileSystemItem
            {
                Name = Path.GetFileName(path.TrimEnd(Slash)),
                Type = type ?? (dirInfo.Attributes.HasFlag(FileAttributes.ReparsePoint) ? ItemType.Link : ItemType.Directory),
                Date = dirInfo.LastWriteTime,
                Path = path,
                FullPath = path
            });
        }
示例#32
0
 public StreamFilter WithItemType(ItemType itemType)
 {
     Type = itemType;
     return this;
 }
示例#33
0
文件: Item.cs 项目: Gravenet/POLUtils
 protected override void LoadField(string Field, System.Xml.XmlElement Node)
 {
     switch (Field)
     {
         // "Simple" Fields
         case "activation-time":
             this.ActivationTime_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "casting-time":
             this.CastingTime_ = (byte)this.LoadUnsignedIntegerField(Node);
             break;
         case "damage":
             this.Damage_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "delay":
             this.Delay_ = (short)this.LoadSignedIntegerField(Node);
             break;
         case "description":
             this.Description_ = this.LoadTextField(Node);
             break;
         case "dps":
             this.DPS_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "element":
             this.Element_ = (Element)this.LoadHexField(Node);
             break;
         case "element-charge":
             this.ElementCharge_ = (uint)this.LoadUnsignedIntegerField(Node);
             break;
         case "flags":
             this.Flags_ = (ItemFlags)this.LoadHexField(Node);
             break;
         case "id":
             this.ID_ = (uint)this.LoadUnsignedIntegerField(Node);
             break;
         case "iLevel:":
             this.iLevel_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "instinct-cost:":
             this.iLevel_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "jobs":
             this.Jobs_ = (Job)this.LoadHexField(Node);
             break;
         case "jug-size":
             this.JugSize_ = (byte)this.LoadUnsignedIntegerField(Node);
             break;
         case "level":
             this.Level_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "log-name-plural":
             this.LogNamePlural_ = this.LoadTextField(Node);
             break;
         case "log-name-singular":
             this.LogNameSingular_ = this.LoadTextField(Node);
             break;
         case "max-charges":
             this.MaxCharges_ = (byte)this.LoadUnsignedIntegerField(Node);
             break;
         case "name":
             this.Name_ = this.LoadTextField(Node);
             break;
         case "puppet-slot":
             this.PuppetSlot_ = (PuppetSlot)this.LoadHexField(Node);
             break;
         case "races":
             this.Races_ = (Race)this.LoadHexField(Node);
             break;
         case "resource-id":
             this.ResourceID_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "reuse-delay":
             this.ReuseDelay_ = (uint)this.LoadUnsignedIntegerField(Node);
             break;
         case "superior-level":
             this.SuperiorLevel_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "shield-size":
             this.ShieldSize_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "skill":
             this.Skill_ = (Skill)this.LoadHexField(Node);
             break;
         case "slots":
             this.Slots_ = (EquipmentSlot)this.LoadHexField(Node);
             break;
         case "stack-size":
             this.StackSize_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "storage-slots":
             this.StorageSlots_ = (int)this.LoadSignedIntegerField(Node);
             break;
         case "type":
             this.Type_ = (ItemType)this.LoadHexField(Node);
             break;
         case "unknown-1":
             this.Unknown1_ = (uint)this.LoadUnsignedIntegerField(Node);
             break;
         case "unknown-2":
             this.Unknown2_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "unknown-3":
             this.Unknown3_ = (uint)this.LoadUnsignedIntegerField(Node);
             break;
         case "unknown-4":
             this.Unknown4_ = (uint)this.LoadUnsignedIntegerField(Node);
             break;
         case "use-delay":
             this.UseDelay_ = (ushort)this.LoadUnsignedIntegerField(Node);
             break;
         case "valid-targets":
             this.ValidTargets_ = (ValidTarget)this.LoadHexField(Node);
             break;
         // Sub-Things
         case "icon":
             if (this.Icon_ == null)
             {
                 this.Icon_ = new Graphic();
             }
             this.LoadThingField(Node, this.Icon_);
             break;
     }
 }
示例#34
0
文件: Item.cs 项目: Gravenet/POLUtils
        public bool Read(BinaryReader BR, Type T)
        {
            this.Clear();
            try
            {
                byte[] ItemBytes = BR.ReadBytes(0xC00);
                FFXIEncryption.Rotate(ItemBytes, 5);
                BR = new BinaryReader(new MemoryStream(ItemBytes, false));
                BR.BaseStream.Seek(0x280, SeekOrigin.Begin);
                Graphic G = new Graphic();
                int GraphicSize = BR.ReadInt32();
                if (GraphicSize < 0 || !G.Read(BR) || BR.BaseStream.Position != 0x280 + 4 + GraphicSize)
                {
                    BR.Close();
                    return false;
                }
                this.Icon_ = G;
                BR.BaseStream.Seek(0, SeekOrigin.Begin);
            }
            catch
            {
                return false;
            }
            // Common Fields (14 bytes)
            this.ID_ = BR.ReadUInt32();
            this.Flags_ = (ItemFlags)BR.ReadUInt16();
            this.StackSize_ = BR.ReadUInt16(); // 0xe0ff for Currency, which kinda suggests this is really 2 separate bytes
            this.Type_ = (ItemType)BR.ReadUInt16();
            this.ResourceID_ = BR.ReadUInt16();
            this.ValidTargets_ = (ValidTarget)BR.ReadUInt16();
            // Extra Fields (22/30/10/6/2 bytes for Armor/Weapon/Puppet/Item/UsableItem)

            if (T == Type.Armor || T == Type.Weapon)
            {
                this.Level_ = BR.ReadUInt16();
                this.Slots_ = (EquipmentSlot)BR.ReadUInt16();
                this.Races_ = (Race)BR.ReadUInt16();
                this.Jobs_ = (Job)BR.ReadUInt32();
                this.SuperiorLevel_ = BR.ReadUInt16();
                if (T == Type.Armor)
                {
                    this.ShieldSize_ = BR.ReadUInt16();
                }
                else
                {
                    // Weapon
                    this.Unknown4_ = BR.ReadUInt16();
                    this.Damage_ = BR.ReadUInt16();
                    this.Delay_ = BR.ReadInt16();
                    this.DPS_ = BR.ReadUInt16();
                    this.Skill_ = (Skill)BR.ReadByte();
                    this.JugSize_ = BR.ReadByte();
                    this.Unknown1_ = BR.ReadUInt32();
                }
                this.MaxCharges_ = BR.ReadByte();
                this.CastingTime_ = BR.ReadByte();
                this.UseDelay_ = BR.ReadUInt16();
                this.ReuseDelay_ = BR.ReadUInt32();
                this.Unknown2_ = BR.ReadUInt16();
                this.iLevel_ = BR.ReadUInt16();
                this.Unknown3_ = BR.ReadUInt32();
            }
            else if (T == Type.PuppetItem)
            {
                this.PuppetSlot_ = (PuppetSlot)BR.ReadUInt16();
                this.ElementCharge_ = BR.ReadUInt32();
                this.Unknown3_ = BR.ReadUInt32();
            }
            else if (T == Type.Instinct)
            {
                BR.ReadUInt32();
                BR.ReadUInt32();
                BR.ReadUInt16();
                this.InstinctCost_ = BR.ReadUInt16();
                BR.ReadUInt16();
                BR.ReadUInt32();
                BR.ReadUInt32();
                BR.ReadUInt32();
            }
            else if (T == Type.Item)
            {
                switch (this.Type_.Value)
                {
                    case ItemType.Flowerpot:
                    case ItemType.Furnishing:
                    case ItemType.Mannequin:
                        this.Element_ = (Element)BR.ReadUInt16();
                        this.StorageSlots_ = BR.ReadInt32();
                        this.Unknown3_ = BR.ReadUInt32();
                        break;
                    default:
                        this.Unknown2_ = BR.ReadUInt16();
                        this.Unknown3_ = BR.ReadUInt32();
                        this.Unknown3_ = BR.ReadUInt32();
                        break;
                }
            }
            else if (T == Type.UsableItem)
            {
                this.ActivationTime_ = BR.ReadUInt16();
                this.Unknown1_ = BR.ReadUInt32();
                this.Unknown3_ = BR.ReadUInt32();
                this.Unknown4_ = BR.ReadUInt32();
            }
            else if (T == Type.Currency)
            {
                this.Unknown2_ = BR.ReadUInt16();
            }
            else if (T == Type.Slip)
            {
                this.Unknown1_ = BR.ReadUInt16();
                for (int counter = 0; counter < 17; counter++)
                {
                    BR.ReadUInt32();
                }
            }
            else if (T == Type.Monipulator)
            {
                this.Unknown1_ = BR.ReadUInt16();
                for (int counter = 0; counter < 24; counter++)
                {
                    BR.ReadInt32();
                }
            }
            // Next Up: Strings (variable size)
            long StringBase = BR.BaseStream.Position;
            uint StringCount = BR.ReadUInt32();
            if (StringCount > 9)
            {
                // Sanity check, for safety - 0 strings is fine for now
                this.Clear();
                return false;
            }
            FFXIEncoding E = new FFXIEncoding();
            string[] Strings = new string[StringCount];
            for (byte i = 0; i < StringCount; ++i)
            {
                long Offset = StringBase + BR.ReadUInt32();
                uint Flag = BR.ReadUInt32();
                if (Offset < 0 || Offset + 0x20 > 0x280 || (Flag != 0 && Flag != 1))
                {
                    this.Clear();
                    return false;
                }
                // Flag seems to be 1 if the offset is not actually an offset. Could just be padding to make StringCount unique per language, or it could be an indication
                // of the pronoun to use (a/an/the/...). The latter makes sense because of the increased number of such flags for french and german.
                if (Flag == 0)
                {
                    BR.BaseStream.Position = Offset;
                    Strings[i] = this.ReadString(BR, E);
                    if (Strings[i] == null)
                    {
                        this.Clear();
                        return false;
                    }
                    BR.BaseStream.Position = StringBase + 4 + 8 * (i + 1);
                }
            }
            // Assign the strings to the proper fields
            switch (StringCount)
            {
                case 1:
                    this.Name_ = Strings[0];
                    break;
                case 2: // Japanese
                    this.Name_ = Strings[0];
                    this.Description_ = Strings[1];
                    break;
                case 5: // English
                    this.Name_ = Strings[0];
                    // unused:              Strings[1]
                    this.LogNameSingular_ = Strings[2];
                    this.LogNamePlural_ = Strings[3];
                    this.Description_ = Strings[4];
                    break;
                case 6: // French
                    this.Name_ = Strings[0];
                    // unused:              Strings[1]
                    // unused:              Strings[2]
                    this.LogNameSingular_ = Strings[3];
                    this.LogNamePlural_ = Strings[4];
                    this.Description_ = Strings[5];
                    break;
                case 9: // German
                    this.Name_ = Strings[0];
                    // unused:              Strings[1]
                    // unused:              Strings[2]
                    // unused:              Strings[3]
                    this.LogNameSingular_ = Strings[4];
                    // unused:              Strings[5]
                    // unused:              Strings[6]
                    this.LogNamePlural_ = Strings[7];
                    this.Description_ = Strings[8];
                    break;
            }
            BR.Close();
            return true;
        }
示例#35
0
文件: Item.cs 项目: Gravenet/POLUtils
 public override void Clear()
 {
     if (this.Icon_ != null)
     {
         this.Icon_.Clear();
     }
     this.ID_ = null;
     this.Flags_ = null;
     this.StackSize_ = null;
     this.Type_ = null;
     this.ResourceID_ = null;
     this.ValidTargets_ = null;
     this.Name_ = null;
     this.Description_ = null;
     this.LogNameSingular_ = null;
     this.LogNamePlural_ = null;
     this.Element_ = null;
     this.StorageSlots_ = null;
     this.ActivationTime_ = null;
     this.Level_ = null;
     this.Slots_ = null;
     this.Races_ = null;
     this.Jobs_ = null;
     this.SuperiorLevel_ = null;
     this.ShieldSize_ = null;
     this.Damage_ = null;
     this.Delay_ = null;
     this.DPS_ = null;
     this.Skill_ = null;
     this.JugSize_ = null;
     this.iLevel_ = null;
     this.MaxCharges_ = null;
     this.CastingTime_ = null;
     this.UseDelay_ = null;
     this.ReuseDelay_ = null;
     this.PuppetSlot_ = null;
     this.ElementCharge_ = null;
     this.InstinctCost_ = null;
     this.Icon_ = null;
     this.Unknown1_ = null;
     this.Unknown2_ = null;
     this.Unknown3_ = null;
     this.Unknown4_ = null;
 }