Point Calculation seems to run

This commit is contained in:
2022-07-03 23:37:55 +02:00
parent e06d33da06
commit 5b2a7a7ae9
2 changed files with 98 additions and 57 deletions

View File

@ -39,26 +39,26 @@
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.txtMaxValue = new System.Windows.Forms.TextBox(); this.txtMaxValue = new System.Windows.Forms.TextBox();
this.txtChosenValue = new System.Windows.Forms.TextBox(); this.txtChosenValue = new System.Windows.Forms.TextBox();
this.textBox1 = 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.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label1.Location = new System.Drawing.Point(26, 23); this.label1.Location = new System.Drawing.Point(23, 17);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(134, 37); this.label1.Size = new System.Drawing.Size(105, 30);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "Nu kör vi"; this.label1.Text = "Nu kör vi";
// //
// btnThrow // btnThrow
// //
this.btnThrow.Location = new System.Drawing.Point(37, 95); this.btnThrow.Location = new System.Drawing.Point(32, 71);
this.btnThrow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnThrow.Name = "btnThrow"; this.btnThrow.Name = "btnThrow";
this.btnThrow.Size = new System.Drawing.Size(110, 31); this.btnThrow.Size = new System.Drawing.Size(96, 23);
this.btnThrow.TabIndex = 1; this.btnThrow.TabIndex = 1;
this.btnThrow.Text = "Kasta Tärningar"; this.btnThrow.Text = "Kasta Tärningar";
this.btnThrow.UseVisualStyleBackColor = true; this.btnThrow.UseVisualStyleBackColor = true;
@ -66,10 +66,9 @@
// //
// btnDiceTmpl1 // btnDiceTmpl1
// //
this.btnDiceTmpl1.Location = new System.Drawing.Point(853, 109); this.btnDiceTmpl1.Location = new System.Drawing.Point(746, 82);
this.btnDiceTmpl1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnDiceTmpl1.Name = "btnDiceTmpl1"; this.btnDiceTmpl1.Name = "btnDiceTmpl1";
this.btnDiceTmpl1.Size = new System.Drawing.Size(48, 59); this.btnDiceTmpl1.Size = new System.Drawing.Size(42, 44);
this.btnDiceTmpl1.TabIndex = 2; this.btnDiceTmpl1.TabIndex = 2;
this.btnDiceTmpl1.Text = "1"; this.btnDiceTmpl1.Text = "1";
this.btnDiceTmpl1.UseVisualStyleBackColor = true; this.btnDiceTmpl1.UseVisualStyleBackColor = true;
@ -78,10 +77,9 @@
// //
// btnDiceTmpl2 // btnDiceTmpl2
// //
this.btnDiceTmpl2.Location = new System.Drawing.Point(853, 168); this.btnDiceTmpl2.Location = new System.Drawing.Point(746, 126);
this.btnDiceTmpl2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnDiceTmpl2.Name = "btnDiceTmpl2"; this.btnDiceTmpl2.Name = "btnDiceTmpl2";
this.btnDiceTmpl2.Size = new System.Drawing.Size(48, 59); this.btnDiceTmpl2.Size = new System.Drawing.Size(42, 44);
this.btnDiceTmpl2.TabIndex = 3; this.btnDiceTmpl2.TabIndex = 3;
this.btnDiceTmpl2.Text = "2"; this.btnDiceTmpl2.Text = "2";
this.btnDiceTmpl2.UseVisualStyleBackColor = true; this.btnDiceTmpl2.UseVisualStyleBackColor = true;
@ -90,10 +88,9 @@
// //
// btnDiceTmpl4 // btnDiceTmpl4
// //
this.btnDiceTmpl4.Location = new System.Drawing.Point(853, 285); this.btnDiceTmpl4.Location = new System.Drawing.Point(746, 214);
this.btnDiceTmpl4.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnDiceTmpl4.Name = "btnDiceTmpl4"; this.btnDiceTmpl4.Name = "btnDiceTmpl4";
this.btnDiceTmpl4.Size = new System.Drawing.Size(48, 59); this.btnDiceTmpl4.Size = new System.Drawing.Size(42, 44);
this.btnDiceTmpl4.TabIndex = 5; this.btnDiceTmpl4.TabIndex = 5;
this.btnDiceTmpl4.Text = "4"; this.btnDiceTmpl4.Text = "4";
this.btnDiceTmpl4.UseVisualStyleBackColor = true; this.btnDiceTmpl4.UseVisualStyleBackColor = true;
@ -102,10 +99,9 @@
// //
// btnDiceTmpl3 // btnDiceTmpl3
// //
this.btnDiceTmpl3.Location = new System.Drawing.Point(853, 227); this.btnDiceTmpl3.Location = new System.Drawing.Point(746, 170);
this.btnDiceTmpl3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnDiceTmpl3.Name = "btnDiceTmpl3"; this.btnDiceTmpl3.Name = "btnDiceTmpl3";
this.btnDiceTmpl3.Size = new System.Drawing.Size(48, 59); this.btnDiceTmpl3.Size = new System.Drawing.Size(42, 44);
this.btnDiceTmpl3.TabIndex = 4; this.btnDiceTmpl3.TabIndex = 4;
this.btnDiceTmpl3.Text = "3"; this.btnDiceTmpl3.Text = "3";
this.btnDiceTmpl3.UseVisualStyleBackColor = true; this.btnDiceTmpl3.UseVisualStyleBackColor = true;
@ -114,10 +110,9 @@
// //
// btnDiceTmpl6 // btnDiceTmpl6
// //
this.btnDiceTmpl6.Location = new System.Drawing.Point(853, 403); this.btnDiceTmpl6.Location = new System.Drawing.Point(746, 302);
this.btnDiceTmpl6.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnDiceTmpl6.Name = "btnDiceTmpl6"; this.btnDiceTmpl6.Name = "btnDiceTmpl6";
this.btnDiceTmpl6.Size = new System.Drawing.Size(48, 59); this.btnDiceTmpl6.Size = new System.Drawing.Size(42, 44);
this.btnDiceTmpl6.TabIndex = 7; this.btnDiceTmpl6.TabIndex = 7;
this.btnDiceTmpl6.Text = "6"; this.btnDiceTmpl6.Text = "6";
this.btnDiceTmpl6.UseVisualStyleBackColor = true; this.btnDiceTmpl6.UseVisualStyleBackColor = true;
@ -126,10 +121,9 @@
// //
// btnDiceTmpl5 // btnDiceTmpl5
// //
this.btnDiceTmpl5.Location = new System.Drawing.Point(853, 344); this.btnDiceTmpl5.Location = new System.Drawing.Point(746, 258);
this.btnDiceTmpl5.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnDiceTmpl5.Name = "btnDiceTmpl5"; this.btnDiceTmpl5.Name = "btnDiceTmpl5";
this.btnDiceTmpl5.Size = new System.Drawing.Size(48, 59); this.btnDiceTmpl5.Size = new System.Drawing.Size(42, 44);
this.btnDiceTmpl5.TabIndex = 6; this.btnDiceTmpl5.TabIndex = 6;
this.btnDiceTmpl5.Text = "5"; this.btnDiceTmpl5.Text = "5";
this.btnDiceTmpl5.UseVisualStyleBackColor = true; this.btnDiceTmpl5.UseVisualStyleBackColor = true;
@ -138,10 +132,9 @@
// //
// btnClose // btnClose
// //
this.btnClose.Location = new System.Drawing.Point(775, 529); this.btnClose.Location = new System.Drawing.Point(713, 583);
this.btnClose.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnClose.Name = "btnClose"; this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(86, 31); this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 8; this.btnClose.TabIndex = 8;
this.btnClose.Text = "Stäng"; this.btnClose.Text = "Stäng";
this.btnClose.UseVisualStyleBackColor = true; this.btnClose.UseVisualStyleBackColor = true;
@ -149,48 +142,58 @@
// //
// txtMaxValue // txtMaxValue
// //
this.txtMaxValue.Location = new System.Drawing.Point(765, 109); this.txtMaxValue.Location = new System.Drawing.Point(669, 82);
this.txtMaxValue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtMaxValue.Multiline = true; this.txtMaxValue.Multiline = true;
this.txtMaxValue.Name = "txtMaxValue"; this.txtMaxValue.Name = "txtMaxValue";
this.txtMaxValue.Size = new System.Drawing.Size(47, 57); this.txtMaxValue.Size = new System.Drawing.Size(42, 44);
this.txtMaxValue.TabIndex = 9; this.txtMaxValue.TabIndex = 9;
this.txtMaxValue.Visible = false; this.txtMaxValue.Visible = false;
// //
// txtChosenValue // txtChosenValue
// //
this.txtChosenValue.Location = new System.Drawing.Point(765, 168); this.txtChosenValue.Location = new System.Drawing.Point(669, 126);
this.txtChosenValue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtChosenValue.Multiline = true; this.txtChosenValue.Multiline = true;
this.txtChosenValue.Name = "txtChosenValue"; this.txtChosenValue.Name = "txtChosenValue";
this.txtChosenValue.Size = new System.Drawing.Size(47, 57); this.txtChosenValue.Size = new System.Drawing.Size(42, 44);
this.txtChosenValue.TabIndex = 10; this.txtChosenValue.TabIndex = 10;
this.txtChosenValue.Visible = false; this.txtChosenValue.Visible = false;
// //
// textBox1 // txtTotalPoints
// //
this.textBox1.Location = new System.Drawing.Point(400, 97); this.txtTotalPoints.Location = new System.Drawing.Point(350, 73);
this.textBox1.Name = "textBox1"; this.txtTotalPoints.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBox1.Size = new System.Drawing.Size(125, 27); this.txtTotalPoints.Name = "txtTotalPoints";
this.textBox1.TabIndex = 11; this.txtTotalPoints.Size = new System.Drawing.Size(110, 23);
this.txtTotalPoints.TabIndex = 11;
// //
// lblRecentPoints // lblRecentPoints
// //
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(196, 93); this.lblRecentPoints.Location = new System.Drawing.Point(172, 70);
this.lblRecentPoints.Name = "lblRecentPoints"; this.lblRecentPoints.Name = "lblRecentPoints";
this.lblRecentPoints.Size = new System.Drawing.Size(198, 28); this.lblRecentPoints.Size = new System.Drawing.Size(158, 21);
this.lblRecentPoints.TabIndex = 12; this.lblRecentPoints.TabIndex = 12;
this.lblRecentPoints.Text = "Aktuell poängsumma"; this.lblRecentPoints.Text = "Aktuell poängsumma";
// //
// btnCollect
//
this.btnCollect.Location = new System.Drawing.Point(495, 71);
this.btnCollect.Name = "btnCollect";
this.btnCollect.Size = new System.Drawing.Size(75, 23);
this.btnCollect.TabIndex = 13;
this.btnCollect.Text = "Nöjd";
this.btnCollect.UseVisualStyleBackColor = true;
this.btnCollect.Click += new System.EventHandler(this.btnCollect_Click);
//
// frmPersonRound // frmPersonRound
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); 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(914, 600); this.ClientSize = new System.Drawing.Size(800, 618);
this.Controls.Add(this.btnCollect);
this.Controls.Add(this.lblRecentPoints); this.Controls.Add(this.lblRecentPoints);
this.Controls.Add(this.textBox1); this.Controls.Add(this.txtTotalPoints);
this.Controls.Add(this.txtChosenValue); this.Controls.Add(this.txtChosenValue);
this.Controls.Add(this.txtMaxValue); this.Controls.Add(this.txtMaxValue);
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
@ -202,7 +205,6 @@
this.Controls.Add(this.btnDiceTmpl1); this.Controls.Add(this.btnDiceTmpl1);
this.Controls.Add(this.btnThrow); this.Controls.Add(this.btnThrow);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "frmPersonRound"; this.Name = "frmPersonRound";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Din tur -"; this.Text = "Din tur -";
@ -224,7 +226,8 @@
private Button btnClose; private Button btnClose;
private TextBox txtMaxValue; private TextBox txtMaxValue;
private TextBox txtChosenValue; private TextBox txtChosenValue;
private TextBox textBox1; private TextBox txtTotalPoints;
private Label lblRecentPoints; private Label lblRecentPoints;
private Button btnCollect;
} }
} }

View File

@ -29,6 +29,7 @@ namespace WinGreed
_ht = new HandleThrow(); _ht = new HandleThrow();
_ht.Who = Player; _ht.Who = Player;
///ht.Throw(); ///ht.Throw();
btnThrow.Enabled = true;
} }
private void btnThrow_Click(object sender, EventArgs e) private void btnThrow_Click(object sender, EventArgs e)
@ -158,11 +159,20 @@ namespace WinGreed
txtRes.Visible = true; txtRes.Visible = true;
this.Controls.Add(txtRes); this.Controls.Add(txtRes);
this.Refresh(); this.Refresh();
}
string outPut = CheckForDifferentOutCome(numbers); string outPut = CheckForDifferentOutCome(numbers);
txtMaxValue.Text = outPut; var actTxtBox=((TextBox)this.Controls.Find($"txtMaxValue{row}", true).FirstOrDefault());
txtMaxValue.Refresh(); actTxtBox.Text = outPut;
actTxtBox.Refresh();
}
else
{
string outPut = CheckForDifferentOutCome(numbers);
var actTxtBox = ((TextBox)this.Controls.Find($"txtChosenValue{row}", true).FirstOrDefault());
actTxtBox.Text = outPut;
actTxtBox.Refresh();
}
numbers.ForEach(x => Debug.Write($"{x}, ")); numbers.ForEach(x => Debug.Write($"{x}, "));
Debug.WriteLine(" -"); Debug.WriteLine(" -");
@ -184,7 +194,9 @@ namespace WinGreed
private int CheckForSerial(List<int> numbers) private int CheckForSerial(List<int> numbers)
{ {
for(int i = 0; i < numbers.Count; i++) if (numbers.Count > 5)
{
for (int i = 0; i < numbers.Count; i++)
{ {
if(numbers[i] != i + 1) if(numbers[i] != i + 1)
{ {
@ -193,6 +205,8 @@ namespace WinGreed
} }
return 1500; return 1500;
} }
return 0;
}
private int CheckForThreeOrMore(List<int> numbers) private int CheckForThreeOrMore(List<int> numbers)
{ {
@ -205,8 +219,8 @@ namespace WinGreed
var fives = 0; var fives = 0;
var sixs = 0; var sixs = 0;
if(numbers.Count > 2) //if(numbers.Count > 2)
{ //{
foreach(var number in numbers) foreach(var number in numbers)
{ {
switch (number) switch (number)
@ -252,7 +266,7 @@ namespace WinGreed
result += NumberCounts(fours, 4); result += NumberCounts(fours, 4);
result += NumberCounts(fives, 5); result += NumberCounts(fives, 5);
result += NumberCounts(sixs, 6); result += NumberCounts(sixs, 6);
} //}
return result; return result;
@ -262,7 +276,8 @@ namespace WinGreed
{ {
if (value > 2) if (value > 2)
{ {
var back = nmbr*(nmbr==1?1000:100); var back = nmbr==1?1000:nmbr*100;
if (value > 3) if (value > 3)
{ {
back *= 2; back *= 2;
@ -277,6 +292,14 @@ namespace WinGreed
} }
return back; return back;
} }
else
{
if (value < 3 && (nmbr==1 || nmbr==5))
{
var back = value * (nmbr == 1 ? 100 : 50);
return back;
}
}
return 0; return 0;
} }
@ -325,5 +348,20 @@ namespace WinGreed
{ {
this.Close(); this.Close();
} }
private void btnCollect_Click(object sender, EventArgs e)
{
btnThrow.Enabled = false;
MarkGrayAndDisable(row);
var totalSum = 0;
for (int i = row; i >0; i--)
{
var acttxt = (TextBox)this.Controls.Find($"txtChosenValue{i}", true).FirstOrDefault();
totalSum += int.Parse(acttxt.Text);
}
TotPoints = totalSum;
txtTotalPoints.Text = totalSum.ToString();
_ht.Score += totalSum;
}
} }
} }