Add code to create dynamic price for ammo inside ammo packs + add edge case system for hand-defined item prices
This commit is contained in:
parent
e850da0dcc
commit
1ffa4f1e0c
@ -28,6 +28,7 @@ namespace MarketPriceLookup.Common.Models
|
||||
public int LootExperience { get; set; }
|
||||
public int ExamineExperience { get; set; }
|
||||
public bool CanSellOnRagfair { get;set;}
|
||||
public List<StackSlot> StackSlots { get ; set; }
|
||||
}
|
||||
|
||||
public class Chamber
|
||||
@ -56,4 +57,24 @@ namespace MarketPriceLookup.Common.Models
|
||||
{
|
||||
public List<string> filter { get; set; }
|
||||
}
|
||||
|
||||
public class StackSlot
|
||||
{
|
||||
public string _name { get; set; }
|
||||
public string _id { get; set; }
|
||||
public string _parent { get; set; }
|
||||
public int _max_count { get; set; }
|
||||
public StackSlotProps _props { get; set; }
|
||||
public string _proto { get; set; }
|
||||
}
|
||||
|
||||
public class StackSlotProps
|
||||
{
|
||||
public List<StackSlotFilter> filters { get; set; }
|
||||
}
|
||||
|
||||
public class StackSlotFilter
|
||||
{
|
||||
public List<string> Filter { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,24 @@
|
||||
using MarketPriceLookup.Common;
|
||||
using MarketPriceLookup.Common.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MarketPriceLookup
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private static readonly Dictionary<string, (int, string, int)> _specialCases = new Dictionary<string, (int, string, int)>
|
||||
{
|
||||
{ "627e14b21713922ded6f2c15", (250000, null, -1)}, // Accuracy International AXMC .338 LM bolt-action sniper rifle
|
||||
};
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// loop over all items and get a price for each
|
||||
var priceList = new Dictionary<string, int>();
|
||||
var handbookPrices = HandbookHelper.Items;
|
||||
foreach (var item in ItemTemplateHelper.Items)
|
||||
{
|
||||
var priceData = MarketPricesHelper.GetItemPrice(item.Key);
|
||||
@ -20,11 +28,65 @@ namespace MarketPriceLookup
|
||||
}
|
||||
}
|
||||
|
||||
// Ammo packs are easy to exploit, they're never listed on flea which casues server to use handbook price, often contain ammo worth x100 the cost of handbook price
|
||||
var ammoPacks = ItemTemplateHelper.Items.Values
|
||||
.Where(x => (x._parent == "5661632d4bdc2d903d8b456b" || x._parent == "543be5cb4bdc2deb348b4568")
|
||||
&& x._name.Contains("item_ammo_box_")
|
||||
&& !x._name.Contains("_damaged"));
|
||||
|
||||
foreach (var ammoPack in ammoPacks)
|
||||
{
|
||||
if (!priceList.ContainsKey(ammoPack._id))
|
||||
{
|
||||
LoggingHelpers.LogWarning($"edge case ammo pack {ammoPack._name} not found in prices, adding manually");
|
||||
// get price of item to multiply price of
|
||||
var itemMultipler = ammoPack._props.StackSlots[0]._max_count;
|
||||
var singleItemPrice = GetItemPrice(priceList, handbookPrices.Items, ammoPack._props.StackSlots[0]._props.filters[0].Filter[0]);
|
||||
var price = singleItemPrice * itemMultipler;
|
||||
|
||||
priceList.Add(ammoPack._id, price);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Some items dont get listed on flea often, manually add prices for these
|
||||
foreach (var specialCase in _specialCases)
|
||||
{
|
||||
if (!priceList.ContainsKey(specialCase.Key))
|
||||
{
|
||||
LoggingHelpers.LogWarning($"edge case item {specialCase.Key} not found in prices, adding manually");
|
||||
if (specialCase.Value.Item1 == -1)
|
||||
{
|
||||
// get price of item to multiply price of
|
||||
var itemTpl = specialCase.Value.Item2;
|
||||
var itemMultipler = specialCase.Value.Item3;
|
||||
var singleItemPrice = GetItemPrice(priceList, handbookPrices.Items, itemTpl);
|
||||
var price = singleItemPrice * itemMultipler;
|
||||
|
||||
priceList.Add(specialCase.Key, price);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
priceList.Add(specialCase.Key, specialCase.Value.Item1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// save found prices to json
|
||||
JsonWriter.WriteJson(priceList, "output", Directory.GetCurrentDirectory(), "prices");
|
||||
}
|
||||
|
||||
private static int GetItemPrice(Dictionary<string, int> priceList, HandbookItem[] handbookItems, string itemTpl)
|
||||
{
|
||||
var fleaPrice = priceList.FirstOrDefault(x => x.Key == itemTpl);
|
||||
if (fleaPrice.Key == null)
|
||||
{
|
||||
return handbookItems.FirstOrDefault(x => x.Id == itemTpl).Price;
|
||||
}
|
||||
return fleaPrice.Value;
|
||||
}
|
||||
|
||||
public class OutputPrices
|
||||
{
|
||||
public int LivePrice { get; set; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user