DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
This commit is contained in:
commit
645b64fe21
4388 files changed
+1405457
No files matched your search
@@ -0,0 +1,109 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DNFLoadout;
|
||||
|
||||
internal sealed class ServerClient
|
||||
{
|
||||
private readonly HttpClient _http = new() { Timeout = TimeSpan.FromSeconds(10) };
|
||||
private readonly Config _config;
|
||||
|
||||
public ServerClient(Config config) => _config = config;
|
||||
|
||||
private HttpRequestMessage Request(HttpMethod method, string path)
|
||||
{
|
||||
var req = new HttpRequestMessage(method, _config.ServerUrl.TrimEnd('/') + path);
|
||||
if (!string.IsNullOrWhiteSpace(_config.AdminToken))
|
||||
req.Headers.TryAddWithoutValidation("X-Admin-Token", _config.AdminToken.Trim());
|
||||
return req;
|
||||
}
|
||||
|
||||
public async Task<List<SlotItem>> GetEquipmentAsync(string characterName)
|
||||
{
|
||||
using var req = Request(HttpMethod.Get,
|
||||
"/local/dnf-gm/loadout/equipment?character_id=" + Uri.EscapeDataString(characterName.Trim()));
|
||||
using var resp = await _http.SendAsync(req);
|
||||
var text = await resp.Content.ReadAsStringAsync();
|
||||
if (!resp.IsSuccessStatusCode) throw new Exception(text);
|
||||
var envelope = JsonSerializer.Deserialize<Envelope<SnapshotData>>(text)
|
||||
?? throw new Exception("empty response");
|
||||
if (!envelope.Ok) throw new Exception(envelope.Error ?? "server returned failure");
|
||||
return envelope.Data?.Slots ?? new List<SlotItem>();
|
||||
}
|
||||
|
||||
public async Task<List<CharacterInfo>> GetCharactersAsync()
|
||||
{
|
||||
using var req = Request(HttpMethod.Get, "/local/dnf-gm/characters");
|
||||
using var resp = await _http.SendAsync(req);
|
||||
var text = await resp.Content.ReadAsStringAsync();
|
||||
if (!resp.IsSuccessStatusCode) throw new Exception(text);
|
||||
var envelope = JsonSerializer.Deserialize<Envelope<List<CharacterInfo>>>(text)
|
||||
?? throw new Exception("empty response");
|
||||
if (!envelope.Ok) throw new Exception(envelope.Error ?? "server returned failure");
|
||||
return envelope.Data ?? new List<CharacterInfo>();
|
||||
}
|
||||
|
||||
internal sealed class CharacterInfo
|
||||
{
|
||||
[JsonPropertyName("character_id")] public string CharacterId { get; set; } = "";
|
||||
[JsonPropertyName("name")] public string Name { get; set; } = "";
|
||||
[JsonPropertyName("online")] public bool Online { get; set; }
|
||||
}
|
||||
|
||||
public async Task<ApplyData> ApplyAsync(string characterName, IEnumerable<SlotItem> slots)
|
||||
{
|
||||
var body = new ApplyRequest
|
||||
{
|
||||
CharacterId = characterName.Trim(),
|
||||
Slots = slots.ToList(),
|
||||
};
|
||||
using var req = Request(HttpMethod.Post, "/local/dnf-gm/loadout/apply");
|
||||
req.Content = JsonContent.Create(body);
|
||||
using var resp = await _http.SendAsync(req);
|
||||
var text = await resp.Content.ReadAsStringAsync();
|
||||
if (!resp.IsSuccessStatusCode) throw new Exception(text);
|
||||
var envelope = JsonSerializer.Deserialize<Envelope<ApplyData>>(text)
|
||||
?? throw new Exception("empty response");
|
||||
if (!envelope.Ok) throw new Exception(envelope.Error ?? "server returned failure");
|
||||
return envelope.Data ?? new ApplyData();
|
||||
}
|
||||
|
||||
private sealed class Envelope<T>
|
||||
{
|
||||
[JsonPropertyName("ok")] public bool Ok { get; set; }
|
||||
[JsonPropertyName("error")] public string? Error { get; set; }
|
||||
[JsonPropertyName("data")] public T? Data { get; set; }
|
||||
}
|
||||
|
||||
private sealed class SnapshotData
|
||||
{
|
||||
[JsonPropertyName("character_id")] public string CharacterId { get; set; } = "";
|
||||
[JsonPropertyName("online")] public bool Online { get; set; }
|
||||
[JsonPropertyName("slots")] public List<SlotItem> Slots { get; set; } = new();
|
||||
}
|
||||
|
||||
private sealed class ApplyRequest
|
||||
{
|
||||
[JsonPropertyName("character_id")] public string CharacterId { get; set; } = "";
|
||||
[JsonPropertyName("slots")] public List<SlotItem> Slots { get; set; } = new();
|
||||
}
|
||||
|
||||
internal sealed class ApplyData
|
||||
{
|
||||
[JsonPropertyName("applied")] public List<SlotItem>? Applied { get; set; } = new();
|
||||
[JsonPropertyName("skipped")] public List<SkipData>? Skipped { get; set; } = new();
|
||||
[JsonPropertyName("refresh_sent")] public bool RefreshSent { get; set; }
|
||||
[JsonPropertyName("refresh_error")] public string? RefreshError { get; set; }
|
||||
[JsonPropertyName("cooldown_seconds")] public int CooldownSeconds { get; set; }
|
||||
[JsonPropertyName("cooldown_remaining")] public int CooldownRemaining { get; set; }
|
||||
}
|
||||
|
||||
internal sealed class SkipData
|
||||
{
|
||||
[JsonPropertyName("slot")] public int Slot { get; set; }
|
||||
[JsonPropertyName("item_id")] public long ItemId { get; set; }
|
||||
[JsonPropertyName("reason")] public string Reason { get; set; } = "";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user