Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Griseo-bh3rd committed Apr 13, 2024
1 parent 5e31d62 commit e621fb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions util/Broadcast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Player, bool> Check;
public int priority;
public byte priority;
public List<string> 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 $"<size=26>「{prefix}」:{text}[{time}]</size>";
}
}
public class BroadcastMain
{
Expand All @@ -42,14 +47,14 @@ public static IEnumerator<float> 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--;
}
Expand Down
2 changes: 1 addition & 1 deletion util/Gamemode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void OnRoundStarted()
switch (NextMode)
{
case Gamemodes.Normal:
PluginAPI.Core.Server.SendBroadcast("<size=26><color=red>回合开始</color>当前回合已经开始</size>", 5, Broadcast.BroadcastFlags.Normal, true);
BroadcastMain.SendGlobalcast(new BroadcastItem { priority = (byte)BroadcastPriority.Normal, prefix = "<color=red>回合开始</color>", text = "当前回合已经开始", time = 5});
break;
case Gamemodes.Other:
PluginAPI.Core.Server.SendBroadcast("<size=26><color=red>「回合开始」</color>本局为娱乐模式</size>", 5, Broadcast.BroadcastFlags.Normal, true);
Expand Down

0 comments on commit e621fb9

Please sign in to comment.