From 8aa46c31768c60c90f0ddfa67e59ef0348cb1b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Thu, 14 Jul 2022 16:52:42 +0200 Subject: [PATCH] Logging added points --- WinGreed/frmPersonRound.cs | 7 +++++-- WinGreed/frmStart.Designer.cs | 28 ++++++++++++++++++++++++++-- WinGreed/frmStart.cs | 14 ++++++++++---- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/WinGreed/frmPersonRound.cs b/WinGreed/frmPersonRound.cs index 060422e..7f624c7 100644 --- a/WinGreed/frmPersonRound.cs +++ b/WinGreed/frmPersonRound.cs @@ -23,6 +23,8 @@ namespace WinGreed private HandleThrow _ht; public string Player { get; set; } public int TotPoints { get; set; } + public int AddedPoints { get; set; } + List Points = new List(); public frmPersonRound(string player) { @@ -193,6 +195,7 @@ namespace WinGreed actTxtBox.Refresh(); tempChsn += outPut.NumSum; txtChosenPoints.Text = tempChsn.ToString(); + AddedPoints = tempChsn; if (((TextBox)this.Controls.Find($"txtMaxValue{row}", true).FirstOrDefault()).Text == actTxtBox.Text && int.Parse(actTxtBox.Text.Trim()) > 0 && _ht.Dices.Count(x => x.Chosen == true) == _ht.Dices.Count) @@ -202,8 +205,8 @@ namespace WinGreed } } - numbers.ForEach(x => Debug.Write($"{x}, ")); - Debug.WriteLine(" -"); + //numbers.ForEach(x => Debug.Write($"{x}, ")); + //Debug.WriteLine(" -"); return result; } diff --git a/WinGreed/frmStart.Designer.cs b/WinGreed/frmStart.Designer.cs index cf3ffc2..045170d 100644 --- a/WinGreed/frmStart.Designer.cs +++ b/WinGreed/frmStart.Designer.cs @@ -38,6 +38,8 @@ this.txtNewName = new System.Windows.Forms.TextBox(); this.btnAddOk = new System.Windows.Forms.Button(); this.btnSound = new System.Windows.Forms.Button(); + this.lstLogBox = new System.Windows.Forms.ListBox(); + this.lblLog = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 @@ -72,7 +74,7 @@ this.lvMemberList.HoverSelection = true; this.lvMemberList.Location = new System.Drawing.Point(387, 97); this.lvMemberList.Name = "lvMemberList"; - this.lvMemberList.Size = new System.Drawing.Size(302, 166); + this.lvMemberList.Size = new System.Drawing.Size(302, 315); this.lvMemberList.TabIndex = 2; this.lvMemberList.UseCompatibleStateImageBehavior = false; this.lvMemberList.View = System.Windows.Forms.View.Details; @@ -134,11 +136,31 @@ this.btnSound.Visible = false; this.btnSound.Click += new System.EventHandler(this.btnSound_Click); // + // lstLogBox + // + this.lstLogBox.FormattingEnabled = true; + this.lstLogBox.ItemHeight = 15; + this.lstLogBox.Location = new System.Drawing.Point(707, 97); + this.lstLogBox.Name = "lstLogBox"; + this.lstLogBox.Size = new System.Drawing.Size(120, 319); + this.lstLogBox.TabIndex = 7; + // + // lblLog + // + this.lblLog.AutoSize = true; + this.lblLog.Location = new System.Drawing.Point(707, 66); + this.lblLog.Name = "lblLog"; + this.lblLog.Size = new System.Drawing.Size(68, 15); + this.lblLog.TabIndex = 8; + this.lblLog.Text = "PoängLogg"; + // // frmStart // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(897, 450); + this.Controls.Add(this.lblLog); + this.Controls.Add(this.lstLogBox); this.Controls.Add(this.btnSound); this.Controls.Add(this.btnAddOk); this.Controls.Add(this.txtNewName); @@ -166,5 +188,7 @@ private TextBox txtNewName; private Button btnAddOk; private Button btnSound; + private ListBox lstLogBox; + private Label lblLog; } } \ No newline at end of file diff --git a/WinGreed/frmStart.cs b/WinGreed/frmStart.cs index b347d40..4ecd29a 100644 --- a/WinGreed/frmStart.cs +++ b/WinGreed/frmStart.cs @@ -20,10 +20,16 @@ namespace WinGreed { var nextLvInstance = lvMemberList.Items[NextLvItem()]; var nextPlayerName = nextLvInstance.Text; - fPR = new frmPersonRound(nextPlayerName); - fPR.TotPoints = int.Parse(nextLvInstance.SubItems[2].Text); - fPR.ShowDialog(); - nextLvInstance.SubItems[2].Text = fPR.TotPoints.ToString(); + + if (!GameOver || (GameOver && nextLvInstance != gocFirst.lvsave)) + { + fPR = new frmPersonRound(nextPlayerName); + fPR.TotPoints = int.Parse(nextLvInstance.SubItems[2].Text); + fPR.ShowDialog(); + nextLvInstance.SubItems[2].Text = fPR.TotPoints.ToString(); + lstLogBox.Items.Add($"{nextPlayerName} -> {fPR.AddedPoints} poäng."); + } + if (GameOver) { if (nextLvInstance == gocFirst.lvsave)