Skip to content

Commit a49e76f

Browse files
committed
better support for offline raids
1 parent 45db343 commit a49e76f

File tree

5 files changed

+134
-37
lines changed

5 files changed

+134
-37
lines changed

TarkovMonitor/Blazor/Components/MessageBoard.razor

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
</span>
2323
</div>
2424
<div class="d-flex align-center">
25+
@foreach (MonitorMessageSelect select in message.Selects)
26+
{
27+
28+
<MudSelect T="MonitorMessageSelectOption" Placeholder="@select.Placeholder" SelectedValuesChanged="@((e) => MessageSelectChanged(select, e) )">
29+
@foreach (MonitorMessageSelectOption option in select.Options)
30+
{
31+
<MudSelectItem Value="@option">@option.Text</MudSelectItem>
32+
}
33+
</MudSelect>
34+
}
2535
@foreach (MonitorMessageButton button in message.Buttons)
2636
{
2737
<MudButton Variant="Variant.Filled" Color="@button.Color" StartIcon="@button.Icon" OnClick="@((e) => MessageButtonClick(button) )">@button.Text</MudButton>
@@ -38,8 +48,8 @@
3848

3949
</MudStack>
4050

41-
@code {
42-
// Force refresh every minute to update timestamps
51+
@code {
52+
// Force refresh every minute to update timestamps
4353
Timer? timer;
4454

4555
protected override void OnInitialized()
@@ -161,4 +171,16 @@
161171
messageLog.AddMessage($"Error in message button: ${ex.Message} {ex.StackTrace}", "exception");
162172
}
163173
}
174+
175+
private async void MessageSelectChanged(MonitorMessageSelect select, IEnumerable<MonitorMessageSelectOption> selected)
176+
{
177+
try
178+
{
179+
select.ChangeSelection(selected.First());
180+
}
181+
catch (Exception ex)
182+
{
183+
messageLog.AddMessage($"Error in message select: ${ex.Message} {ex.StackTrace}", "exception");
184+
}
185+
}
164186
}

TarkovMonitor/MainBlazorUI.cs

Lines changed: 69 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private void Eft_RaidEnded(object? sender, RaidInfoEventArgs e)
237237
}
238238
messageLog.AddMessage(monMessage);
239239
runthroughTimer.Stop();
240-
if (e.RaidInfo.RaidType == RaidType.Scav && Properties.Settings.Default.scavCooldownAlert)
240+
if (Properties.Settings.Default.scavCooldownAlert && (e.RaidInfo.RaidType == RaidType.Scav || e.RaidInfo.RaidType == RaidType.PVE))
241241
{
242242
scavCooldownTimer.Stop();
243243
scavCooldownTimer.Interval = TimeSpan.FromSeconds(TarkovDev.ResetScavCoolDown()).TotalMilliseconds;
@@ -630,25 +630,40 @@ private async void Eft_RaidStart(object? sender, RaidInfoEventArgs e)
630630
MonitorMessage monMessage = new($"Starting {e.RaidInfo.RaidType} raid on {mapName}");
631631
if (map != null && e.RaidInfo.StartedTime != null && map.HasGoons())
632632
{
633-
MonitorMessageButton goonsButton = new($"Report Goons", Icons.Material.Filled.Groups);
634-
goonsButton.OnClick = async () => {
635-
try
633+
AddGoonsButton(monMessage, e.RaidInfo);
634+
}
635+
else if (map == null)
636+
{
637+
monMessage.Message = $"Starting {e.RaidInfo.RaidType} raid on:";
638+
MonitorMessageSelect select = new();
639+
foreach (var gameMap in TarkovDev.Maps)
640+
{
641+
select.Options.Add(new(gameMap.name, gameMap.nameId));
642+
}
643+
select.Placeholder = "Select map";
644+
monMessage.Selects.Add(select);
645+
MonitorMessageButton mapButton = new("Set map", Icons.Material.Filled.Map);
646+
mapButton.OnClick += () => {
647+
if (select.Selected == null)
636648
{
637-
await TarkovDev.PostGoonsSighting(e.RaidInfo.Map, (DateTime)e.RaidInfo.StartedTime, eft.AccountId);
638-
messageLog.AddMessage($"Goons reported on {mapName}", "info");
649+
return;
639650
}
640-
catch (Exception ex) {
641-
messageLog.AddMessage($"Error reporting goons: {ex.Message} {ex.StackTrace}", "exception");
651+
e.RaidInfo.Map = select.Selected.Value;
652+
monMessage.Message = $"Starting {e.RaidInfo.RaidType} raid on {select.Selected.Text}";
653+
monMessage.Buttons.Clear();
654+
monMessage.Selects.Clear();
655+
//AddGoonsButton(monMessage, e.RaidInfo); // offline raids have goons on all goons maps
656+
if (Properties.Settings.Default.autoNavigateMap)
657+
{
658+
var map = TarkovDev.Maps.Find(m => m.nameId == e.RaidInfo.Map);
659+
if (map == null)
660+
{
661+
return;
662+
}
663+
SocketClient.NavigateToMap(map);
642664
}
643-
monMessage.Buttons.Remove(goonsButton);
644665
};
645-
goonsButton.Confirm = new(
646-
$"Report Goons on {mapName}",
647-
"<p>Please only submit a report if you saw the goons in this raid.</p><p><strong>Notice:</strong> By submitting a goons report, you consent to collection of your IP address and EFT account id for report verification purposes.</p>",
648-
"Submit report", "Cancel"
649-
);
650-
goonsButton.Timeout = TimeSpan.FromMinutes(120).TotalMilliseconds;
651-
monMessage.Buttons.Add(goonsButton);
666+
monMessage.Buttons.Add(mapButton);
652667
}
653668
messageLog.AddMessage(monMessage);
654669
if (Properties.Settings.Default.raidStartAlert && e.RaidInfo.StartingTime == null)
@@ -661,26 +676,51 @@ private async void Eft_RaidStart(object? sender, RaidInfoEventArgs e)
661676
{
662677
messageLog.AddMessage($"Re-entering raid on {mapName}");
663678
}
664-
if (e.RaidInfo.Reconnected || !e.RaidInfo.Online || e.RaidInfo.QueueTime == 0 || e.RaidInfo.RaidType == RaidType.Unknown)
665-
{
666-
return;
667-
}
668-
if (Properties.Settings.Default.runthroughAlert && e.RaidInfo.RaidType == RaidType.PMC)
679+
if (Properties.Settings.Default.runthroughAlert && !e.RaidInfo.Reconnected && (e.RaidInfo.RaidType == RaidType.PMC || e.RaidInfo.RaidType == RaidType.PVE))
669680
{
670681
runthroughTimer.Stop();
671682
runthroughTimer.Start();
672683
}
673-
if (!Properties.Settings.Default.submitQueueTime || e.Profile.Type == ProfileType.PVE)
684+
if (Properties.Settings.Default.submitQueueTime && e.RaidInfo.QueueTime > 0 && e.RaidInfo.RaidType != RaidType.Unknown)
674685
{
675-
return;
676-
}
677-
try
678-
{
679-
await TarkovDev.PostQueueTime(e.RaidInfo.Map, (int)Math.Round(e.RaidInfo.QueueTime), e.RaidInfo.RaidType.ToString().ToLower());
686+
try
687+
{
688+
await TarkovDev.PostQueueTime(e.RaidInfo.Map, (int)Math.Round(e.RaidInfo.QueueTime), e.RaidInfo.RaidType.ToString().ToLower(), eft.CurrentProfile.Type);
689+
}
690+
catch (Exception ex)
691+
{
692+
messageLog.AddMessage($"Error submitting queue time: {ex.Message}", "exception");
693+
}
680694
}
681-
catch (Exception ex)
695+
}
696+
697+
private void AddGoonsButton(MonitorMessage monMessage, RaidInfo raidInfo)
698+
{
699+
var mapName = raidInfo.Map;
700+
var map = TarkovDev.Maps.Find(m => m.nameId == mapName);
701+
if (map != null) mapName = map.name;
702+
if (map != null && raidInfo.StartedTime != null && map.HasGoons())
682703
{
683-
messageLog.AddMessage($"Error submitting queue time: {ex.Message}", "exception");
704+
MonitorMessageButton goonsButton = new($"Report Goons", Icons.Material.Filled.Groups);
705+
goonsButton.OnClick = async () => {
706+
try
707+
{
708+
await TarkovDev.PostGoonsSighting(raidInfo.Map, (DateTime)raidInfo.StartedTime, eft.AccountId, eft.CurrentProfile.Type);
709+
messageLog.AddMessage($"Goons reported on {mapName}", "info");
710+
}
711+
catch (Exception ex)
712+
{
713+
messageLog.AddMessage($"Error reporting goons: {ex.Message} {ex.StackTrace}", "exception");
714+
}
715+
monMessage.Buttons.Remove(goonsButton);
716+
};
717+
goonsButton.Confirm = new(
718+
$"Report Goons on {mapName}",
719+
"<p>Please only submit a report if you saw the goons in this raid.</p><p><strong>Notice:</strong> By submitting a goons report, you consent to collection of your IP address and EFT account id for report verification purposes.</p>",
720+
"Submit report", "Cancel"
721+
);
722+
goonsButton.Timeout = TimeSpan.FromMinutes(120).TotalMilliseconds;
723+
monMessage.Buttons.Add(goonsButton);
684724
}
685725
}
686726

TarkovMonitor/MonitorMessage.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class MonitorMessage
1414
public string Url { get; set; } = "";
1515
public Action? OnClick { get; set; } = null;
1616
public ObservableCollection<MonitorMessageButton> Buttons { get; set; } = new();
17+
public ObservableCollection<MonitorMessageSelect> Selects { get; set; } = new();
1718
public MonitorMessage(string message)
1819
{
1920
Message = message;
@@ -142,4 +143,37 @@ public MonitorMessageButtonConfirm(string title, string message, string yesText,
142143
CancelText = cancelText;
143144
}
144145
}
146+
147+
public class MonitorMessageSelect
148+
{
149+
public List<MonitorMessageSelectOption> Options { get; set; } = new();
150+
public event EventHandler<MonitorMessageSelectChangedEventArgs>? SelectionChanged;
151+
public MonitorMessageSelectOption? Selected { get; private set; }
152+
public string Placeholder { get; set; } = "";
153+
public void ChangeSelection(MonitorMessageSelectOption selected)
154+
{
155+
Selected = selected;
156+
SelectionChanged?.Invoke(this, new MonitorMessageSelectChangedEventArgs() { Selected = selected });
157+
}
158+
}
159+
160+
public class MonitorMessageSelectOption
161+
{
162+
public string Text { get; set; }
163+
public string Value { get; set; }
164+
override public string ToString()
165+
{
166+
return Text;
167+
}
168+
public MonitorMessageSelectOption(string text, string value)
169+
{
170+
Text = text;
171+
Value = value;
172+
}
173+
}
174+
175+
public class MonitorMessageSelectChangedEventArgs : EventArgs
176+
{
177+
public MonitorMessageSelectOption Selected { get; set; }
178+
}
145179
}

TarkovMonitor/SocketClient.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private static string GetId(int length)
3232
string characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
3333

3434
Random r = new Random();
35-
int rInt = r.Next(0, characters.Length);
35+
//int rInt = r.Next(0, characters.Length);
3636

3737
for (int i = 0; i < length; i++)
3838
{
@@ -100,7 +100,6 @@ public static async Task Connect()
100100
catch (Exception ex) {
101101
ExceptionThrown?.Invoke(null, new(ex, $"Connecting with id {Properties.Settings.Default.remoteId}"));
102102
}
103-
104103
}
105104

106105
private static void SettingChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)

TarkovMonitor/TarkovDev.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ query TarkovMonitorPlayerLevels {
226226
return PlayerLevels;
227227
}
228228

229-
public async static Task<DataSubmissionResponse> PostQueueTime(string mapNameId, int queueTime, string type)
229+
public async static Task<DataSubmissionResponse> PostQueueTime(string mapNameId, int queueTime, string type, ProfileType gameMode)
230230
{
231231
try
232232
{
233-
return await api.SubmitQueueTime(new QueueTimeBody() { map = mapNameId, time = queueTime, type = type });
233+
return await api.SubmitQueueTime(new QueueTimeBody() { map = mapNameId, time = queueTime, type = type, gameMode = gameMode.ToString().ToLower() });
234234
}
235235
catch (ApiException ex)
236236
{
@@ -246,11 +246,11 @@ public async static Task<DataSubmissionResponse> PostQueueTime(string mapNameId,
246246
}
247247
}
248248

249-
public async static Task<DataSubmissionResponse> PostGoonsSighting(string mapNameId, DateTime date, int accountId)
249+
public async static Task<DataSubmissionResponse> PostGoonsSighting(string mapNameId, DateTime date, int accountId, ProfileType profileType)
250250
{
251251
try
252252
{
253-
return await api.SubmitGoonsSighting(new GoonsBody() { map = mapNameId, timestamp = ((DateTimeOffset)date).ToUnixTimeMilliseconds(), accountId = accountId });
253+
return await api.SubmitGoonsSighting(new GoonsBody() { map = mapNameId, gameMode = profileType.ToString().ToLower(), timestamp = ((DateTimeOffset)date).ToUnixTimeMilliseconds(), accountId = accountId });
254254
}
255255
catch (ApiException ex)
256256
{
@@ -471,6 +471,7 @@ public class QueueTimeBody
471471
public string map { get; set; }
472472
public int time { get; set; }
473473
public string type { get; set; }
474+
public string gameMode { get; set; }
474475
}
475476

476477
public class DataSubmissionResponse
@@ -481,6 +482,7 @@ public class DataSubmissionResponse
481482
public class GoonsBody
482483
{
483484
public string map { get; set; }
485+
public string gameMode { get; set; }
484486
public long timestamp { get; set; }
485487
public int accountId { get; set; }
486488
}

0 commit comments

Comments
 (0)