Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
puzzleplayer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Floris
puzzleplayer
Commits
c10cb020
Commit
c10cb020
authored
3 months ago
by
bionic85
Browse files
Options
Downloads
Patches
Plain Diff
Setup Fase is done
parent
5879e4a9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PuzzlePlayer/BlackJack.cs
+70
-23
70 additions, 23 deletions
PuzzlePlayer/BlackJack.cs
with
70 additions
and
23 deletions
PuzzlePlayer/BlackJack.cs
+
70
−
23
View file @
c10cb020
using
System
;
using
Microsoft.VisualBasic.Devices
;
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
...
...
@@ -17,15 +18,15 @@ namespace PuzzlePlayer_Namespace
internal
class
BlackJack
:
Form
{
BJSTATE
state
;
int
money
=
1000
;
int
money
;
int
deploydMoney
=
0
;
const
string
DIR
=
@"..\..\..\Resources\BlackJack\"
;
FontFamily
BJFont
=
FontFamily
.
GenericSansSerif
;
Size
screen
=
Screen
.
PrimaryScreen
.
WorkingArea
.
Size
;
Panel
DefaultPanel
;
// always visibl
e
Panel
SetupPanel
;
// visibility depends on game state
// visibility depends on game stat
e
Panel
SetupPanel
;
Panel
GamePanel
;
Panel
ResultPanel
;
...
...
@@ -38,26 +39,37 @@ namespace PuzzlePlayer_Namespace
state
=
BJSTATE
.
Setup
;
WindowState
=
FormWindowState
.
Maximized
;
BackColor
=
Color
.
DarkGreen
;
Paint
+=
BlackJack_Paint
;
money
=
ReadMoney
();
SetupUI
();
}
private
int
ReadMoney
()
//TODO read money from local file
{
return
1000
;
}
private
void
SetupUI
()
{
//Default
DefaultPanel
=
new
Panel
();
DefaultPanel
.
Size
=
new
Size
(
screen
.
Width
/
2
,
screen
.
Height
);
DefaultPanel
.
Location
=
new
Point
(
screen
.
Width
/
4
,
0
);
//Setup
#
region
SetupPanel
SetupPanel
=
new
Panel
();
SetupPanel
.
Size
=
new
Size
(
screen
.
Width
/
2
,
screen
.
Height
);
// /4
SetupPanel
.
Location
=
new
Point
(
screen
.
Width
/
4
,
0
);
//DefaultPanel.BackColor = Color.Blue; //DEBUG
SetupPanel
.
Paint
+=
DefaultPaint
;
//money buttons
int
goofyIndex
=
0
;
//dw
for
(
int
j
=
1
;
j
<=
2
;
j
++)
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
Button
b
=
new
Button
();
b
.
Size
=
new
Size
(
Default
Panel
.
Width
/
4
,
Default
Panel
.
Height
/
5
);
b
.
Location
=
new
Point
(
i
*
b
.
Size
.
Width
,
Default
Panel
.
Height
-
b
.
Size
.
Height
*
j
);
b
.
Size
=
new
Size
(
Setup
Panel
.
Width
/
4
,
Setup
Panel
.
Height
/
6
);
// /2
b
.
Location
=
new
Point
(
i
*
b
.
Size
.
Width
,
Setup
Panel
.
Height
-
b
.
Size
.
Height
*
j
);
b
.
Name
=
goofyIndex
.
ToString
();
// for getting the index for chipInfo later
(
int
,
string
,
Color
)
chip
=
chipInfo
[
goofyIndex
];
...
...
@@ -67,30 +79,59 @@ namespace PuzzlePlayer_Namespace
b
.
Click
+=
moneyButtonClick
;
Default
Panel
.
Controls
.
Add
(
b
);
Setup
Panel
.
Controls
.
Add
(
b
);
goofyIndex
++;
}
Controls
.
Add
(
DefaultPanel
);
// Deal button
Button
dealButton
=
new
Button
();
dealButton
.
Text
=
"DEAL"
;
dealButton
.
Size
=
new
Size
(
SetupPanel
.
Width
/
4
,
SetupPanel
.
Height
/
6
);
dealButton
.
Location
=
new
Point
(
SetupPanel
.
Width
/
2
-
dealButton
.
Width
/
2
,
SetupPanel
.
Height
/
4
);
dealButton
.
Font
=
new
Font
(
BJFont
,
dealButton
.
Size
.
Width
/
5
);
dealButton
.
BackColor
=
Color
.
DodgerBlue
;
dealButton
.
Click
+=
(
object
o
,
EventArgs
e
)
=>
{
if
(
deploydMoney
==
0
)
return
;
SetupPanel
.
Hide
();
GamePanel
.
Show
();
state
=
BJSTATE
.
Game
;
};
SetupPanel
.
Controls
.
Add
(
dealButton
);
Controls
.
Add
(
SetupPanel
);
#
endregion
//Setup
SetupPanel
=
new
Panel
();
//Game
#
region
GamePanel
GamePanel
=
new
Panel
();
GamePanel
.
BackColor
=
Color
.
AliceBlue
;
//DEBUG
GamePanel
.
Hide
();
//Hide until the game state is reached
Controls
.
Add
(
GamePanel
);
#
endregion
//Result
#
region
ResultPanel
ResultPanel
=
new
Panel
();
ResultPanel
.
Hide
();
//Hide until the result state is reached
Controls
.
Add
(
ResultPanel
);
#
endregion
}
private
void
moneyButtonClick
(
object
sender
,
EventArgs
e
)
{
Button
b
=
(
Button
)
sender
;
(
int
,
string
,
Color
)
chip
=
chipInfo
[
int
.
Parse
(
b
.
Name
)];
if
(
money
>
chip
.
Item1
)
if
(
money
>
=
chip
.
Item1
)
{
//bababababa
deploydMoney
+=
chip
.
Item1
;
money
-=
chip
.
Item1
;
}
Invalidate
(
true
);
}
private
void
BlackJack_Paint
(
object
sender
,
PaintEventArgs
e
)
...
...
@@ -104,7 +145,7 @@ namespace PuzzlePlayer_Namespace
switch
(
state
)
// paint according to the current state
{
case
BJSTATE
.
Setup
:
Setup_Paint
(
g
);
//
Setup_Paint(g);
break
;
case
BJSTATE
.
Game
:
Game_Paint
(
g
);
...
...
@@ -114,10 +155,16 @@ namespace PuzzlePlayer_Namespace
break
;
}
}
private
void
Setup_Paint
(
Graphics
g
)
private
void
DefaultPaint
(
object
sender
,
PaintEventArgs
e
)
{
Graphics
g
=
e
.
Graphics
;
// draw deployd money
// Might update this to butiful chipss
string
s
=
"Deployd Money: "
+
deploydMoney
.
ToString
();
Font
deplMoneyFont
=
new
Font
(
BJFont
,
SetupPanel
.
Width
/
20
,
FontStyle
.
Bold
);
SizeF
pf
=
g
.
MeasureString
(
s
,
deplMoneyFont
);
PointF
p
=
new
PointF
(
SetupPanel
.
Width
/
2
-
pf
.
Width
/
2
,
SetupPanel
.
Height
/
2
);
g
.
DrawString
(
s
,
deplMoneyFont
,
Brushes
.
Black
,
p
);
}
private
void
Game_Paint
(
Graphics
g
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment