Added Background opacity for better view, added possibility sliders for weighted lane choosing
This commit is contained in:
@@ -70,6 +70,12 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
|
||||
private string? _leagueClientVersion;
|
||||
|
||||
private int _topPercentage = 100;
|
||||
private int _midPercentage = 100;
|
||||
private int _jglPercentage = 100;
|
||||
private int _botPercentage = 100;
|
||||
private int _supPercentage = 100;
|
||||
|
||||
public RelayCommand getRandomChampionLaneComboCommand { get; private set; }
|
||||
|
||||
public List<Champion>? ChampionList
|
||||
@@ -101,6 +107,36 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
get => _leagueClientVersion;
|
||||
set => SetProperty(ref _leagueClientVersion, value);
|
||||
}
|
||||
|
||||
public int TopPercentage
|
||||
{
|
||||
get => _topPercentage;
|
||||
set => SetProperty(ref _topPercentage, value);
|
||||
}
|
||||
|
||||
public int MidPercentage
|
||||
{
|
||||
get => _midPercentage;
|
||||
set => SetProperty(ref _midPercentage, value);
|
||||
}
|
||||
|
||||
public int JglPercentage
|
||||
{
|
||||
get => _jglPercentage;
|
||||
set => SetProperty(ref _jglPercentage, value);
|
||||
}
|
||||
|
||||
public int BotPercentage
|
||||
{
|
||||
get => _botPercentage;
|
||||
set => SetProperty(ref _botPercentage, value);
|
||||
}
|
||||
|
||||
public int SupPercentage
|
||||
{
|
||||
get => _supPercentage;
|
||||
set => SetProperty(ref _supPercentage, value);
|
||||
}
|
||||
|
||||
private async void LoadAndSetChampionImageAsync()
|
||||
{
|
||||
@@ -164,6 +200,41 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
Console.WriteLine("Failed to load Champions: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void getRandomLane()
|
||||
{
|
||||
var weights = new Dictionary<string, int>
|
||||
{
|
||||
{ "Top", TopPercentage },
|
||||
{ "Mid", MidPercentage },
|
||||
{ "Jgl", JglPercentage },
|
||||
{ "Bot", BotPercentage },
|
||||
{ "Sup", SupPercentage },
|
||||
};
|
||||
|
||||
var totalWeight = weights.Values.Sum();
|
||||
if (totalWeight <= 0)
|
||||
{
|
||||
Lane = Lanes[Random.Shared.Next(Lanes.Count)];
|
||||
return;
|
||||
}
|
||||
|
||||
var roll = Random.Shared.Next(totalWeight);
|
||||
|
||||
var x = 0;
|
||||
foreach (var kv in weights)
|
||||
{
|
||||
x += kv.Value;
|
||||
if (roll < x)
|
||||
{
|
||||
Lane = kv.Key;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 5) Sicherheitshalber (wegen Rundungsfehlern)
|
||||
Lane = weights.Keys.Last();
|
||||
}
|
||||
|
||||
private async void getRandomChampionLaneComboCommandExecute()
|
||||
{
|
||||
@@ -174,8 +245,8 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
// champ.Image.Full = await LoadChampionImageAsync(champ);
|
||||
SelectedChampion = champ;
|
||||
LoadAndSetChampionImageAsync();
|
||||
}
|
||||
Lane = Lanes[Random.Shared.Next(Lanes.Count)];
|
||||
}
|
||||
getRandomLane();
|
||||
}
|
||||
|
||||
public async Task InitAsync()
|
||||
@@ -188,5 +259,6 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
_ = InitAsync();
|
||||
getRandomChampionLaneComboCommand = new RelayCommand(getRandomChampionLaneComboCommandExecute);
|
||||
getRandomChampionLaneComboCommandExecute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user