This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from slimDebug/develop
added uprank/derank prognosis if you hover over the MMR value
- Loading branch information
Showing
10 changed files
with
272 additions
and
36 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
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,112 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
using System.Windows.Media; | ||
using HuntMmrReader.Models.BaseModels; | ||
|
||
namespace HuntMmrReader.Converters; | ||
|
||
internal abstract class MmrConverterBase : IValueConverter | ||
{ | ||
private static readonly Brush CloseToUpRankBrush = Brushes.Green; | ||
private static readonly Brush CloseToDeRankBrush = Brushes.Red; | ||
private static readonly Brush NeutralRankBrush = Brushes.Orange; | ||
|
||
public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture); | ||
public abstract object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture); | ||
|
||
protected static ushort GetStarsFromMmr(ushort mmr) | ||
{ | ||
return mmr switch | ||
{ | ||
>= HuntBaseEntity.SixStarMinimumMmr => 6, | ||
>= HuntBaseEntity.FiveStarMinimumMmr => 5, | ||
>= HuntBaseEntity.FourStarMinimumMmr => 4, | ||
>= HuntBaseEntity.ThreeStarMinimumMmr => 3, | ||
>= HuntBaseEntity.TwoStarMinimumMmr => 2, | ||
_ => 1 | ||
}; | ||
} | ||
|
||
protected static Brush GetBrushPrognosis(ushort mmr) | ||
{ | ||
var stars = GetStarsFromMmr(mmr); | ||
return stars switch | ||
{ | ||
1 => CloseToUpRankBrush, | ||
2 => HuntBaseEntity.ThreeStarMinimumMmr - mmr < mmr - HuntBaseEntity.TwoStarMinimumMmr | ||
? CloseToUpRankBrush | ||
: HuntBaseEntity.ThreeStarMinimumMmr - mmr > mmr - HuntBaseEntity.TwoStarMinimumMmr | ||
? CloseToDeRankBrush | ||
: NeutralRankBrush, | ||
3 => HuntBaseEntity.FourStarMinimumMmr - mmr < mmr - HuntBaseEntity.ThreeStarMinimumMmr | ||
? CloseToUpRankBrush | ||
: HuntBaseEntity.FourStarMinimumMmr - mmr > mmr - HuntBaseEntity.ThreeStarMinimumMmr | ||
? CloseToDeRankBrush | ||
: NeutralRankBrush, | ||
4 => HuntBaseEntity.FiveStarMinimumMmr - mmr < mmr - HuntBaseEntity.FourStarMinimumMmr | ||
? CloseToUpRankBrush | ||
: HuntBaseEntity.FiveStarMinimumMmr - mmr > mmr - HuntBaseEntity.FourStarMinimumMmr | ||
? CloseToDeRankBrush | ||
: NeutralRankBrush, | ||
5 => HuntBaseEntity.SixStarMinimumMmr - mmr < mmr - HuntBaseEntity.FiveStarMinimumMmr | ||
? CloseToUpRankBrush | ||
: HuntBaseEntity.SixStarMinimumMmr - mmr > mmr - HuntBaseEntity.FiveStarMinimumMmr | ||
? CloseToDeRankBrush | ||
: NeutralRankBrush, | ||
_ => CloseToUpRankBrush | ||
}; | ||
} | ||
|
||
protected static ushort GetUpRankDeRankPrognosis(ushort mmr) | ||
{ | ||
var stars = GetStarsFromMmr(mmr); | ||
return stars switch | ||
{ | ||
1 => (ushort) (HuntBaseEntity.TwoStarMinimumMmr - mmr), | ||
2 => (ushort) (HuntBaseEntity.ThreeStarMinimumMmr - mmr <= mmr - HuntBaseEntity.TwoStarMinimumMmr | ||
? HuntBaseEntity.ThreeStarMinimumMmr - mmr | ||
: 1 + mmr - HuntBaseEntity.TwoStarMinimumMmr), | ||
3 => (ushort) (HuntBaseEntity.FourStarMinimumMmr - mmr <= mmr - HuntBaseEntity.ThreeStarMinimumMmr | ||
? HuntBaseEntity.FourStarMinimumMmr - mmr | ||
: 1 + mmr - HuntBaseEntity.ThreeStarMinimumMmr), | ||
4 => (ushort) (HuntBaseEntity.FiveStarMinimumMmr - mmr <= mmr - HuntBaseEntity.FourStarMinimumMmr | ||
? HuntBaseEntity.FiveStarMinimumMmr - mmr | ||
: 1 + mmr - HuntBaseEntity.FourStarMinimumMmr), | ||
5 => (ushort) (HuntBaseEntity.SixStarMinimumMmr - mmr <= mmr - HuntBaseEntity.FiveStarMinimumMmr | ||
? HuntBaseEntity.SixStarMinimumMmr - mmr | ||
: 1 + mmr - HuntBaseEntity.FiveStarMinimumMmr), | ||
_ => (ushort) (1 + mmr - HuntBaseEntity.SixStarMinimumMmr) | ||
}; | ||
} | ||
|
||
protected static ushort GetClosestRank(ushort mmr) | ||
{ | ||
var stars = GetStarsFromMmr(mmr); | ||
return stars switch | ||
{ | ||
1 => 2, | ||
2 => (ushort) (HuntBaseEntity.ThreeStarMinimumMmr - mmr < mmr - HuntBaseEntity.TwoStarMinimumMmr | ||
? 3 | ||
: HuntBaseEntity.ThreeStarMinimumMmr - mmr > mmr - HuntBaseEntity.TwoStarMinimumMmr | ||
? 2 | ||
: 3), | ||
3 => (ushort) (HuntBaseEntity.FourStarMinimumMmr - mmr < mmr - HuntBaseEntity.ThreeStarMinimumMmr | ||
? 4 | ||
: HuntBaseEntity.FourStarMinimumMmr - mmr > mmr - HuntBaseEntity.ThreeStarMinimumMmr | ||
? 3 | ||
: 4), | ||
4 => (ushort) (HuntBaseEntity.FiveStarMinimumMmr - mmr < mmr - HuntBaseEntity.FourStarMinimumMmr | ||
? 5 | ||
: HuntBaseEntity.FiveStarMinimumMmr - mmr > mmr - HuntBaseEntity.FourStarMinimumMmr | ||
? 4 | ||
: 5), | ||
5 => (ushort) (HuntBaseEntity.SixStarMinimumMmr - mmr < mmr - HuntBaseEntity.FiveStarMinimumMmr | ||
? 6 | ||
: HuntBaseEntity.SixStarMinimumMmr - mmr > mmr - HuntBaseEntity.FiveStarMinimumMmr | ||
? 5 | ||
: 6), | ||
_ => 5 | ||
}; | ||
} | ||
} |
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,20 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Media; | ||
|
||
namespace HuntMmrReader.Converters; | ||
|
||
internal class MmrToColorConverter : MmrConverterBase | ||
{ | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is ushort ushortValue) | ||
return GetBrushPrognosis(ushortValue); | ||
return Brushes.Orange; | ||
} | ||
|
||
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} |
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,36 @@ | ||
using System; | ||
using System.Globalization; | ||
using HuntMmrReader.Models.BaseModels; | ||
|
||
namespace HuntMmrReader.Converters; | ||
|
||
internal class MmrToMmrRangeString : MmrConverterBase | ||
{ | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is not ushort ushortValue) | ||
return string.Empty; | ||
var stars = GetStarsFromMmr(ushortValue); | ||
var baseString = | ||
$"This is a {stars.ToString(CultureInfo.InvariantCulture)} star hunter.{Environment.NewLine}The MMR range of a {stars.ToString(CultureInfo.InvariantCulture)} star hunter goes from "; | ||
return stars switch | ||
{ | ||
1 => | ||
$"{baseString}{HuntBaseEntity.OneStarMinimumMmr.ToString(CultureInfo.InvariantCulture)}-{(HuntBaseEntity.TwoStarMinimumMmr - 1).ToString(CultureInfo.InvariantCulture)}.", | ||
2 => | ||
$"{baseString}{HuntBaseEntity.TwoStarMinimumMmr.ToString(CultureInfo.InvariantCulture)}-{(HuntBaseEntity.ThreeStarMinimumMmr - 1).ToString(CultureInfo.InvariantCulture)}.", | ||
3 => | ||
$"{baseString}{HuntBaseEntity.ThreeStarMinimumMmr.ToString(CultureInfo.InvariantCulture)}-{(HuntBaseEntity.FourStarMinimumMmr - 1).ToString(CultureInfo.InvariantCulture)}.", | ||
4 => | ||
$"{baseString}{HuntBaseEntity.FourStarMinimumMmr.ToString(CultureInfo.InvariantCulture)}-{(HuntBaseEntity.FiveStarMinimumMmr - 1).ToString(CultureInfo.InvariantCulture)}.", | ||
5 => | ||
$"{baseString}{HuntBaseEntity.FiveStarMinimumMmr.ToString(CultureInfo.InvariantCulture)}-{(HuntBaseEntity.SixStarMinimumMmr - 1).ToString(CultureInfo.InvariantCulture)}.", | ||
_ => $"{baseString}{HuntBaseEntity.SixStarMinimumMmr.ToString(CultureInfo.InvariantCulture)}-{'\u221E'}." | ||
}; | ||
} | ||
|
||
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} |
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,19 @@ | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace HuntMmrReader.Converters; | ||
|
||
internal class MmrToPrognosisStringConverter : MmrConverterBase | ||
{ | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return value is not ushort ushortValue | ||
? string.Empty | ||
: $"This hunter is only {GetUpRankDeRankPrognosis(ushortValue).ToString(CultureInfo.InvariantCulture)} MMR points away, before becoming a {GetClosestRank(ushortValue).ToString(CultureInfo.InvariantCulture)} star hunter."; | ||
} | ||
|
||
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} |
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
Oops, something went wrong.