diff --git a/osrs-toolbox/Models/HomePageModel.cs b/osrs-toolbox/Models/HomePageModel.cs
index 5a038c5..d10170e 100644
--- a/osrs-toolbox/Models/HomePageModel.cs
+++ b/osrs-toolbox/Models/HomePageModel.cs
@@ -14,6 +14,7 @@ namespace osrs_toolbox
private ICommand _openCompetitionOverlaySettings;
private ICommand _openDropChanceCalculator;
private ICommand _openCombatLevelCalculator;
+ private ICommand _openShopBuyoutCalculator;
public ICommand OpenCompetitionOverlaySettings
{
@@ -32,5 +33,10 @@ namespace osrs_toolbox
get { return _openCombatLevelCalculator; }
set { SetProperty(ref _openCombatLevelCalculator, value, nameof(OpenCombatLevelCalculator)); }
}
+ public ICommand OpenShopBuyoutCalculator
+ {
+ get { return _openShopBuyoutCalculator; }
+ set { SetProperty(ref _openShopBuyoutCalculator, value, nameof(OpenShopBuyoutCalculator)); }
+ }
}
}
diff --git a/osrs-toolbox/Models/ShopBuyoutModel.cs b/osrs-toolbox/Models/ShopBuyoutModel.cs
new file mode 100644
index 0000000..3f54845
--- /dev/null
+++ b/osrs-toolbox/Models/ShopBuyoutModel.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace osrs_toolbox
+{
+ public abstract class ShopBuyoutModel : ModelBase
+ {
+ private int _quantityAvailable;
+ private int _baseValue;
+ private double _baseMultiplier;
+ private double _changePerUnit;
+
+ public int QuantityAvailable
+ {
+ get { return _quantityAvailable; }
+ set
+ {
+ SetProperty(ref _quantityAvailable, value, nameof(QuantityAvailable));
+ OnPropertyChanged(nameof(MaxMultiplier));
+ OnPropertyChanged(nameof(MaxPrice));
+ OnPropertyChanged(nameof(BuyoutPrice));
+ }
+ }
+ public int BaseValue
+ {
+ get { return _baseValue; }
+ set
+ {
+ SetProperty(ref _baseValue, value, nameof(BaseValue));
+ OnPropertyChanged(nameof(BasePrice));
+ OnPropertyChanged(nameof(MaxPrice));
+ OnPropertyChanged(nameof(BuyoutPrice));
+ }
+ }
+ public double BaseMultiplier
+ {
+ get { return _baseMultiplier; }
+ set
+ {
+ SetProperty(ref _baseMultiplier, value, nameof(BaseMultiplier));
+ OnPropertyChanged(nameof(BasePrice));
+ OnPropertyChanged(nameof(MaxMultiplier));
+ OnPropertyChanged(nameof(MaxPrice));
+ OnPropertyChanged(nameof(BuyoutPrice));
+ }
+ }
+ public double ChangePerUnit
+ {
+ get { return _changePerUnit; }
+ set
+ {
+ SetProperty(ref _changePerUnit, value, nameof(ChangePerUnit));
+ OnPropertyChanged(nameof(MaxMultiplier));
+ OnPropertyChanged(nameof(MaxPrice));
+ OnPropertyChanged(nameof(BuyoutPrice));
+ }
+ }
+
+ public double MaxMultiplier => (QuantityAvailable * ChangePerUnit) + BaseMultiplier;
+ public double BasePrice => Math.Round(BaseValue * BaseMultiplier, 0);
+ public double MaxPrice => Math.Round(BaseValue * MaxMultiplier, 0);
+ public double BuyoutPrice
+ {
+ get
+ {
+ double PriceSum = 0d;
+ for(int i = 0; i < QuantityAvailable; i++)
+ {
+ double CurrentMultiplier = ((ChangePerUnit * i) + BaseMultiplier);
+ PriceSum += Math.Round(BaseValue * Math.Min(CurrentMultiplier, MaxMultiplier));
+ }
+ return PriceSum;
+ }
+ }
+ }
+}
diff --git a/osrs-toolbox/ViewModels/HomePageViewModel.cs b/osrs-toolbox/ViewModels/HomePageViewModel.cs
index 1b55c12..bacebc9 100644
--- a/osrs-toolbox/ViewModels/HomePageViewModel.cs
+++ b/osrs-toolbox/ViewModels/HomePageViewModel.cs
@@ -25,6 +25,7 @@ namespace osrs_toolbox
OpenCompetitionOverlaySettings = new RelayCommand(DoOpenCompetitionOverlaySettings);
OpenDropChanceCalculator = new RelayCommand(DoOpenDropChanceCalculator);
OpenCombatLevelCalculator = new RelayCommand(DoOpenCombatLevelCalculator);
+ OpenShopBuyoutCalculator = new RelayCommand(DoOpenShopBuyoutCalculator);
}
private void DoOpenCompetitionOverlaySettings(object obj)
@@ -68,5 +69,19 @@ namespace osrs_toolbox
clv.Show();
}
}
+
+ private void DoOpenShopBuyoutCalculator(object obj)
+ {
+ if (ShopBuyoutView.Current != null)
+ {
+ ShopBuyoutView.Current.Close();
+ ShopBuyoutView.Current = null;
+ }
+ else
+ {
+ ShopBuyoutView sbv = new ShopBuyoutView();
+ sbv.Show();
+ }
+ }
}
}
diff --git a/osrs-toolbox/ViewModels/ShopBuyoutViewModel.cs b/osrs-toolbox/ViewModels/ShopBuyoutViewModel.cs
new file mode 100644
index 0000000..2dbd365
--- /dev/null
+++ b/osrs-toolbox/ViewModels/ShopBuyoutViewModel.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace osrs_toolbox
+{
+ public class ShopBuyoutViewModel : ShopBuyoutModel
+ {
+ public ShopBuyoutViewModel()
+ {
+ InitializeVariables();
+ InitializeCommands();
+ }
+
+ private void InitializeVariables()
+ {
+ QuantityAvailable = 1000;
+ BaseValue = 100;
+ BaseMultiplier = 11.5;
+ ChangePerUnit = 0.01;
+ }
+
+ private void InitializeCommands()
+ {
+
+ }
+ }
+}
diff --git a/osrs-toolbox/Views/HomePageView.xaml b/osrs-toolbox/Views/HomePageView.xaml
index a0f69e5..6e77196 100644
--- a/osrs-toolbox/Views/HomePageView.xaml
+++ b/osrs-toolbox/Views/HomePageView.xaml
@@ -9,9 +9,14 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/osrs-toolbox/Views/ShopBuyoutView.xaml b/osrs-toolbox/Views/ShopBuyoutView.xaml
new file mode 100644
index 0000000..17d5263
--- /dev/null
+++ b/osrs-toolbox/Views/ShopBuyoutView.xaml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/osrs-toolbox/Views/ShopBuyoutView.xaml.cs b/osrs-toolbox/Views/ShopBuyoutView.xaml.cs
new file mode 100644
index 0000000..98f0223
--- /dev/null
+++ b/osrs-toolbox/Views/ShopBuyoutView.xaml.cs
@@ -0,0 +1,34 @@
+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 ShopBuyoutView.xaml
+ ///
+ public partial class ShopBuyoutView : Window
+ {
+ public static ShopBuyoutView Current;
+ public ShopBuyoutView()
+ {
+ InitializeComponent();
+ Current = this;
+ }
+
+ private void Window_Closed(object sender, EventArgs e)
+ {
+ Current = null;
+ }
+ }
+}