0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/Utils/DifficultyManager.cs
Merijn Hendriks accb0ab9f6 Reduce bot difficulty requests (!111)
Requires server-side changes (will need your help @TheSparta for this!).

This combined all the single bot difficulty requests into a single GET request (`/singleplayer/bot/difficulties`) with the following data structure:
```json
[
    {
        "role": "assault",
        "difficulty": "easy",
        "data": "assets/database/bots/types/assault.json difficulty easy contents"
    },
    {
        "role": "pmcbot",
        "difficulty": "normal",
        "data": "assets/database/bots/types/pmcbot.json difficulty normal contents"
    }
]
```
The request expects all roles and all their respective difficulties to be in the response.

Co-authored-by: Merijn Hendriks <merijnhendriks@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#111
Reviewed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-authored-by: Merijn Hendriks <senko-san@noreply.dev.sp-tarkov.com>
Co-committed-by: Merijn Hendriks <senko-san@noreply.dev.sp-tarkov.com>
2024-04-20 22:32:28 +00:00

43 lines
1.1 KiB
C#

using System.Collections.Generic;
using EFT;
using Aki.Common.Http;
using Aki.Common.Utils;
using Aki.Custom.Models;
namespace Aki.Custom.Utils
{
public static class DifficultyManager
{
public static List<DifficultyInfo> Difficulties { get; private set; }
static DifficultyManager()
{
Difficulties = new List<DifficultyInfo>();
}
public static void Update()
{
// remove existing list
Difficulties.Clear();
// get new difficulties
var json = RequestHandler.GetJson("/singleplayer/settings/bot/difficulties");
Difficulties = Json.Deserialize<List<DifficultyInfo>>(json);
}
public static string Get(BotDifficulty botDifficulty, WildSpawnType role)
{
foreach (var entry in Difficulties)
{
if (botDifficulty.ToString().ToLower() == entry.Difficulty
&& role.ToString().ToLower() == entry.Role)
{
return entry.Data;
}
}
return string.Empty;
}
}
}