Added Background opacity for better view, added possibility sliders for weighted lane choosing

This commit is contained in:
Ano-sys
2025-04-19 22:18:06 +02:00
parent 1dcbaf4cf8
commit 5a1445a6b4
2 changed files with 141 additions and 29 deletions
+74 -2
View File
@@ -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();
}
}