2024-12-18 09:33:25 +00:00
|
|
|
|
using LootBoxSimulator.Models.DAO;
|
|
|
|
|
|
|
|
|
|
RemoteDatabaseContext db = new RemoteDatabaseContext();
|
2024-12-17 15:06:26 +00:00
|
|
|
|
decimal [] test = [0.25M, 0.5M, 0.125M , 0.125M];
|
2024-12-18 09:33:25 +00:00
|
|
|
|
Dictionary<int, (decimal, decimal)> rareDictionary = new Dictionary<int, (decimal, decimal)>();
|
|
|
|
|
var rates = db.Rates.OrderByDescending(it => it.Rate).ToList();
|
2024-12-05 11:29:52 +00:00
|
|
|
|
|
2024-12-16 13:07:23 +00:00
|
|
|
|
|
2024-12-17 15:06:26 +00:00
|
|
|
|
Random random = new Random();
|
|
|
|
|
decimal number = Convert.ToDecimal(Math.Round(random.NextDouble(),2));
|
|
|
|
|
Console.WriteLine($"Random number: {number}");
|
|
|
|
|
decimal startRange = 0;
|
2024-12-18 09:33:25 +00:00
|
|
|
|
decimal endRange = rates[0].Rate;
|
|
|
|
|
rareDictionary.Add(rates[0].Id, (startRange, endRange));
|
|
|
|
|
for (int i = 1; i < rates.Count; i++)
|
2024-12-16 13:07:23 +00:00
|
|
|
|
{
|
2024-12-17 15:06:26 +00:00
|
|
|
|
startRange = endRange;
|
2024-12-18 09:33:25 +00:00
|
|
|
|
endRange = startRange + rates[i].Rate;
|
|
|
|
|
rareDictionary.Add(rates[i].Id, (startRange, endRange));
|
2024-12-17 15:06:26 +00:00
|
|
|
|
if (number >= startRange && number <= endRange)
|
|
|
|
|
{
|
2024-12-18 09:33:25 +00:00
|
|
|
|
Console.WriteLine(rates[i].Id);
|
|
|
|
|
};
|
2024-12-17 06:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 09:33:25 +00:00
|
|
|
|
foreach (var keyValuePair in rareDictionary)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"{keyValuePair.Key}: {keyValuePair.Value}");
|
|
|
|
|
}
|
2024-12-17 12:43:34 +00:00
|
|
|
|
|
2024-12-18 09:33:25 +00:00
|
|
|
|
var items = db.Items.Where(it => it.Rate.Rate == 3).ToList();
|
|
|
|
|
Random randomInt = new Random();
|
|
|
|
|
int randomIndex = randomInt.Next(0,items.Count);
|
|
|
|
|
Console.WriteLine(items[randomIndex].Name);
|
|
|
|
|
//вынести попадание в диапазон в отдельную функцию, которая возвращает айди редкость
|
|
|
|
|
//сделать ролл по предметам с условием выпавшей редкости и вернуть случайную вещь
|
|
|
|
|
//сгенерировать случайное число от 0 до кол-во вещей после фильтра и выдать случайный
|
|
|
|
|
//предмет по выпавшему индексу
|