public string PostPurchaseForFaction(List <string> ids, string Faction)
 {
     try {
         Faction realFaction = (Faction)Enum.Parse(typeof(Faction), Faction);
         if (Holder.factionShops != null)
         {
             FactionShop shop = Holder.factionShops.FirstOrDefault(x => x.shopOwner == realFaction);
             if (shop != null)
             {
                 foreach (string ID in ids)
                 {
                     ShopDefItem item = shop.currentSoldItems.FirstOrDefault(x => x.ID.Equals(ID));
                     if (item != null)
                     {
                         item.Count--;
                     }
                 }
                 shop.currentSoldItems.RemoveAll(x => x.Count <= 0);
             }
         }
         Logger.LogLine(ids.Count + " items removed from shop for " + Faction);
         return(ids.Count + " items removed from shop for " + Faction);
     }
     catch (Exception e) {
         Logger.LogError(e);
         return("Error");
     }
 }
Example #2
0
 public override string PostPurchaseForFaction(List <string> ids, string Faction)
 {
     lock (_purchaseLock) {
         try {
             Faction realFaction = (Faction)Enum.Parse(typeof(Faction), Faction);
             if (Holder.factionShops != null)
             {
                 FactionShop shop = Holder.factionShops.FirstOrDefault(x => x.shopOwner == realFaction);
                 if (shop != null)
                 {
                     foreach (string ID in ids)
                     {
                         ShopDefItem item = shop.currentSoldItems.FirstOrDefault(x => x.ID.Equals(ID));
                         if (item != null)
                         {
                             item.Count--;
                         }
                     }
                     shop.currentSoldItems.RemoveAll(x => x.Count <= 0);
                 }
             }
             logger.Info($"INV: {ids.Count} items were removed from the shop for faction ({Faction})");
             return(ids.Count + " items removed from shop for " + Faction);
         }
         catch (Exception e) {
             logger.Warn(e, "Failed to process purchase!");
             return("Error");
         }
     }
 }
        public string PostPurchaseForFactionDepricated(string Faction, string ID)
        {
            Faction realFaction = (Faction)Enum.Parse(typeof(Faction), Faction);

            if (Holder.factionShops != null)
            {
                FactionShop shop = Holder.factionShops.FirstOrDefault(x => x.shopOwner == realFaction);
                if (shop != null)
                {
                    ShopDefItem item = shop.currentSoldItems.FirstOrDefault(x => x.ID.Equals(ID));
                    if (item != null)
                    {
                        item.Count--;
                    }
                    shop.currentSoldItems.RemoveAll(x => x.Count <= 0);
                }
            }
            Logger.LogLine(ID + " 1 removed from shop for " + Faction);
            return(ID + " 1 removed from shop for " + Faction);
        }