Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CaiBotPlugin): 添加更多进度查询信息 #765

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/CaiBot/CaiBotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,18 @@ internal static async Task HandleMessageAsync(string receivedData)
await SendDateAsync(JsonConvert.SerializeObject(result));
break;
case "process":
List<Dictionary<string, bool>> processList = new (
new Dictionary<string, bool>[] { new () { { "King Slime", NPC.downedSlimeKing } }, new () { { "Eye of Cthulhu", NPC.downedBoss1 } }, new () { { "Eater of Worlds / Brain of Cthulhu", NPC.downedBoss2 } }, new () { { "Queen Bee", NPC.downedQueenBee } }, new () { { "Skeletron", NPC.downedBoss3 } }, new () { { "Deerclops", NPC.downedDeerclops } }, new () { { "Wall of Flesh", Main.hardMode } }, new () { { "Queen Slime", NPC.downedQueenSlime } }, new () { { "The Twins", NPC.downedMechBoss2 } }, new () { { "The Destroyer", NPC.downedMechBoss1 } }, new () { { "Skeletron Prime", NPC.downedMechBoss3 } }, new () { { "Plantera", NPC.downedPlantBoss } }, new () { { "Golem", NPC.downedGolemBoss } }, new () { { "Duke Fishron", NPC.downedFishron } }, new () { { "Empress of Light", NPC.downedEmpressOfLight } }, new () { { "Lunatic Cultist", NPC.downedAncientCultist } }, new () { { "Moon Lord", NPC.downedMoonlord } }, new () { { "Solar Pillar", NPC.downedTowerSolar } }, new () { { "Nebula Pillar", NPC.downedTowerNebula } }, new () { { "Vortex Pillar", NPC.downedTowerVortex } }, new () { { "Stardust Pillar", NPC.downedTowerStardust } } });
result = new RestObject { { "type", "process" }, { "result", processList }, { "worldname", Main.worldName }, { "group", (long) jsonObject["group"]! } };
result = new RestObject
{
{ "type", "process" },
{ "process", Utils.GetProcessList() },
{ "kill_counts", Utils.GetKillCountList()},
{ "worldname", Main.worldName },
{ "drunk_world", Main.drunkWorld },
{ "zenith_world" , Main.zenithWorld },
{ "world_icon", Utils.GetWorldIconName()},
{ "group", (long) jsonObject["group"]! }

};
await SendDateAsync(JsonConvert.SerializeObject(result));
break;
case "whitelist":
Expand All @@ -128,7 +137,6 @@ internal static async Task HandleMessageAsync(string receivedData)
Login.HandleLogin(plr);
}
}

break;
case "selfkick":
name = (string) jsonObject["name"]!;
Expand All @@ -140,7 +148,6 @@ internal static async Task HandleMessageAsync(string receivedData)

playerList2[0].Kick("在群中使用自踢命令.", true, saveSSI: true);
break;

case "lookbag":
name = (string) jsonObject["name"]!;
var playerList3 = TSPlayer.FindByNameOrID("tsn:" + name);
Expand Down
2 changes: 1 addition & 1 deletion src/CaiBot/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace CaiBot;
[ApiVersion(2, 1)]
public class Plugin : TerrariaPlugin
{
public static readonly Version VersionNum = new (2025, 1, 25, 1); //日期+版本号(0,1,2...)
public static readonly Version VersionNum = new (2025, 1, 27, 1); //日期+版本号(0,1,2...)
internal static int InitCode = -1;
public static bool LocalMode => Config.Settings.BotApi != "api.terraria.ink:22334";
public static bool DebugMode;
Expand Down
4 changes: 3 additions & 1 deletion src/CaiBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
## 更新日志

```
v2025.01.27.1 添加更多进度查询信息
v2025.01.24.1 升级绘图库,修复`上传小地图`,允许用户自定义Api地址,
服务器加入退出消息可以留空关闭,添加群聊天忽略用户列表,添加Ban封禁通知开关,
允许使用/reload重载,添加主动解绑命令,添加白名单缓存机制
Expand Down Expand Up @@ -83,7 +84,8 @@ v2024.07.24.2 修复心跳包错误
v2024.07.24.1 优化代码、发送心跳包、修复进度显示错误
v2024.07.11.1 支持下载地图和下载小地图
v2024.06.19.1 支持共享服务器(Beta测试)
v2024.06.07.0 添加自动获取群号,向BOT发送服务器的一些信息(平台、白名单状态、服务器进服密码、插件版本、TShock版本、Terraria版本),将调试模式(-caidebug)和本地BOT模式(-cailocalbot)分离
v2024.06.07.0 添加自动获取群号,向BOT发送服务器的一些信息(平台、白名单状态、服务器进服密码、插件版本、TShock版本、Terraria版本),
将调试模式(-caidebug)和本地BOT模式(-cailocalbot)分离
v1.1 修复前置加载失败的问题
```

Expand Down
122 changes: 122 additions & 0 deletions src/CaiBot/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,133 @@
using System.IO.Compression;
using System.Text;
using Terraria;
using Terraria.GameContent.Events;
using Terraria.ID;
using Terraria.IO;

namespace CaiBot;

internal static class Utils
{


internal static string GetWorldIconName()
{
var data = Main.ActiveWorldFileData;

static string GetSeedIcon(string seed)
{
return "Icon" + (Main.ActiveWorldFileData.IsHardMode ? "Hallow" : "") + (Main.ActiveWorldFileData.HasCorruption ? "Corruption" : "Crimson") + seed;
}

if (data.ZenithWorld)
{
return "Icon" + (data.IsHardMode ? "Hallow" : "") + "Everything";
}
if (data.DrunkWorld)
{
return "Icon" + (data.IsHardMode ? "Hallow" : "") + "CorruptionCrimson";
}
if (data.ForTheWorthy)
{
return GetSeedIcon("FTW");
}
if (data.NotTheBees)
{
return GetSeedIcon("NotTheBees");
}
if (data.Anniversary)
{
return GetSeedIcon("Anniversary");
}
if (data.DontStarve)
{
return GetSeedIcon("DontStarve");
}
if (data.RemixWorld)
{
return GetSeedIcon("Remix");
}
if (data.NoTrapsWorld)
{
return GetSeedIcon("Traps");
}
return "Icon" + (data.IsHardMode ? "Hallow" : "") + (data.HasCorruption ? "Corruption" : "Crimson");
}

internal static Dictionary<string,bool> GetProcessList()
{

// ReSharper disable once UseObjectOrCollectionInitializer
Dictionary<string, bool> processList = new();
processList.Add("King Slime", NPC.downedSlimeKing);
processList.Add("Eye of Cthulhu", NPC.downedBoss1);
processList.Add("Eater of Worlds or Brain of Cthulhu", NPC.downedBoss2);
processList.Add("Eater of Worlds", Main.BestiaryTracker.Kills.GetKillCount(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCID.EaterofWorldsHead])>0);
processList.Add("Brain of Cthulhu", Main.BestiaryTracker.Kills.GetKillCount(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCID.BrainofCthulhu])>0);
processList.Add("Queen Bee", NPC.downedQueenBee);
processList.Add("Deerclops", NPC.downedDeerclops);
processList.Add("Skeletron", NPC.downedBoss3);
processList.Add("Wall of Flesh", Main.hardMode);
processList.Add("Queen Slime", NPC.downedQueenSlime);
processList.Add("The Destroyer", NPC.downedMechBoss1);
processList.Add("The Twins", NPC.downedMechBoss2);
processList.Add("Skeletron Prime", NPC.downedMechBoss3);
processList.Add("Plantera", NPC.downedPlantBoss);
processList.Add("Golem", NPC.downedGolemBoss);
processList.Add("Duke Fishron", NPC.downedFishron);
processList.Add("Empress of Light", NPC.downedEmpressOfLight);
processList.Add("Lunatic Cultist", NPC.downedAncientCultist);

processList.Add("Tower Solar", NPC.downedTowerSolar);
processList.Add("Tower Nebula", NPC.downedTowerNebula);
processList.Add("Tower Vortex", NPC.downedTowerVortex);
processList.Add("Tower Stardust", NPC.downedTowerStardust);

processList.Add("Moon Lord", NPC.downedMoonlord);
processList.Add("Pillars", NPC.downedTowerSolar && NPC.downedTowerNebula && NPC.downedTowerVortex && NPC.downedTowerStardust);
processList.Add("Goblins", NPC.downedGoblins);
processList.Add("Pirates", NPC.downedPirates);
processList.Add("Frost", NPC.downedFrost);
processList.Add("Frost Moon", NPC.downedChristmasTree && NPC.downedChristmasSantank && NPC.downedChristmasIceQueen);
processList.Add("Pumpkin Moon", NPC.downedHalloweenTree && NPC.downedHalloweenKing);
processList.Add("Martians", NPC.downedMartians);
processList.Add("DD2InvasionT1", DD2Event.DownedInvasionT1);
processList.Add("DD2InvasionT2", DD2Event.DownedInvasionT2);
processList.Add("DD2InvasionT3", DD2Event.DownedInvasionT3);
return processList;
}

internal static Dictionary<string,int> GetKillCountList()
{
int GetKillCount(int id)
{
return Main.BestiaryTracker.Kills.GetKillCount(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[id]);
}
// ReSharper disable once UseObjectOrCollectionInitializer
Dictionary<string, int> killCountList = new();
killCountList.Add("King Slime", GetKillCount(NPCID.KingSlime));
killCountList.Add("Eye of Cthulhu", GetKillCount(NPCID.EyeofCthulhu));
killCountList.Add("Eater of Worlds", GetKillCount(NPCID.EaterofWorldsHead));
killCountList.Add("Brain of Cthulhu", GetKillCount(NPCID.BrainofCthulhu));
killCountList.Add("Queen Bee", GetKillCount(NPCID.QueenBee));
killCountList.Add("Deerclops", GetKillCount(NPCID.Deerclops));
killCountList.Add("Skeletron", GetKillCount(NPCID.SkeletronHead));
killCountList.Add("Wall of Flesh", GetKillCount(NPCID.WallofFlesh));
killCountList.Add("Queen Slime", GetKillCount(NPCID.QueenSlimeBoss));
killCountList.Add("The Twins", Math.Min(GetKillCount(NPCID.Retinazer),GetKillCount(NPCID.Spazmatism)));
killCountList.Add("The Destroyer", GetKillCount(NPCID.TheDestroyer));
killCountList.Add("Skeletron Prime", GetKillCount(NPCID.SkeletronPrime));
killCountList.Add("Plantera", GetKillCount(NPCID.Plantera));
killCountList.Add("Golem", GetKillCount(NPCID.Golem));
killCountList.Add("Duke Fishron", GetKillCount(NPCID.DukeFishron));
killCountList.Add("Empress of Light", GetKillCount(NPCID.HallowBoss));
killCountList.Add("Lunatic Cultist", GetKillCount(NPCID.CultistBoss));
killCountList.Add("Moon Lord", GetKillCount(NPCID.MoonLordCore));
return killCountList;
}


internal static List<string> GetOnlineProcessList()
{
List<string> onlineProcessList = new ();
Expand Down
Loading