diff --git a/osrs-toolbox/Models/DropChanceModel.cs b/osrs-toolbox/Models/DropChanceModel.cs
new file mode 100644
index 0000000..6cf9894
--- /dev/null
+++ b/osrs-toolbox/Models/DropChanceModel.cs
@@ -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);
+ }
+ }
+ }
+}
diff --git a/osrs-toolbox/Models/HomePageModel.cs b/osrs-toolbox/Models/HomePageModel.cs
index d9437f5..da167d0 100644
--- a/osrs-toolbox/Models/HomePageModel.cs
+++ b/osrs-toolbox/Models/HomePageModel.cs
@@ -12,11 +12,18 @@ namespace osrs_toolbox
public abstract class HomePageModel : ModelBase
{
private ICommand _openCompetitionOverlaySettings;
+ private ICommand _openDropChanceCalculator;
public ICommand OpenCompetitionOverlaySettings
{
get { return _openCompetitionOverlaySettings; }
set { SetProperty(ref _openCompetitionOverlaySettings, value, nameof(OpenCompetitionOverlaySettings)); }
}
+
+ public ICommand OpenDropChanceCalculator
+ {
+ get { return _openDropChanceCalculator; }
+ set { SetProperty(ref _openDropChanceCalculator, value, nameof(OpenDropChanceCalculator)); }
+ }
}
}
diff --git a/osrs-toolbox/ViewModels/DropChanceViewModel.cs b/osrs-toolbox/ViewModels/DropChanceViewModel.cs
new file mode 100644
index 0000000..8c58953
--- /dev/null
+++ b/osrs-toolbox/ViewModels/DropChanceViewModel.cs
@@ -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()
+ {
+
+ }
+ }
+}
diff --git a/osrs-toolbox/ViewModels/HomePageViewModel.cs b/osrs-toolbox/ViewModels/HomePageViewModel.cs
index 02cce14..bf6d503 100644
--- a/osrs-toolbox/ViewModels/HomePageViewModel.cs
+++ b/osrs-toolbox/ViewModels/HomePageViewModel.cs
@@ -23,6 +23,7 @@ namespace osrs_toolbox
private void InitializeCommands()
{
OpenCompetitionOverlaySettings = new RelayCommand(DoOpenCompetitionOverlaySettings);
+ OpenDropChanceCalculator = new RelayCommand(DoOpenDropChanceCalculator);
}
private void DoOpenCompetitionOverlaySettings(object obj)
@@ -38,5 +39,19 @@ namespace osrs_toolbox
cosv.Show();
}
}
+
+ private void DoOpenDropChanceCalculator(object obj)
+ {
+ if (DropChanceView.Current != null)
+ {
+ DropChanceView.Current.Close();
+ DropChanceView.Current = null;
+ }
+ else
+ {
+ DropChanceView dcv = new DropChanceView();
+ dcv.Show();
+ }
+ }
}
}
diff --git a/osrs-toolbox/Views/DropChanceView.xaml b/osrs-toolbox/Views/DropChanceView.xaml
new file mode 100644
index 0000000..85510bb
--- /dev/null
+++ b/osrs-toolbox/Views/DropChanceView.xaml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/osrs-toolbox/Views/DropChanceView.xaml.cs b/osrs-toolbox/Views/DropChanceView.xaml.cs
new file mode 100644
index 0000000..1559ef0
--- /dev/null
+++ b/osrs-toolbox/Views/DropChanceView.xaml.cs
@@ -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
+{
+ ///
+ /// Interaction logic for DropChanceView.xaml
+ ///
+ public partial class DropChanceView : Window
+ {
+ public static DropChanceView Current;
+ public DropChanceView()
+ {
+ InitializeComponent();
+ Current = this;
+ }
+ }
+}
diff --git a/osrs-toolbox/Views/HomePageView.xaml b/osrs-toolbox/Views/HomePageView.xaml
index edf7aaf..d1f04b8 100644
--- a/osrs-toolbox/Views/HomePageView.xaml
+++ b/osrs-toolbox/Views/HomePageView.xaml
@@ -9,7 +9,8 @@
-
+
-
+
+