From c10cb020acb80bcb5de752ab45b4c25100d77215 Mon Sep 17 00:00:00 2001 From: bionic85 <144353436+bionic85@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:36:23 +0100 Subject: [PATCH] Setup Fase is done --- PuzzlePlayer/BlackJack.cs | 93 +++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 23 deletions(-) diff --git a/PuzzlePlayer/BlackJack.cs b/PuzzlePlayer/BlackJack.cs index f9b850c..e31b77c 100644 --- a/PuzzlePlayer/BlackJack.cs +++ b/PuzzlePlayer/BlackJack.cs @@ -1,4 +1,5 @@ -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 visible - Panel SetupPanel; // visibility depends on game state + + // visibility depends on game state + 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(DefaultPanel.Width / 4, DefaultPanel.Height / 5); - b.Location = new Point(i * b.Size.Width, DefaultPanel.Height - b.Size.Height*j); + b.Size = new Size(SetupPanel.Width / 4, SetupPanel.Height / 6); // /2 + b.Location = new Point(i * b.Size.Width, SetupPanel.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; - DefaultPanel.Controls.Add(b); + SetupPanel.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) -- GitLab