This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a thing to check the timeline.
- Loading branch information
1 parent
3016cef
commit 57ad3f8
Showing
15 changed files
with
176 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"ClickingCount": 86236, | ||
"SayingHelloCount": 75, | ||
"ClickingCount": 87877, | ||
"SayingHelloCount": 76, | ||
"SaidUsers": [] | ||
} |
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
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,24 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace RotationSolver.Basic.Data; | ||
internal readonly struct TimelineItem(float time, string name, params string[] ids) | ||
{ | ||
public float Time => time; | ||
|
||
public bool IsShown => !name.StartsWith("--") && !name.EndsWith("--"); | ||
|
||
public bool IsIdMatched(uint id) | ||
{ | ||
return ids.Any(i => new Regex(i).IsMatch(id.ToString("X"))); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $""" | ||
IsShown: {IsShown}, | ||
Time: {time}, | ||
Name: {name}, | ||
Ids: {string.Join(", ", ids)} | ||
"""; | ||
} | ||
} |
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
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
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
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
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,83 @@ | ||
using ECommons.DalamudServices; | ||
using Newtonsoft.Json.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace RotationSolver.Updaters; | ||
internal static partial class RaidTimeUpdater | ||
{ | ||
internal static void Enable() | ||
{ | ||
Svc.ClientState.TerritoryChanged += ClientState_TerritoryChanged; | ||
ClientState_TerritoryChanged(Svc.ClientState.TerritoryType); | ||
} | ||
|
||
internal static void Disable() | ||
{ | ||
Svc.ClientState.TerritoryChanged -= ClientState_TerritoryChanged; | ||
} | ||
|
||
private static void ClientState_TerritoryChanged(ushort obj) | ||
{ | ||
try | ||
{ | ||
UpdateRaidTime("06-ew/raid/p9s.txt"); | ||
} | ||
catch (Exception e) | ||
{ | ||
Svc.Log.Warning(e, "Failed to update the raid timeline!"); | ||
} | ||
} | ||
static async void UpdateRaidTime(string path) | ||
{ | ||
using var client = new HttpClient(); | ||
var message = await client.GetAsync("https://raw.githubusercontent.com/OverlayPlugin/cactbot/main/ui/raidboss/data/" + path); | ||
|
||
if (!message.IsSuccessStatusCode) return; | ||
|
||
var str = await message.Content.ReadAsStringAsync(); | ||
|
||
var result = new List<TimelineItem>(); | ||
foreach (var timelineItem in TimeLineItem().Matches(str).Cast<Match>()) | ||
{ | ||
try | ||
{ | ||
var header = TimeHeader().Match(timelineItem.Value); | ||
var action = JObject.Parse(ActionGetter().Match(timelineItem.Value).Value)["id"]; | ||
var time = float.Parse(Time().Match(header.Value).Value); | ||
var name = Name().Match(header.Value).Value[1..^1]; | ||
|
||
string[] ids = []; | ||
if (action is JArray array) | ||
{ | ||
ids = [..array.Select(i => i.ToString())]; | ||
} | ||
else | ||
{ | ||
ids = [action?.ToString() ?? string.Empty]; | ||
} | ||
|
||
result.Add(new (time, name, ids)); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Svc.Log.Warning(ex, "sth wrong with matching!"); | ||
} | ||
} | ||
DataCenter.TimelineItems = [..result]; | ||
} | ||
|
||
[GeneratedRegex("\\d+\\.\\d.*Ability.*")] | ||
private static partial Regex TimeLineItem(); | ||
|
||
[GeneratedRegex("^\\d+\\.\\d")] | ||
private static partial Regex Time(); | ||
|
||
[GeneratedRegex("\".*?\"")] | ||
private static partial Regex Name(); | ||
|
||
[GeneratedRegex("^\\d+\\.\\d \".*?\"")] | ||
private static partial Regex TimeHeader(); | ||
|
||
[GeneratedRegex("{.*}")] | ||
private static partial Regex ActionGetter(); | ||
} |
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