Added temporary sum

This commit is contained in:
2022-07-12 23:50:51 +02:00
parent 125b669d93
commit 49a8dec39e
4 changed files with 81 additions and 23 deletions

14
WinGreed/ResultSum.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinGreed
{
public class ResultSum
{
public int NumSum { get; set; }
public string StrSum { get; set; }
}
}

View File

@ -45,6 +45,9 @@
this.txtTotalPoints = new System.Windows.Forms.TextBox(); this.txtTotalPoints = new System.Windows.Forms.TextBox();
this.lblRecentPoints = new System.Windows.Forms.Label(); this.lblRecentPoints = new System.Windows.Forms.Label();
this.btnCollect = new System.Windows.Forms.Button(); this.btnCollect = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.txtMaxPoints = new System.Windows.Forms.TextBox();
this.txtChosenPoints = new System.Windows.Forms.TextBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
@ -59,7 +62,7 @@
// //
// btnThrow // btnThrow
// //
this.btnThrow.Location = new System.Drawing.Point(32, 71); this.btnThrow.Location = new System.Drawing.Point(32, 81);
this.btnThrow.Name = "btnThrow"; this.btnThrow.Name = "btnThrow";
this.btnThrow.Size = new System.Drawing.Size(96, 23); this.btnThrow.Size = new System.Drawing.Size(96, 23);
this.btnThrow.TabIndex = 1; this.btnThrow.TabIndex = 1;
@ -181,7 +184,7 @@
// //
// txtTotalPoints // txtTotalPoints
// //
this.txtTotalPoints.Location = new System.Drawing.Point(350, 73); this.txtTotalPoints.Location = new System.Drawing.Point(350, 51);
this.txtTotalPoints.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.txtTotalPoints.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtTotalPoints.Name = "txtTotalPoints"; this.txtTotalPoints.Name = "txtTotalPoints";
this.txtTotalPoints.Size = new System.Drawing.Size(110, 23); this.txtTotalPoints.Size = new System.Drawing.Size(110, 23);
@ -191,7 +194,7 @@
// //
this.lblRecentPoints.AutoSize = true; this.lblRecentPoints.AutoSize = true;
this.lblRecentPoints.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.lblRecentPoints.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.lblRecentPoints.Location = new System.Drawing.Point(172, 70); this.lblRecentPoints.Location = new System.Drawing.Point(172, 48);
this.lblRecentPoints.Name = "lblRecentPoints"; this.lblRecentPoints.Name = "lblRecentPoints";
this.lblRecentPoints.Size = new System.Drawing.Size(158, 21); this.lblRecentPoints.Size = new System.Drawing.Size(158, 21);
this.lblRecentPoints.TabIndex = 12; this.lblRecentPoints.TabIndex = 12;
@ -199,7 +202,7 @@
// //
// btnCollect // btnCollect
// //
this.btnCollect.Location = new System.Drawing.Point(495, 71); this.btnCollect.Location = new System.Drawing.Point(495, 49);
this.btnCollect.Name = "btnCollect"; this.btnCollect.Name = "btnCollect";
this.btnCollect.Size = new System.Drawing.Size(75, 23); this.btnCollect.Size = new System.Drawing.Size(75, 23);
this.btnCollect.TabIndex = 13; this.btnCollect.TabIndex = 13;
@ -207,11 +210,40 @@
this.btnCollect.UseVisualStyleBackColor = true; this.btnCollect.UseVisualStyleBackColor = true;
this.btnCollect.Click += new System.EventHandler(this.btnCollect_Click); this.btnCollect.Click += new System.EventHandler(this.btnCollect_Click);
// //
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label2.Location = new System.Drawing.Point(172, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(148, 21);
this.label2.TabIndex = 14;
this.label2.Text = "Maxpoints / Chosen";
//
// txtMaxPoints
//
this.txtMaxPoints.Location = new System.Drawing.Point(359, 82);
this.txtMaxPoints.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtMaxPoints.Name = "txtMaxPoints";
this.txtMaxPoints.Size = new System.Drawing.Size(48, 23);
this.txtMaxPoints.TabIndex = 15;
//
// txtChosenPoints
//
this.txtChosenPoints.Location = new System.Drawing.Point(413, 82);
this.txtChosenPoints.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtChosenPoints.Name = "txtChosenPoints";
this.txtChosenPoints.Size = new System.Drawing.Size(48, 23);
this.txtChosenPoints.TabIndex = 16;
//
// frmPersonRound // frmPersonRound
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 618); this.ClientSize = new System.Drawing.Size(800, 618);
this.Controls.Add(this.txtChosenPoints);
this.Controls.Add(this.txtMaxPoints);
this.Controls.Add(this.label2);
this.Controls.Add(this.btnCollect); this.Controls.Add(this.btnCollect);
this.Controls.Add(this.lblRecentPoints); this.Controls.Add(this.lblRecentPoints);
this.Controls.Add(this.txtTotalPoints); this.Controls.Add(this.txtTotalPoints);
@ -252,5 +284,8 @@
private Label lblRecentPoints; private Label lblRecentPoints;
private Button btnCollect; private Button btnCollect;
private ImageList imageList1; private ImageList imageList1;
private Label label2;
private TextBox txtMaxPoints;
private TextBox txtChosenPoints;
} }
} }

View File

@ -16,6 +16,8 @@ namespace WinGreed
int y = 79; int y = 79;
int x = 0; int x = 0;
int row = 0; int row = 0;
int tempMax = 0;
int tempChsn = 0;
bool maxHeatPoints = false; bool maxHeatPoints = false;
private List<Button> _dice = new List<Button>(); private List<Button> _dice = new List<Button>();
private HandleThrow _ht; private HandleThrow _ht;
@ -168,23 +170,29 @@ namespace WinGreed
this.Controls.Add(txtRes); this.Controls.Add(txtRes);
this.Refresh(); this.Refresh();
string outPut = CheckForDifferentOutCome(numbers); var outPut = CheckForDifferentOutCome(numbers);
var actTxtBox = ((TextBox)this.Controls.Find($"txtMaxValue{row}", true).FirstOrDefault()); var actTxtBox = ((TextBox)this.Controls.Find($"txtMaxValue{row}", true).FirstOrDefault());
actTxtBox.Text = outPut; actTxtBox.Text = outPut.StrSum;
actTxtBox.Refresh(); actTxtBox.Refresh();
if (numbers.Count > 0 && int.Parse(outPut.Trim()) == 0) tempMax += outPut.NumSum;
txtMaxPoints.Text = tempMax.ToString();
if (numbers.Count > 0 && int.Parse(outPut.StrSum.Trim()) == 0)
{ {
btnThrow.Enabled = false; btnThrow.Enabled = false;
btnCollect.Enabled = false; btnCollect.Enabled = false;
MarkGrayAndDisable(row); MarkGrayAndDisable(row);
txtMaxPoints.Text = "0";
txtChosenPoints.Text = "0";
} }
} }
else else
{ {
string outPut = CheckForDifferentOutCome(numbers); var outPut = CheckForDifferentOutCome(numbers);
var actTxtBox = ((TextBox)this.Controls.Find($"txtChosenValue{row}", true).FirstOrDefault()); var actTxtBox = ((TextBox)this.Controls.Find($"txtChosenValue{row}", true).FirstOrDefault());
actTxtBox.Text = outPut; actTxtBox.Text = outPut.StrSum;
actTxtBox.Refresh(); actTxtBox.Refresh();
tempChsn += outPut.NumSum;
txtChosenPoints.Text = tempChsn.ToString();
if (((TextBox)this.Controls.Find($"txtMaxValue{row}", true).FirstOrDefault()).Text == actTxtBox.Text if (((TextBox)this.Controls.Find($"txtMaxValue{row}", true).FirstOrDefault()).Text == actTxtBox.Text
&& int.Parse(actTxtBox.Text.Trim()) > 0 && int.Parse(actTxtBox.Text.Trim()) > 0
&& _ht.Dices.Count(x => x.Chosen == true) == _ht.Dices.Count) && _ht.Dices.Count(x => x.Chosen == true) == _ht.Dices.Count)
@ -200,18 +208,19 @@ namespace WinGreed
} }
private string CheckForDifferentOutCome(List<int> numbers) private ResultSum CheckForDifferentOutCome(List<int> numbers)
{ {
var outPut = ""; var result = new ResultSum();
var sum = 0; result.StrSum = "";
result.NumSum = 0;
maxHeatPoints = false; maxHeatPoints = false;
numbers.Sort(); numbers.Sort();
sum = CheckForDoubleTriple(numbers); result.NumSum = CheckForDoubleTriple(numbers);
sum += CheckForTripleDouble(numbers); result.NumSum += CheckForTripleDouble(numbers);
sum += CheckForSerial(numbers); result.NumSum += CheckForSerial(numbers);
sum += CheckForThreeOrMore(numbers); result.NumSum += CheckForThreeOrMore(numbers);
outPut = sum.ToString(); result.StrSum = result.NumSum.ToString();
return outPut; return result;
} }
private int CheckForSerial(List<int> numbers) private int CheckForSerial(List<int> numbers)
@ -297,7 +306,7 @@ namespace WinGreed
public int NumberCounts(int value, int nmbr) public int NumberCounts(int value, int nmbr)
{ {
if (value > 2) if (value > 2 && !maxHeatPoints)
{ {
var back = nmbr == 1 ? 1000 : nmbr * 100; var back = nmbr == 1 ? 1000 : nmbr * 100;

View File

@ -65,7 +65,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAnhUAAAJNU0Z0AUkBTAIBAQYB SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAnhUAAAJNU0Z0AUkBTAIBAQYB
AAEYAQABGAEAASABAAEgAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMAAYADAAFAAwABAQEAAQgG AAFIAQABSAEAASABAAEgAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMAAYADAAFAAwABAQEAAQgG
AAEgGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEAAfABygGmAQABMwUAATMB AAEgGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEAAfABygGmAQABMwUAATMB
AAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEAAYABfAH/AQACUAH/AQAB AAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEAAYABfAH/AQACUAH/AQAB
kwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFmAwABmQMAAcwCAAEzAwAC kwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFmAwABmQMAAcwCAAEzAwAC