Added shop buyout calculator.
This commit is contained in:
@@ -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)); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
79
osrs-toolbox/Models/ShopBuyoutModel.cs
Normal file
79
osrs-toolbox/Models/ShopBuyoutModel.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
osrs-toolbox/ViewModels/ShopBuyoutViewModel.cs
Normal file
30
osrs-toolbox/ViewModels/ShopBuyoutViewModel.cs
Normal file
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,9 +9,14 @@
|
||||
<Window.DataContext>
|
||||
<local:HomePageViewModel/>
|
||||
</Window.DataContext>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Command="{Binding OpenCompetitionOverlaySettings, UpdateSourceTrigger=PropertyChanged}" Content="Open Competition Overlay Settings" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Button Command="{Binding OpenDropChanceCalculator, UpdateSourceTrigger=PropertyChanged}" Content="Open Drop Chance Calculator" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Button Command="{Binding OpenCombatLevelCalculator, UpdateSourceTrigger=PropertyChanged}" Content="Open Combat Level Calculator" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Command="{Binding OpenCompetitionOverlaySettings, UpdateSourceTrigger=PropertyChanged}" Content="Open Competition Overlay Settings" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Button Command="{Binding OpenDropChanceCalculator, UpdateSourceTrigger=PropertyChanged}" Content="Open Drop Chance Calculator" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Command="{Binding OpenCombatLevelCalculator, UpdateSourceTrigger=PropertyChanged}" Content="Open Combat Level Calculator" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Button Command="{Binding OpenShopBuyoutCalculator, UpdateSourceTrigger=PropertyChanged}" Content="Open Shop Buyout Calculator" Margin="3" Padding="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
42
osrs-toolbox/Views/ShopBuyoutView.xaml
Normal file
42
osrs-toolbox/Views/ShopBuyoutView.xaml
Normal file
@@ -0,0 +1,42 @@
|
||||
<Window x:Class="osrs_toolbox.ShopBuyoutView"
|
||||
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="Shop Buyout Calculator" Height="450" Width="800" Closed="Window_Closed" SizeToContent="WidthAndHeight">
|
||||
<Window.DataContext>
|
||||
<local:ShopBuyoutViewModel/>
|
||||
</Window.DataContext>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Quantity Available:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="Base Value:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="Base Multiplier:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="Change Per Unit:" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBox Text="{Binding QuantityAvailable, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="3"/>
|
||||
<TextBox Text="{Binding BaseValue, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="3"/>
|
||||
<TextBox Text="{Binding BaseMultiplier, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="3"/>
|
||||
<TextBox Text="{Binding ChangePerUnit, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="3"/>
|
||||
<TextBlock Text="Base Price:" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="Max Multiplier:" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="Max Price:" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="Buyout Price:" Grid.Row="3" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="{Binding BasePrice, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="{Binding MaxMultiplier, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="{Binding MaxPrice, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
<TextBlock Text="{Binding BuyoutPrice, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3"/>
|
||||
</Grid>
|
||||
</Window>
|
34
osrs-toolbox/Views/ShopBuyoutView.xaml.cs
Normal file
34
osrs-toolbox/Views/ShopBuyoutView.xaml.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ShopBuyoutView.xaml
|
||||
/// </summary>
|
||||
public partial class ShopBuyoutView : Window
|
||||
{
|
||||
public static ShopBuyoutView Current;
|
||||
public ShopBuyoutView()
|
||||
{
|
||||
InitializeComponent();
|
||||
Current = this;
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
Current = null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user