Commit 794e6fb4 authored by M1888's avatar M1888

iltakoodailut

parent 9e03ca56
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Lottokone.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Lottokone.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<startup> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> </configSections>
</startup> <startup>
<userSettings> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<Lottokone.Properties.Settings> </startup>
<setting name="Pelaajia" serializeAs="String"> <userSettings>
<value>100000</value> <Lottokone.Properties.Settings>
</setting> <setting name="Pelaajia" serializeAs="String">
<setting name="Riveja" serializeAs="String"> <value>100000</value>
<value>3</value> </setting>
</setting> <setting name="Riveja" serializeAs="String">
<setting name="Voimassa" serializeAs="String"> <value>3</value>
<value>6</value> </setting>
</setting> <setting name="Voimassa" serializeAs="String">
<setting name="Nimi" serializeAs="String"> <value>6</value>
<value>Veikkaaja</value> </setting>
</setting> <setting name="Nimi" serializeAs="String">
<setting name="Arparivit" serializeAs="String"> <value>Veikkaaja</value>
<value>10</value> </setting>
</setting> <setting name="Arparivit" serializeAs="String">
<setting name="ArparivitVoimassa" serializeAs="String"> <value>10</value>
<value>6</value> </setting>
</setting> <setting name="ArparivitVoimassa" serializeAs="String">
<setting name="Rivihinta" serializeAs="String"> <value>6</value>
<value>1</value> </setting>
</setting> <setting name="Rivihinta" serializeAs="String">
<setting name="Vakiorivit" serializeAs="String"> <value>1</value>
<value>0</value> </setting>
</setting> <setting name="Vakiorivit" serializeAs="String">
</Lottokone.Properties.Settings> <value>0</value>
</userSettings> </setting>
</Lottokone.Properties.Settings>
</userSettings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration> </configuration>
\ No newline at end of file
...@@ -26,5 +26,11 @@ ...@@ -26,5 +26,11 @@
<Setter Property="FontSize" Value="16" /> <Setter Property="FontSize" Value="16" />
</Style> </Style>
<Style TargetType="TextBox" x:Key="Lottonumero">
<Setter Property="Width" Value="50" />
<Setter Property="MinWidth" Value="20"/>
<Setter Property="Margin" Value="3" />
</Style>
</Application.Resources> </Application.Resources>
</Application> </Application>
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
<TextBox Style="{StaticResource Asetusboksi}" x:Name="txbVakiorivit" Text="{Binding Vakiorivit, Mode=TwoWay}" /> <TextBox Style="{StaticResource Asetusboksi}" x:Name="txbVakiorivit" Text="{Binding Vakiorivit, Mode=TwoWay}" />
</DockPanel> </DockPanel>
<TextBlock Margin="25,-5,0,0">Montako vakioriviä haluat pelata?</TextBlock> <TextBlock Margin="25,-5,0,0">Montako vakioriviä haluat pelata?</TextBlock>
<Button Content="Aseta rivit" Width="100" x:Name="btnRivit" Click="BtnRivit_Click" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
......
...@@ -11,6 +11,7 @@ using System.Windows.Input; ...@@ -11,6 +11,7 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using Lottokone.Model;
namespace Lottokone namespace Lottokone
{ {
...@@ -33,7 +34,8 @@ namespace Lottokone ...@@ -33,7 +34,8 @@ namespace Lottokone
private void BtnRivit_Click(object sender, RoutedEventArgs e) private void BtnRivit_Click(object sender, RoutedEventArgs e)
{ {
var ikkuna = new Lottorivit();
ikkuna.ShowDialog();
} }
} }
} }
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
...@@ -34,11 +36,27 @@ ...@@ -34,11 +36,27 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="MedallionRandom, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MedallionRandom, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\MedallionRandom.1.1.0\lib\net452\MedallionRandom.dll</HintPath> <HintPath>packages\MedallionRandom.1.1.0\lib\net452\MedallionRandom.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\System.Data.SQLite.Core.1.0.110.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\System.Data.SQLite.EF6.1.0.110.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\System.Data.SQLite.Linq.1.0.110.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
...@@ -57,11 +75,21 @@ ...@@ -57,11 +75,21 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Lottorivit.xaml.cs">
<DependentUpon>Lottorivit.xaml</DependentUpon>
</Compile>
<Compile Include="Settings.cs" /> <Compile Include="Settings.cs" />
<Compile Include="Voitto.xaml.cs">
<DependentUpon>Voitto.xaml</DependentUpon>
</Compile>
<Page Include="Asetukset.xaml"> <Page Include="Asetukset.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Lottorivit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
...@@ -77,6 +105,10 @@ ...@@ -77,6 +105,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="Voitto.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Model\Lotto.cs" /> <Compile Include="Model\Lotto.cs" />
...@@ -113,5 +145,15 @@ ...@@ -113,5 +145,15 @@
<ItemGroup> <ItemGroup>
<Resource Include="Resources\lotto.png" /> <Resource Include="Resources\lotto.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Resources\lottovoittaja.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets'))" />
</Target>
</Project> </Project>
\ No newline at end of file
...@@ -5,8 +5,13 @@ ...@@ -5,8 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lottokone" xmlns:local="clr-namespace:Lottokone"
mc:Ignorable="d" mc:Ignorable="d"
Title="Lottorivit" Height="450" Width="800"> Title="Lottorivit" Height="450" Width="400">
<Grid> <Grid x:Name="grdRivit">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
</Grid> </Grid>
</Window> </Window>
...@@ -19,6 +19,10 @@ namespace Lottokone ...@@ -19,6 +19,10 @@ namespace Lottokone
/// </summary> /// </summary>
public partial class Lottorivit : Window public partial class Lottorivit : Window
{ {
private Button btnSave;
private Label lblInfo;
public Lottorivit() public Lottorivit()
{ {
InitializeComponent(); InitializeComponent();
...@@ -27,43 +31,82 @@ namespace Lottokone ...@@ -27,43 +31,82 @@ namespace Lottokone
public void NaytaKontrollit() public void NaytaKontrollit()
{ {
/*
StackPanel rivit = new StackPanel(); StackPanel rivit = new StackPanel();
for (int i = 0; i < Properties.Settings.Default.Vakiorivit; i++) for (int i = 0; i < Properties.Settings.Default.Vakiorivit; i++)
{ {
StackPanel rivi = new StackPanel(); StackPanel rivi = new StackPanel();
rivi.Orientation = Orientation.Horizontal; rivi.Orientation = Orientation.Horizontal;
rivi.Name = "spRivi{i}"; rivi.Name = $"spRivi{i}";
Grid.SetRow(rivi, i);
Label l = new Label();
l.Content = $"Rivi {i}: ";
rivi.Children.Add(l);
for (int j = 0; j < 7; j++) for (int j = 0; j < 7; j++)
{ {
TextBox tb = new TextBox(); TextBox tb = new TextBox();
tb.Style = Resources["Lottonumero"] as Style; tb.Style = Resources["Lottonumero"] as Style;
tb.TextChanged += txbChanged; tb.TextChanged += txbChanged;
Grid.SetColumn(tb, j);
rivi.Children.Add(tb); rivi.Children.Add(tb);
} }
rivit.Children.Add(rivi); rivit.Children.Add(rivi);
} }
grdRivit.Children.Add(rivit); grdRivit.Children.Add(rivit);
StackPanel spAlarivi = new StackPanel();
Grid.SetRow(spAlarivi, Properties.Settings.Default.Vakiorivit);
btnSave = new Button();
btnSave.Content = "Tallenna";
btnSave.Click += btnSave_Click;
spAlarivi.Children.Add(btnSave);
lblInfo = new Label();
lblInfo.Style = Resources["Isompi"] as Style;
spAlarivi.Children.Add(lblInfo);
grdRivit.Children.Add(spAlarivi);*/
}
public void btnSave_Click(object sender, RoutedEventArgs e)
{
} }
public void txbChanged(object sender, TextChangedEventArgs e) public void txbChanged(object sender, TextChangedEventArgs e)
{ {
TextBox tb = sender as TextBox; TextBox tb = sender as TextBox;
if(tb != null) if (tb != null)
{ {
if(int.TryParse(tb.Text, out int result)) bool ok = true;
if (int.TryParse(tb.Text, out int result))
{ {
if(result < 1) if (result < 1)
{ {
tb.Text = "1"; ok = false;
} }
else if (result > 40) else if (result > 40)
{ {
tb.Text = "40"; ok = false;
} }
} }
else else
{ {
MessageBox.Show("Syötä vain numeroita 1-40"); ok = false;
}
if (ok)
{
lblInfo.Content = "";
btnSave.IsEnabled = true;
}
else
{
lblInfo.Content = "Syötä vain numeroita 1-40";
btnSave.IsEnabled = false;
} }
} }
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<Window.Background> <Window.Background>
<ImageBrush ImageSource="Resources/lotto.png" /> <ImageBrush ImageSource="Resources/lotto.png" />
</Window.Background> </Window.Background>
<Grid>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<StackPanel Margin="0,10,0,0"> <StackPanel Margin="0,10,0,0">
<Button x:Name="btnNext" Margin="0,5,0,0" Content="Seuraava viikko" Click="btnNext_Click"/> <Button x:Name="btnNext" Margin="0,5,0,0" Content="Seuraava viikko" Click="btnNext_Click"/>
...@@ -17,11 +16,12 @@ ...@@ -17,11 +16,12 @@
<Button x:Name="btnStop" Margin="0,5,0,0" Content="Pysäytä" Click="btnStop_Click"/> <Button x:Name="btnStop" Margin="0,5,0,0" Content="Pysäytä" Click="btnStop_Click"/>
<Button x:Name="btnSettings" Margin="0,50,0,0" Content="Asetukset" Click="btnSettings_Click" /> <Button x:Name="btnSettings" Margin="0,50,0,0" Content="Asetukset" Click="btnSettings_Click" />
</StackPanel> </StackPanel>
<StackPanel x:Name="spLotto" Width="250"> <StackPanel x:Name="spLotto" Width="250" Background="White" Opacity="0.6" VerticalAlignment="Top">
<Label Style="{StaticResource Isompi}" Content="{Binding Vuosi}" ContentStringFormat="Vuosi: {0}"/> <Label Style="{StaticResource Isompi}" Content="{Binding Vuosi}" ContentStringFormat="Vuosi: {0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Viikko}" ContentStringFormat="Viikko: {0}"/> <Label Style="{StaticResource Isompi}" Content="{Binding Viikko}" ContentStringFormat="Viikko: {0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Rivimaara}" ContentStringFormat="Rivejä: {0:N0}"/> <Label Style="{StaticResource Isompi}" Content="{Binding Rivimaara}" ContentStringFormat="Rivejä: {0:N0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Potti}" ContentStringFormat="Potti: {0:C0}"/> <Label Style="{StaticResource Isompi}" Content="{Binding Potti}" ContentStringFormat="Potti: {0:C0}"/>
<Label Style="{StaticResource Isompi}" Content="{Binding Paavoitto}" ContentStringFormat="Päävoitto: {0:C0}"/>
<Label Style="{StaticResource Isompi}">Voittorivi:</Label> <Label Style="{StaticResource Isompi}">Voittorivi:</Label>
<Label Style="{StaticResource Isompi}" Content="{Binding Voittorivi}" /> <Label Style="{StaticResource Isompi}" Content="{Binding Voittorivi}" />
</StackPanel> </StackPanel>
...@@ -29,14 +29,17 @@ ...@@ -29,14 +29,17 @@
<Label Style="{StaticResource Isompi}" Content="Status:"/> <Label Style="{StaticResource Isompi}" Content="Status:"/>
<ListView Height="350" Width="300" x:Name="lstStatus" ItemsSource="{Binding Value, UpdateSourceTrigger=PropertyChanged}" Opacity="0.7"/> <ListView Height="350" Width="300" x:Name="lstStatus" ItemsSource="{Binding Value, UpdateSourceTrigger=PropertyChanged}" Opacity="0.7"/>
</StackPanel> </StackPanel>
<StackPanel x:Name="spPlayer" Width="300" Margin="5,0,0,0"> <StackPanel>
<Label Style="{StaticResource Isompi}" Content="{Binding Nimi}" ContentStringFormat="Nimi: {0}" /> <StackPanel x:Name="spPlayer" Width="300" Margin="5,0,0,0" Background="White" Opacity="0.8">
<Label Style="{StaticResource Isompi}" Content="{Binding Saldo}" ContentStringFormat="Tilin saldo: {0:C0}" /> <Label Style="{StaticResource Isompi}" Content="{Binding Nimi}" ContentStringFormat="Nimi: {0}" />
<Label Style="{StaticResource Isompi}" Content="{Binding Riveja}" ContentStringFormat="Rivejä: {0:N0}" /> <Label Style="{StaticResource Isompi}" Content="{Binding Saldo}" ContentStringFormat="Tilin saldo: {0:C0}" />
<Label Style="{StaticResource Isompi}" Content="Omat voitot:" Margin="0,100,0,0"/> <Label Style="{StaticResource Isompi}" Content="{Binding Riveja}" ContentStringFormat="Rivejä: {0:N0}" />
<ListView x:Name="lstVoitot" Height="180" Width="300" Opacity="0.7"> </StackPanel>
</ListView> <StackPanel Width="300">
<Label Style="{StaticResource Isompi}" Content="Omat voitot:" Margin="0,100,0,0"/>
<ListView x:Name="lstVoitot" Height="180" Width="300" Opacity="0.7">
</ListView>
</StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid>
</Window> </Window>
...@@ -83,9 +83,9 @@ namespace Lottokone ...@@ -83,9 +83,9 @@ namespace Lottokone
default: default:
break; break;
} }
if(s.Length > 0) if (s.Length > 0)
{ {
lock(voittolukko) lock (voittolukko)
{ {
voitot.Insert(0, s); voitot.Insert(0, s);
} }
...@@ -174,7 +174,8 @@ namespace Lottokone ...@@ -174,7 +174,8 @@ namespace Lottokone
private void btnSettings_Click(object sender, RoutedEventArgs e) private void btnSettings_Click(object sender, RoutedEventArgs e)
{ {
new Asetukset().ShowDialog(); var a = new Asetukset();
a.ShowDialog();
} }
} }
} }
...@@ -36,16 +36,6 @@ namespace Lottokone.Model ...@@ -36,16 +36,6 @@ namespace Lottokone.Model
private ConcurrentBag<Pelaaja> oikein6_1; private ConcurrentBag<Pelaaja> oikein6_1;
private ConcurrentBag<Pelaaja> oikein7; private ConcurrentBag<Pelaaja> oikein7;
// Lista kaikista kierroksen voittajista. Tämä voidaan käydä läpi lottokoneen
// ulkopuolella, ja tarkistaa onko meidän pelaaja listalla.
public IEnumerable<Pelaaja> Voittajat
{
get
{
return oikein5.Concat(oikein6).Concat(oikein6_1).Concat(oikein7);
}
}
private short viikko; private short viikko;
public short Viikko public short Viikko
{ {
...@@ -89,6 +79,20 @@ namespace Lottokone.Model ...@@ -89,6 +79,20 @@ namespace Lottokone.Model
public ConcurrentBag<Pelaaja> Pelaajat { get; set; } public ConcurrentBag<Pelaaja> Pelaajat { get; set; }
private int paavoitto;
public int Paavoitto
{
get
{
return paavoitto;
}
set
{
paavoitto = value;
RaisePropertyChanged();
}
}
private int potti; private int potti;
public int Potti public int Potti
{ {
...@@ -165,6 +169,7 @@ namespace Lottokone.Model ...@@ -165,6 +169,7 @@ namespace Lottokone.Model
public Lotto() public Lotto()
{ {
Potti = 0; Potti = 0;
Paavoitto = 1_250_000;
Viikko = 0; Viikko = 0;
Vuosi = 1; Vuosi = 1;
Pelaajat = new ConcurrentBag<Pelaaja>(); Pelaajat = new ConcurrentBag<Pelaaja>();
...@@ -330,16 +335,20 @@ namespace Lottokone.Model ...@@ -330,16 +335,20 @@ namespace Lottokone.Model
if (!oikein7.IsEmpty) if (!oikein7.IsEmpty)
{ {
int voittajia = oikein7.Count(); int voittajia = oikein7.Count();
int voitto = (int)((potti / 100) * 60) / voittajia; int voitto = (int)(paavoitto / voittajia);
Paavoitto = 1_250_000;
Status = $"!!! 7 oikein !!!! {voitto:C0} ({voittajia:N0} kpl) !!!"; Status = $"!!! 7 oikein !!!! {voitto:C0} ({voittajia:N0} kpl) !!!";
while (oikein7.TryTake(out Pelaaja p) != false) while (oikein7.TryTake(out Pelaaja p) != false)
{ {
p.Saldo += voitto; p.Saldo += voitto;
Potti -= voitto;
} }
} }
else
{
Paavoitto = (int)(Paavoitto * 1.1);
}
} }
protected void RaisePropertyChanged([CallerMemberName] string propertyName = null) protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
......
...@@ -5,8 +5,11 @@ ...@@ -5,8 +5,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Lottokone" xmlns:local="clr-namespace:Lottokone"
mc:Ignorable="d" mc:Ignorable="d"
Title="Voitto" Height="450" Width="800"> Title="Voittajan on helppo hymyillä" Height="600" Width="400">
<Window.Background>
<ImageBrush ImageSource="Resources/lottovoittaja.png"/>
</Window.Background>
<Grid> <Grid>
</Grid> </Grid>
</Window> </Window>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="MedallionRandom" version="1.1.0" targetFramework="net461" /> <package id="MedallionRandom" version="1.1.0" targetFramework="net461" />
<package id="System.Data.SQLite" version="1.0.110.0" targetFramework="net461" />
<package id="System.Data.SQLite.Core" version="1.0.110.0" targetFramework="net461" />
<package id="System.Data.SQLite.EF6" version="1.0.110.0" targetFramework="net461" />
<package id="System.Data.SQLite.Linq" version="1.0.110.0" targetFramework="net461" />
</packages> </packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment