Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
M1888
lottokone
Commits
a0d0345c
Commit
a0d0345c
authored
Apr 16, 2019
by
M1888
Browse files
1604
parent
29acc7dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Lottokone/Asetukset.xaml
View file @
a0d0345c
...
...
@@ -8,8 +8,8 @@
Title="Asetukset" Height="450" Width="800">
<Grid>
<StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Width="300"
x:Name="spSettings"
>
<StackPanel Orientation="Horizontal"
x:Name="spSettings"
>
<StackPanel Width="300">
<Label FontWeight="Bold">Simulaation asetukset</Label>
<StackPanel>
<StackPanel Margin="5" Orientation="Horizontal">
...
...
@@ -30,6 +30,11 @@
</StackPanel>
<StackPanel>
<Label FontWeight="Bold">Omat rivit</Label>
<StackPanel>
<StackPanel Orientation="Horizontal">
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
...
...
Lottokone/Asetukset.xaml.cs
View file @
a0d0345c
...
...
@@ -19,8 +19,6 @@ namespace Lottokone
/// </summary>
public
partial
class
Asetukset
:
Window
{
public
Asetukset
()
{
InitializeComponent
();
...
...
Lottokone/MainWindow.xaml
View file @
a0d0345c
...
...
@@ -20,7 +20,7 @@
<Label Content="Viikko:"/>
<Label Content="{Binding Viikko}" />
<Label Content="Pelaajia:"/>
<Label Content="{Binding Pelaaja
t.Count()
}"/>
<Label Content="{Binding Pelaaja
maara
}"/>
<Label Content="Potti:"/>
<Label Content="{Binding Potti}"/>
<Label Content="Voittorivi:"/>
...
...
Lottokone/Model/Lotto.cs
View file @
a0d0345c
...
...
@@ -105,6 +105,16 @@ namespace Lottokone.Model
}
}
// pelaajamäärä pitää pitää inttinä, niin saadaan helposti bindattua se
// käyttöliittymän puolella.
public
int
Pelaajamaara
{
get
{
return
Pelaajat
.
Count
();
}
}
// Konstruktori lottokoneen pääluokalle
public
Lotto
()
{
...
...
@@ -113,31 +123,17 @@ namespace Lottokone.Model
Pelaajat
=
new
ConcurrentBag
<
Pelaaja
>();
Voittorivi
=
new
Voittorivi
();
StatusHistory
=
new
ObservableCollectionEx
<
string
>(
new
List
<
String
>());
Status
=
"Alustetaan pelaajia..."
;
Status
=
"Veikkaus: Pelaa maltillisesti :):):):)"
;
for
(
int
i
=
0
;
i
<
Properties
.
Settings
.
Default
.
Pelaajia
;
i
++)
{
Pelaaja
p
=
new
Pelaaja
();
for
(
int
j
=
0
;
j
<
5
;
j
++)
{
Lottorivi
l
=
new
Lottorivi
();
l
.
ArvoRivi
();
p
.
Rivit
.
Add
(
l
);
Potti
++;
}
Pelaajat
.
Add
(
p
);
}
LisaaPelaajia
(
Properties
.
Settings
.
Default
.
Pelaajia
,
Properties
.
Settings
.
Default
.
Riveja
);
}
public
void
LisaaPelaajia
(
int
pelaajia
,
int
riveja
)
{
for
(
int
i
=
0
;
i
<
pelaajia
;
i
++)
{
for
(
int
j
=
0
;
j
<
riveja
;
j
++)
{
Pelaajat
.
Add
(
new
Pelaaja
());
}
Pelaajat
.
Add
(
new
Pelaaja
(
riveja
));
}
}
...
...
@@ -172,17 +168,18 @@ namespace Lottokone.Model
if
(!
Oikein7
.
IsEmpty
)
Status
=
$"7 oikein:
{
Oikein7
.
Count
()}
"
;
JaaVoitot
();
//
JaaVoitot();
}
private
void
EtsiVoittajat
()
{
Parallel
.
ForEach
(
Pelaajat
,
(
p
)
=>
{
foreach
(
Rivi
r
in
p
.
Rivit
)
// päivitetään lottorivit
p
.
Tick
();
foreach
(
Lottorivi
r
in
p
.
Rivit
)
{
int
oikein
=
r
.
Oikein
(
Voittorivi
);
switch
(
oikein
)
switch
(
r
.
Oikein
(
Voittorivi
))
{
case
4
:
Oikein4
.
Add
(
p
);
...
...
Lottokone/Model/Pelaaja.cs
View file @
a0d0345c
...
...
@@ -12,7 +12,7 @@ namespace Lottokone.Model
public
long
Saldo
{
get
;
set
;
}
public
List
<
Lottorivi
>
Rivit
{
get
;
set
;
}
public
shor
t
Riveja
{
get
;
set
;
}
public
in
t
Riveja
{
get
;
set
;
}
public
Pelaaja
()
{
...
...
@@ -25,21 +25,27 @@ namespace Lottokone.Model
Nimi
=
nimi
;
}
public
Pelaaja
(
shor
t
riveja
)
:
this
()
public
Pelaaja
(
in
t
riveja
)
:
this
()
{
Riveja
=
riveja
;
for
(
int
i
=
0
;
i
<
Riveja
;
i
++)
Rivit
.
Add
(
new
Lottorivi
());
}
public
void
Tick
()
{
for
each
(
Lottorivi
r
in
Rivit
)
for
(
int
i
=
Rivit
.
Count
()
-
1
;
i
>
0
;
i
--
)
{
Lottorivi
r
=
Rivit
[
i
];
r
.
Voimassa
--;
if
(
r
.
Voimassa
<
0
)
{
if
(
r
.
Voimassa
<
0
)
Rivit
.
Remove
(
r
);
}
}
int
ero
=
Riveja
-
Rivit
.
Count
();
if
(
ero
>
0
)
for
(
int
i
=
0
;
i
<
ero
;
i
++)
Rivit
.
Add
(
new
Lottorivi
());
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment