-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
namespace PrismBot.SDK.Models; | ||
using System.Text.Json.Serialization; | ||
|
||
public class BossProgress | ||
{ | ||
[JsonPropertyName("status")] | ||
public string Status { get; set; } | ||
|
||
[JsonPropertyName("response")] | ||
public BossStatus Response { get; set; } | ||
} | ||
|
||
public class BossStatus | ||
{ | ||
[JsonPropertyName("King Slime")] | ||
public bool KingSlime { get; set; } | ||
|
||
[JsonPropertyName("Eye of Cthulhu")] | ||
public bool EyeOfCthulhu { get; set; } | ||
|
||
[JsonPropertyName("Eater of Worlds / Brain of Cthulhu")] | ||
public bool EaterOfWorldsOrBrainOfCthulhu { get; set; } | ||
|
||
[JsonPropertyName("Queen Bee")] | ||
public bool QueenBee { get; set; } | ||
|
||
[JsonPropertyName("Skeletron")] | ||
public bool Skeletron { get; set; } | ||
|
||
[JsonPropertyName("Deerclops")] | ||
public bool Deerclops { get; set; } | ||
|
||
[JsonPropertyName("Wall of Flesh")] | ||
public bool WallOfFlesh { get; set; } | ||
|
||
[JsonPropertyName("Queen Slime")] | ||
public bool QueenSlime { get; set; } | ||
|
||
[JsonPropertyName("The Twins")] | ||
public bool TheTwins { get; set; } | ||
|
||
[JsonPropertyName("The Destroyer")] | ||
public bool TheDestroyer { get; set; } | ||
|
||
[JsonPropertyName("Skeletron Prime")] | ||
public bool SkeletronPrime { get; set; } | ||
|
||
[JsonPropertyName("Plantera")] | ||
public bool Plantera { get; set; } | ||
|
||
[JsonPropertyName("Golem")] | ||
public bool Golem { get; set; } | ||
|
||
[JsonPropertyName("Duke Fishron")] | ||
public bool DukeFishron { get; set; } | ||
|
||
[JsonPropertyName("Empress of Light")] | ||
public bool EmpressOfLight { get; set; } | ||
|
||
[JsonPropertyName("Lunatic Cultist")] | ||
public bool LunaticCultist { get; set; } | ||
|
||
[JsonPropertyName("Moon Lord")] | ||
public bool MoonLord { get; set; } | ||
|
||
[JsonPropertyName("Solar Pillar")] | ||
public bool SolarPillar { get; set; } | ||
|
||
[JsonPropertyName("Nebula Pillar")] | ||
public bool NebulaPillar { get; set; } | ||
|
||
[JsonPropertyName("Vortex Pillar")] | ||
public bool VortexPillar { get; set; } | ||
|
||
[JsonPropertyName("Stardust Pillar")] | ||
public bool StardustPillar { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
PrismBot/InternalPlugins/ServerStatus/GroupCommands/Progress.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System.Reflection; | ||
using PrismBot.SDK.Data; | ||
using PrismBot.SDK.Extensions; | ||
using PrismBot.SDK.Interfaces; | ||
using PrismBot.SDK.Models; | ||
using SixLabors.Fonts; | ||
using SixLabors.ImageSharp.Drawing.Processing; | ||
using Sora.Entities; | ||
using Sora.Entities.Segment; | ||
using Sora.EventArgs.SoraEvent; | ||
|
||
namespace PrismBot.InternalPlugins.ServerStatus.GroupCommands; | ||
|
||
public class Progress : IGroupCommand | ||
{ | ||
public string GetCommand() | ||
{ | ||
return "进度"; | ||
} | ||
|
||
public string GetPermission() | ||
{ | ||
return "ss.progress"; | ||
} | ||
|
||
public async Task OnPermissionDeniedAsync(string type, GroupMessageEventArgs eventArgs) | ||
{ | ||
await eventArgs.SendDefaultPermissionDeniedMessageAsync(); | ||
} | ||
|
||
public async Task OnPermissionGrantedAsync(string type, GroupMessageEventArgs eventArgs) | ||
{ | ||
var args = eventArgs.Message.GetCommandArgs(); | ||
if (args.Length != 2) | ||
{ | ||
await eventArgs.SourceGroup.SendGroupMessage("您输入的参数不符合要求。请参考以下语法进行输入:进度 <服务器标识符>"); | ||
return; | ||
} | ||
var db = new BotDbContext(); | ||
|
||
var server = await db.Servers.FindAsync(args[1]); | ||
if (server == null) | ||
{ | ||
await eventArgs.SourceGroup.SendGroupMessage("不存在该服务器。"); | ||
return; | ||
} | ||
|
||
var bossProgress = await server.GetServerProgressAsync(); | ||
var bossStatus = bossProgress.Response; | ||
var backgroundImage = | ||
await Image.LoadAsync(Path.Combine(AppContext.BaseDirectory, "images", "progress_bg.png")); | ||
var x = 260; | ||
var y = 460; | ||
var count = 0; | ||
|
||
// 定义你的字体文件的路径 | ||
var fontPath = Path.Combine(AppContext.BaseDirectory, "fonts", "Alibaba-PuHuiTi-Medium.otf"); | ||
|
||
// 加载字体 | ||
var fontCollection = new FontCollection(); | ||
var fontFamily = fontCollection.Add(fontPath); | ||
var font = fontFamily.CreateFont(32, FontStyle.Regular); | ||
|
||
foreach (var value in GetBossStatusValues(bossStatus)) | ||
{ | ||
backgroundImage.Mutate(image => image.DrawText(value ? "已 击 败" : "未 击 败", | ||
font, value ? Color.Red : Color.Black, new PointF(x, y))); | ||
x += 265; | ||
if (x > 1670 && count == 0) | ||
{ | ||
x = 260; | ||
y += 270; | ||
count ++; | ||
} | ||
else if (x > 1670 && count != 0) | ||
{ | ||
x = 260; | ||
y += 210; | ||
} | ||
} | ||
|
||
await backgroundImage.SaveAsync(Path.Combine(AppContext.BaseDirectory, "imageCache", "progress.png")); | ||
await eventArgs.SourceGroup.SendGroupMessage(SoraSegment.Image(Path.Combine(AppContext.BaseDirectory, | ||
"imageCache", "progress.png"))); | ||
} | ||
|
||
public List<bool> GetBossStatusValues(BossStatus bossStatus) | ||
{ | ||
List<bool> values = new List<bool>(); | ||
|
||
PropertyInfo[] properties = typeof(BossStatus).GetProperties(); | ||
|
||
foreach (PropertyInfo property in properties) | ||
{ | ||
if (property.PropertyType == typeof(bool)) | ||
{ | ||
bool value = (bool)property.GetValue(bossStatus); | ||
values.Add(value); | ||
} | ||
} | ||
|
||
return values; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.