Exemplo n.º 1
0
 public void LoadAvailablePrerequisiteItemCost(string token, Character character)
 {
     foreach (Item item in AllItems)
     {
         item.Cost = 0.0f;
         foreach (var li in item.LocationInfo)
         {
             if (li.Source == ItemSource.Vendor)
             {
                 VendorItem vendor = li as VendorItem;
                 int count;
                 if (vendor.TokenMap.TryGetValue(token, out count))
                 {
                     // determine if the other prerequisites are available
                     bool valid = true;
                     foreach (var t in vendor.TokenMap)
                     {
                         if (t.Key != token)
                         {
                             // we have the name of the lower level item
                             // find this item
                             var pitem = AllItems.Find(i => i.Name == t.Key && i.ItemLevel < item.ItemLevel);
                             if (pitem != null)
                             {
                                 // is it available
                                 if (character.GetItemAvailability(new ItemInstance(pitem, 0, null, null, null, null, null, null)) == ItemAvailability.NotAvailable)
                                 {
                                     valid = false;
                                     break;
                                 }
                             }
                         }
                     }
                     if (valid)
                     {
                         item.Cost = count;
                     }
                 }
             }
         }
     }
     // don't need to invalidate relevant caches, but still trigger event to refresh graphs etc.
     if (ItemsChanged != null) ItemsChanged(null, null);
 }