diff --git a/util/Broadcast.cs b/util/Broadcast.cs index 0b7a535..374eecf 100644 --- a/util/Broadcast.cs +++ b/util/Broadcast.cs @@ -8,15 +8,20 @@ namespace UtilPlugin { + public enum BroadcastPriority : byte { Lowest = 1, Lower = 50, Normal = 100, Higher = 150, Highest = 200, eme = 255} public class BroadcastItem { public int time; public string prefix, text; public Func Check; - public int priority; + public byte priority; public List targets; public static bool operator <(BroadcastItem lhs, BroadcastItem rhs) => lhs.priority < rhs.priority; - public static bool operator >(BroadcastItem lhs, BroadcastItem rhs) => lhs.priority > rhs.priority; + public static bool operator >(BroadcastItem lhs, BroadcastItem rhs) => lhs.priority > rhs.priority; + public override string ToString() + { + return $"「{prefix}」:{text}[{time}]"; + } } public class BroadcastMain { @@ -42,14 +47,14 @@ public static IEnumerator Maincoroutine() int remain = 3; foreach (BroadcastItem item in globals) { - if (remain > 0) result += $"「{item.prefix}」:{item.text}[{item.time}]\n"; + if (remain > 0) result += $"{item}\n"; remain--; } foreach (BroadcastItem item in normals) { if ((item.targets.Contains(player.UserId)) || (item.Check != null && item.Check(player))) { - result += $"「{item.prefix}」:{item.text}[{item.time}]\n"; + result += $"{item}\n"; } remain--; } diff --git a/util/Gamemode.cs b/util/Gamemode.cs index 1a4dd65..32042e7 100644 --- a/util/Gamemode.cs +++ b/util/Gamemode.cs @@ -27,7 +27,7 @@ public static void OnRoundStarted() switch (NextMode) { case Gamemodes.Normal: - PluginAPI.Core.Server.SendBroadcast("「回合开始」当前回合已经开始", 5, Broadcast.BroadcastFlags.Normal, true); + BroadcastMain.SendGlobalcast(new BroadcastItem { priority = (byte)BroadcastPriority.Normal, prefix = "回合开始", text = "当前回合已经开始", time = 5}); break; case Gamemodes.Other: PluginAPI.Core.Server.SendBroadcast("「回合开始」本局为娱乐模式", 5, Broadcast.BroadcastFlags.Normal, true);