Added drop chance calculator.
This commit is contained in:
95
osrs-toolbox/Models/DropChanceModel.cs
Normal file
95
osrs-toolbox/Models/DropChanceModel.cs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
|
||||||
|
namespace osrs_toolbox
|
||||||
|
{
|
||||||
|
public abstract class DropChanceModel : ModelBase
|
||||||
|
{
|
||||||
|
private double _dropRate;
|
||||||
|
private int _currentKC;
|
||||||
|
|
||||||
|
private double _chanceAtCurrent;
|
||||||
|
private int _kcForFifty;
|
||||||
|
private int _kcForNinety;
|
||||||
|
|
||||||
|
private double _chanceCheck;
|
||||||
|
|
||||||
|
private int _kcForChanceCheck;
|
||||||
|
|
||||||
|
public double DropRate
|
||||||
|
{
|
||||||
|
get { return _dropRate; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _dropRate, value, nameof(DropRate));
|
||||||
|
OnPropertyChanged(nameof(ChanceAtCurrent));
|
||||||
|
OnPropertyChanged(nameof(KCForFifty));
|
||||||
|
OnPropertyChanged(nameof(KCForNinety));
|
||||||
|
OnPropertyChanged(nameof(KCForChanceCheck));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int CurrentKC
|
||||||
|
{
|
||||||
|
get { return _currentKC; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _currentKC, value, nameof(CurrentKC));
|
||||||
|
OnPropertyChanged(nameof(ChanceAtCurrent));
|
||||||
|
OnPropertyChanged(nameof(KCForFifty));
|
||||||
|
OnPropertyChanged(nameof(KCForNinety));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ChanceAtCurrent
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
double rate = DropRate > 1 ? (1 / DropRate) : DropRate;
|
||||||
|
return 1 - Math.Pow(1 - rate,CurrentKC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int KCForFifty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
double rate = DropRate > 1 ? (1 / DropRate) : DropRate;
|
||||||
|
double kc = Math.Log(1 / 2) / Math.Log(1 - rate);
|
||||||
|
return (int)Math.Round(kc, MidpointRounding.AwayFromZero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int KCForNinety
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
double rate = DropRate > 1 ? (1 / DropRate) : DropRate;
|
||||||
|
double kc = Math.Log(1 / 10) / Math.Log(1 - rate);
|
||||||
|
return (int)Math.Ceiling(kc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ChanceCheck
|
||||||
|
{
|
||||||
|
get { return _chanceCheck; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _chanceCheck, value, nameof(ChanceCheck));
|
||||||
|
OnPropertyChanged(nameof(KCForChanceCheck));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int KCForChanceCheck
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
double rate = DropRate > 1 ? (1 / DropRate) : DropRate;
|
||||||
|
double chance = ChanceCheck > 1 ? (ChanceCheck / 100) : ChanceCheck;
|
||||||
|
double kc = Math.Log(1 - chance) / Math.Log(1 - rate);
|
||||||
|
return (int)Math.Ceiling(kc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -12,11 +12,18 @@ namespace osrs_toolbox
|
|||||||
public abstract class HomePageModel : ModelBase
|
public abstract class HomePageModel : ModelBase
|
||||||
{
|
{
|
||||||
private ICommand _openCompetitionOverlaySettings;
|
private ICommand _openCompetitionOverlaySettings;
|
||||||
|
private ICommand _openDropChanceCalculator;
|
||||||
|
|
||||||
public ICommand OpenCompetitionOverlaySettings
|
public ICommand OpenCompetitionOverlaySettings
|
||||||
{
|
{
|
||||||
get { return _openCompetitionOverlaySettings; }
|
get { return _openCompetitionOverlaySettings; }
|
||||||
set { SetProperty(ref _openCompetitionOverlaySettings, value, nameof(OpenCompetitionOverlaySettings)); }
|
set { SetProperty(ref _openCompetitionOverlaySettings, value, nameof(OpenCompetitionOverlaySettings)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICommand OpenDropChanceCalculator
|
||||||
|
{
|
||||||
|
get { return _openDropChanceCalculator; }
|
||||||
|
set { SetProperty(ref _openDropChanceCalculator, value, nameof(OpenDropChanceCalculator)); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
osrs-toolbox/ViewModels/DropChanceViewModel.cs
Normal file
29
osrs-toolbox/ViewModels/DropChanceViewModel.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osrs_toolbox
|
||||||
|
{
|
||||||
|
public class DropChanceViewModel : DropChanceModel
|
||||||
|
{
|
||||||
|
public DropChanceViewModel()
|
||||||
|
{
|
||||||
|
InitializeVariables();
|
||||||
|
InitializeCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeVariables()
|
||||||
|
{
|
||||||
|
DropRate = 1;
|
||||||
|
CurrentKC = 1;
|
||||||
|
ChanceCheck = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeCommands()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -23,6 +23,7 @@ namespace osrs_toolbox
|
|||||||
private void InitializeCommands()
|
private void InitializeCommands()
|
||||||
{
|
{
|
||||||
OpenCompetitionOverlaySettings = new RelayCommand(DoOpenCompetitionOverlaySettings);
|
OpenCompetitionOverlaySettings = new RelayCommand(DoOpenCompetitionOverlaySettings);
|
||||||
|
OpenDropChanceCalculator = new RelayCommand(DoOpenDropChanceCalculator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoOpenCompetitionOverlaySettings(object obj)
|
private void DoOpenCompetitionOverlaySettings(object obj)
|
||||||
@@ -38,5 +39,19 @@ namespace osrs_toolbox
|
|||||||
cosv.Show();
|
cosv.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DoOpenDropChanceCalculator(object obj)
|
||||||
|
{
|
||||||
|
if (DropChanceView.Current != null)
|
||||||
|
{
|
||||||
|
DropChanceView.Current.Close();
|
||||||
|
DropChanceView.Current = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DropChanceView dcv = new DropChanceView();
|
||||||
|
dcv.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
osrs-toolbox/Views/DropChanceView.xaml
Normal file
41
osrs-toolbox/Views/DropChanceView.xaml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<Window x:Class="osrs_toolbox.DropChanceView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:osrs_toolbox"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Drop Chance Calculator" Height="450" Width="800" SizeToContent="WidthAndHeight">
|
||||||
|
<Window.DataContext>
|
||||||
|
<local:DropChanceViewModel/>
|
||||||
|
</Window.DataContext>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="2*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Drop Rate:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||||
|
<TextBlock Text="Current KC:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||||
|
<TextBlock Text="Chance at Current KC:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||||
|
<!--TextBlock Text="KC for 50% Chance:" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/-->
|
||||||
|
<!--TextBlock Text="KC for 90% Chance:" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/-->
|
||||||
|
<TextBlock Text="X% Chance:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||||
|
<TextBlock Text="KC for X% Chance:" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||||
|
<TextBox Text="{Binding DropRate, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="3"/>
|
||||||
|
<TextBox Text="{Binding CurrentKC, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="3"/>
|
||||||
|
<TextBlock Text="{Binding ChanceAtCurrent, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||||
|
<!--TextBlock Text="{Binding KCForFifty, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/-->
|
||||||
|
<!--TextBlock Text="{Binding KCForNinety, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/-->
|
||||||
|
<TextBox Text="{Binding ChanceCheck, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="3"/>
|
||||||
|
<TextBlock Text="{Binding KCForChanceCheck, UpdateSourceTrigger=PropertyChanged}" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
29
osrs-toolbox/Views/DropChanceView.xaml.cs
Normal file
29
osrs-toolbox/Views/DropChanceView.xaml.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace osrs_toolbox
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for DropChanceView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class DropChanceView : Window
|
||||||
|
{
|
||||||
|
public static DropChanceView Current;
|
||||||
|
public DropChanceView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Current = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,8 @@
|
|||||||
<Window.DataContext>
|
<Window.DataContext>
|
||||||
<local:HomePageViewModel/>
|
<local:HomePageViewModel/>
|
||||||
</Window.DataContext>
|
</Window.DataContext>
|
||||||
<Grid>
|
<StackPanel>
|
||||||
<Button Command="{Binding OpenCompetitionOverlaySettings, UpdateSourceTrigger=PropertyChanged}" Content="Open Competition Overlay Settings" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<Button Command="{Binding OpenCompetitionOverlaySettings, UpdateSourceTrigger=PropertyChanged}" Content="Open Competition Overlay Settings" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
</Grid>
|
<Button Command="{Binding OpenDropChanceCalculator, UpdateSourceTrigger=PropertyChanged}" Content="Open Drop Chance Calculator" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
Reference in New Issue
Block a user