-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manager: Add historical (un)availability to weekly clears
- Loading branch information
Showing
6 changed files
with
284 additions
and
181 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace GW2Scratch.ArcdpsLogManager.Sections.Clears; | ||
|
||
public enum EncounterAvailability | ||
{ | ||
Available, | ||
DoesNotExist, | ||
NotLogged, | ||
} |
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,77 +1,14 @@ | ||
using GW2Scratch.ArcdpsLogManager.Logs; | ||
using GW2Scratch.EVTCAnalytics.GameData.Encounters; | ||
using GW2Scratch.EVTCAnalytics.Processing.Encounters.Modes; | ||
using GW2Scratch.EVTCAnalytics.Processing.Encounters.Results; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace GW2Scratch.ArcdpsLogManager.Sections.Clears; | ||
|
||
public interface IFinishableEncounter | ||
{ | ||
bool IsSatisfiedBy(IEnumerable<LogData> logs); | ||
bool IsChallengeModeSatisfiedBy(IEnumerable<LogData> logs); | ||
bool HasNormalMode { get; } | ||
bool HasChallengeMode { get; } | ||
EncounterAvailability GetNormalModeAvailability(DateOnly resetDate); | ||
EncounterAvailability GetChallengeModeAvailability(DateOnly resetDate); | ||
Category Category { get; } | ||
} | ||
|
||
public class NormalEncounter(Encounter encounter, bool hasChallengeMode, Category category) : IFinishableEncounter | ||
{ | ||
public Encounter Encounter { get; } = encounter; | ||
public bool HasNormalMode => true; | ||
public bool HasChallengeMode { get; } = hasChallengeMode; | ||
public Category Category { get; } = category; | ||
|
||
public bool IsSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return logs.Any(log => log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == Encounter); | ||
} | ||
|
||
public bool IsChallengeModeSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return logs.Any(log => log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == Encounter && | ||
log.EncounterMode == EncounterMode.Challenge); | ||
} | ||
} | ||
|
||
public class UnsupportedEncounter(string name, Category category) : IFinishableEncounter | ||
{ | ||
public string Name { get; } = name; | ||
public bool HasNormalMode => false; | ||
public bool HasChallengeMode => false; | ||
public Category Category { get; } = category; | ||
|
||
public bool IsSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
|
||
public bool IsChallengeModeSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
|
||
public class MultipartEncounter(string name, IEnumerable<Encounter> encounters, bool hasChallengeMode, Category category) : IFinishableEncounter | ||
{ | ||
public string Name { get; } = name; | ||
private IEnumerable<Encounter> Encounters { get; } = encounters; | ||
public bool HasNormalMode => true; | ||
public bool HasChallengeMode { get; } = hasChallengeMode; | ||
public Category Category { get; } = category; | ||
|
||
public bool IsSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return Encounters.All(encounter => logs.Any(log => | ||
log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == encounter)); | ||
} | ||
|
||
public bool IsChallengeModeSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return Encounters.All(encounter => logs.Any(log => | ||
log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == encounter && | ||
log.EncounterMode == EncounterMode.Challenge)); | ||
} | ||
} |
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,63 @@ | ||
using GW2Scratch.ArcdpsLogManager.Logs; | ||
using GW2Scratch.EVTCAnalytics.GameData.Encounters; | ||
using GW2Scratch.EVTCAnalytics.Processing.Encounters.Modes; | ||
using GW2Scratch.EVTCAnalytics.Processing.Encounters.Results; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace GW2Scratch.ArcdpsLogManager.Sections.Clears; | ||
|
||
public class MultipartEncounter : IFinishableEncounter | ||
{ | ||
private readonly DateOnly? normalModeSince; | ||
private readonly DateOnly? challengeModeSince; | ||
|
||
public MultipartEncounter(string name, IEnumerable<Encounter> encounters, Category category, DateOnly? normalModeSince, DateOnly? challengeModeSince) | ||
{ | ||
if (normalModeSince.HasValue && normalModeSince.Value.DayOfWeek != DayOfWeek.Monday) | ||
{ | ||
throw new ArgumentException("Normal mode reset date must be a Monday.", nameof(normalModeSince)); | ||
} | ||
|
||
if (challengeModeSince.HasValue && challengeModeSince.Value.DayOfWeek != DayOfWeek.Monday) | ||
{ | ||
throw new ArgumentException("Challenge mode reset date must be a Monday.", nameof(challengeModeSince)); | ||
} | ||
|
||
this.normalModeSince = normalModeSince; | ||
this.challengeModeSince = challengeModeSince; | ||
Name = name; | ||
Encounters = encounters; | ||
Category = category; | ||
} | ||
|
||
public string Name { get; } | ||
private IEnumerable<Encounter> Encounters { get; } | ||
public Category Category { get; } | ||
|
||
public EncounterAvailability GetNormalModeAvailability(DateOnly resetDate) | ||
{ | ||
if (normalModeSince == null) return EncounterAvailability.NotLogged; | ||
return resetDate < normalModeSince ? EncounterAvailability.DoesNotExist : EncounterAvailability.Available; | ||
} | ||
|
||
public EncounterAvailability GetChallengeModeAvailability(DateOnly resetDate) | ||
{ | ||
if (challengeModeSince == null) return EncounterAvailability.NotLogged; | ||
return resetDate < challengeModeSince ? EncounterAvailability.DoesNotExist : EncounterAvailability.Available; | ||
} | ||
|
||
public bool IsSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return Encounters.All(encounter => logs.Any(log => | ||
log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == encounter)); | ||
} | ||
|
||
public bool IsChallengeModeSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return Encounters.All(encounter => logs.Any(log => | ||
log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == encounter && | ||
log.EncounterMode == EncounterMode.Challenge)); | ||
} | ||
} |
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,76 @@ | ||
using GW2Scratch.ArcdpsLogManager.Logs; | ||
using GW2Scratch.EVTCAnalytics.GameData.Encounters; | ||
using GW2Scratch.EVTCAnalytics.Processing.Encounters.Modes; | ||
using GW2Scratch.EVTCAnalytics.Processing.Encounters.Results; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace GW2Scratch.ArcdpsLogManager.Sections.Clears; | ||
|
||
public class NormalEncounter : IFinishableEncounter | ||
{ | ||
private readonly DateOnly? normalModeSince; | ||
private readonly DateOnly? challengeModeSince; | ||
private readonly DateOnly? logsSince; | ||
|
||
public NormalEncounter(Encounter encounter, Category category, DateOnly? normalModeSince, DateOnly? challengeModeSince, DateOnly? logsSince = null) | ||
{ | ||
if (normalModeSince.HasValue && normalModeSince.Value.DayOfWeek != DayOfWeek.Monday) | ||
{ | ||
throw new ArgumentException("Normal mode reset date must be a Monday.", nameof(normalModeSince)); | ||
} | ||
|
||
if (challengeModeSince.HasValue && challengeModeSince.Value.DayOfWeek != DayOfWeek.Monday) | ||
{ | ||
throw new ArgumentException("Challenge mode reset date must be a Monday.", nameof(challengeModeSince)); | ||
} | ||
|
||
if (logsSince.HasValue && logsSince.Value.DayOfWeek != DayOfWeek.Monday) | ||
{ | ||
throw new ArgumentException("Logs since date must be a Monday.", nameof(logsSince)); | ||
} | ||
|
||
this.normalModeSince = normalModeSince; | ||
this.challengeModeSince = challengeModeSince; | ||
this.logsSince = logsSince; | ||
Encounter = encounter; | ||
Category = category; | ||
} | ||
|
||
public Encounter Encounter { get; } | ||
|
||
public EncounterAvailability GetNormalModeAvailability(DateOnly resetDate) | ||
{ | ||
if (normalModeSince == null) return EncounterAvailability.DoesNotExist; | ||
if (resetDate < normalModeSince) | ||
{ | ||
return EncounterAvailability.DoesNotExist; | ||
} | ||
|
||
return resetDate < logsSince ? EncounterAvailability.NotLogged : EncounterAvailability.Available; | ||
} | ||
|
||
public EncounterAvailability GetChallengeModeAvailability(DateOnly resetDate) | ||
{ | ||
if (challengeModeSince == null) return EncounterAvailability.DoesNotExist; | ||
if (resetDate < challengeModeSince) | ||
{ | ||
return EncounterAvailability.DoesNotExist; | ||
} | ||
return resetDate < logsSince ? EncounterAvailability.NotLogged : EncounterAvailability.Available; | ||
} | ||
|
||
public Category Category { get; } | ||
|
||
public bool IsSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return logs.Any(log => log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == Encounter); | ||
} | ||
|
||
public bool IsChallengeModeSatisfiedBy(IEnumerable<LogData> logs) | ||
{ | ||
return logs.Any(log => log.ParsingStatus == ParsingStatus.Parsed && log.EncounterResult == EncounterResult.Success && log.Encounter == Encounter && | ||
log.EncounterMode == EncounterMode.Challenge); | ||
} | ||
} |
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,17 @@ | ||
using GW2Scratch.ArcdpsLogManager.Logs; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace GW2Scratch.ArcdpsLogManager.Sections.Clears; | ||
|
||
public class UnsupportedEncounter(string name, Category category) : IFinishableEncounter | ||
{ | ||
public EncounterAvailability GetNormalModeAvailability(DateOnly resetDate) => EncounterAvailability.NotLogged; | ||
public EncounterAvailability GetChallengeModeAvailability(DateOnly resetDate) => EncounterAvailability.NotLogged; | ||
|
||
public string Name { get; } = name; | ||
public Category Category { get; } = category; | ||
|
||
public bool IsSatisfiedBy(IEnumerable<LogData> logs) => false; | ||
public bool IsChallengeModeSatisfiedBy(IEnumerable<LogData> logs) => false; | ||
} |
Oops, something went wrong.