Skip to content

Commit

Permalink
修复紫卡查询
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealKamisama committed Dec 20, 2023
1 parent 1ac00a6 commit 9863bbd
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 24 deletions.
3 changes: 2 additions & 1 deletion WFBot.Tests/FunctionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void Init()
{
core = new WFBotCore(true);
core.Init().Wait();
Config.Instance.EnableImageRendering = false;
}
WFBotCore core;
[TestMethod]
Expand Down Expand Up @@ -76,7 +77,7 @@ private void InputCommand(string msg)
public void TestWildcards()
{
var test = new List<Sale>();
Assert.IsTrue(WMSearcher.Search("凯旋将军破坏者", ref test)); // 破坏者不加p
Assert.IsTrue(WMSearcher.Search("凯旋将军破坏者", ref test)); // 破坏者不加p // 这玩意出错了
test.Clear();
Assert.IsTrue(WMSearcher.Search("valkyrp", ref test)); // p自动补全为prime
test.Clear();
Expand Down
2 changes: 1 addition & 1 deletion WFBot/Features/Commands/KookSpecificCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ string Redeem(string code)
[Matchers("有效期")]
string ExpireTime()
{
return $"本服务器的机器人有效期为: {MiguelNetwork.KookVerifyServer.GetGuildValidationTime(O).Result.ToString(CultureInfo.CurrentCulture)}\n状态: {(MiguelNetwork.KookVerifyServer.VerifyGuild(O).Result ? "未过期": "已过期")}";
return $"本服务器的机器人有效期为: {MiguelNetwork.KookVerifyServer.GetGuildValidationTime(O).Result.Humanize()}\n状态: {(MiguelNetwork.KookVerifyServer.VerifyGuild(O).Result ? "未过期": "已过期")}";
}

[SkipBotChannelCheck]
Expand Down
68 changes: 48 additions & 20 deletions WFBot/Features/Utils/WFFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using WFBot.Features.Resource;
using WFBot.Features.Telemetry;
using WFBot.Utils;
using WarframeAlertingPrime.SDK.Models.Meta;

namespace WFBot.Features.Utils
{
Expand Down Expand Up @@ -473,29 +474,46 @@ public static async Task<List<RivenData>> GetRivenData()
public static string GetRivenInfoString(Riven riven)
{
var sb = new StringBuilder();
var datas = GetRivenData().Result.Where(d => d.compatibility == riven.name).ToList();

var weaponinfo = WFResources.WFTranslateData.Riven.First(d => d.name == riven.name);

sb.AppendLine($"下面是 {riven.zhname} 紫卡的基本信息(来自DE)");
sb.AppendLine($"类型: {WFResources.WFTranslator.TranslateWeaponType(weaponinfo.type)} 倾向: {weaponinfo.rank}星 倍率: {Math.Round(weaponinfo.modulus, 2)}");
var rerolled = datas.Where(d => !d.rerolled).ToImmutableArray();
if (rerolled.Any())

var datas = new List<RivenData>();
try
{
sb.AppendLine($"0洗均价: {rerolled.First().avg}白金");
datas = GetRivenData().Result?.Where(d => d.compatibility == riven.name).ToList();
}
catch (Exception )
{
return sb.ToString().Trim();
// DE数据目前不可用
}

rerolled = datas.Where(d => d.rerolled).ToImmutableArray();
if (rerolled.Any())

if (datas != null)
{
sb.AppendLine($"全部均价: {rerolled.First().avg}白金");
var rerolled = datas.Where(d => !d.rerolled).ToImmutableArray();
if (rerolled.Any())
{
sb.AppendLine($"0洗均价: {rerolled.First().avg}白金");
}

rerolled = datas.Where(d => d.rerolled).ToImmutableArray();
if (rerolled.Any())
{
sb.AppendLine($"全部均价: {rerolled.First().avg}白金");
}
}


return sb.ToString().Trim();
}
public static string GetRivenInfoString(WeaponInfo weapon)
{
var sb = new StringBuilder();
var datas = GetRivenData().Result?.Where(d => d.compatibility.Format() == weapon.enname.Format()).ToList();

var rivens = WFResources.WFTranslateData.Riven.Where(d => d.name == weapon.enname).ToList();

if (rivens.Any())
Expand All @@ -504,21 +522,31 @@ public static string GetRivenInfoString(WeaponInfo weapon)
sb.AppendLine($"{weapon.zhname} 紫卡的基本信息");
sb.AppendLine($"类型: {WFResources.WFTranslator.TranslateWeaponType(riven.type)} 倾向: {riven.rank}星 倍率: {Math.Round(riven.modulus, 2)}");
}
var datas = new List<RivenData>();
try
{
datas = GetRivenData().Result?.Where(d => d.compatibility.Format() == weapon.enname.Format()).ToList();
}
catch (Exception)
{
return sb.ToString().Trim();
// DE数据目前不可用
}

if (datas != null)
if (datas == null) return sb.ToString().Trim();

var rerolled = datas.Where(d => !d.rerolled).ToImmutableArray();
if (rerolled.Any())
{
var rerolled = datas.Where(d => !d.rerolled).ToImmutableArray();
if (rerolled.Any())
{
sb.AppendLine($"0洗均价: {rerolled.First().avg}白金(每周交易数据)");
}
sb.AppendLine($"0洗均价: {rerolled.First().avg}白金(每周交易数据)");
}

rerolled = datas.Where(d => d.rerolled).ToImmutableArray();
if (rerolled.Any())
{
sb.AppendLine($"全部均价: {rerolled.First().avg}白金(每周交易数据)");
}
rerolled = datas.Where(d => d.rerolled).ToImmutableArray();
if (rerolled.Any())
{
sb.AppendLine($"全部均价: {rerolled.First().avg}白金(每周交易数据)");
}


return sb.ToString().Trim();
}
Expand Down
3 changes: 2 additions & 1 deletion WFBot/Features/Utils/WFObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ public class WFCD_All
{
public string name { get; set; }
public List<Component> components { get; set; } = new List<Component>();
#if DEBUG // 很鸡巴弱智, 这下面一堆东西的都会null/混用类型, 如果遇到问题就关掉DEBUG模式
#if DEBUG
// 很鸡巴弱智, 这下面一堆东西的都会null/混用类型, 如果遇到问题就关掉DEBUG模式
// 这个注释是我写的吗? 我又再次遇到这个问题了, 可是我得用DEBUG模式的功能 ah, 在未来换个数据源吧
// TODO 换数据源
// 笑死 CY还因为这个问题专门写了个Commit, 以为机器人开不起是这玩意造成的
Expand Down
2 changes: 1 addition & 1 deletion WFBot/Orichalt/MiguelNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public static void Reply(OrichaltContext o, RichMessages msg)
{
File.Delete(resultPath);
}
File.AppendAllText(resultPath, msg + Environment.NewLine);
File.AppendAllText(resultPath, msg.OfType<TextMessage>().Select(x => x.Content).Connect() + Environment.NewLine);
break;
}
}
Expand Down

0 comments on commit 9863bbd

Please sign in to comment.