Game over handling ready
This commit is contained in:
20
WinGreed/GameOverCheck.cs
Normal file
20
WinGreed/GameOverCheck.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinGreed
|
||||||
|
{
|
||||||
|
public class GameOverCheck
|
||||||
|
{
|
||||||
|
public GameOverCheck()
|
||||||
|
{
|
||||||
|
this.lvsave = null;
|
||||||
|
this.points = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListViewItem lvsave { get; set; }
|
||||||
|
public int points { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,8 +4,11 @@ namespace WinGreed
|
|||||||
{
|
{
|
||||||
public partial class frmStart : Form
|
public partial class frmStart : Form
|
||||||
{
|
{
|
||||||
|
private bool GameOver = false;
|
||||||
|
private GameOverCheck gocFirst = new GameOverCheck();
|
||||||
|
private GameOverCheck gocSecond = new GameOverCheck();
|
||||||
private frmPersonRound fPR = null;
|
private frmPersonRound fPR = null;
|
||||||
private int actPlayerNo=-1;
|
private int actPlayerNo = -1;
|
||||||
public frmStart()
|
public frmStart()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -18,9 +21,45 @@ namespace WinGreed
|
|||||||
var nextLvInstance = lvMemberList.Items[NextLvItem()];
|
var nextLvInstance = lvMemberList.Items[NextLvItem()];
|
||||||
var nextPlayerName = nextLvInstance.Text;
|
var nextPlayerName = nextLvInstance.Text;
|
||||||
fPR = new frmPersonRound(nextPlayerName);
|
fPR = new frmPersonRound(nextPlayerName);
|
||||||
fPR.TotPoints = int.Parse( nextLvInstance.SubItems[2].Text);
|
fPR.TotPoints = int.Parse(nextLvInstance.SubItems[2].Text);
|
||||||
fPR.ShowDialog();
|
fPR.ShowDialog();
|
||||||
nextLvInstance.SubItems[2].Text = fPR.TotPoints.ToString();
|
nextLvInstance.SubItems[2].Text = fPR.TotPoints.ToString();
|
||||||
|
if (GameOver)
|
||||||
|
{
|
||||||
|
if (nextLvInstance == gocFirst.lvsave)
|
||||||
|
{
|
||||||
|
PlaySomething();
|
||||||
|
if (gocSecond.lvsave != null)
|
||||||
|
{
|
||||||
|
gocSecond.lvsave.SubItems[1].Text = (int.Parse(gocSecond.lvsave.SubItems[1].Text) + 1).ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextLvInstance.SubItems[1].Text = (int.Parse(nextLvInstance.SubItems[1].Text) + 1).ToString();
|
||||||
|
}
|
||||||
|
btnSpela.Enabled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(fPR.TotPoints > gocFirst.points && nextLvInstance != gocFirst.lvsave)
|
||||||
|
{
|
||||||
|
if(nextLvInstance != gocSecond.lvsave && fPR.TotPoints > gocSecond.points)
|
||||||
|
{
|
||||||
|
gocSecond.points = fPR.TotPoints;
|
||||||
|
gocSecond.lvsave = nextLvInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fPR.TotPoints > 10000)
|
||||||
|
{
|
||||||
|
GameOver = true;
|
||||||
|
gocFirst.points = fPR.TotPoints;
|
||||||
|
gocFirst.lvsave = nextLvInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +69,7 @@ namespace WinGreed
|
|||||||
if (lvMemberList.Items.Count > 1)
|
if (lvMemberList.Items.Count > 1)
|
||||||
{
|
{
|
||||||
actPlayerNo++;
|
actPlayerNo++;
|
||||||
if(actPlayerNo > lvMemberList.Items.Count-1)
|
if (actPlayerNo > lvMemberList.Items.Count - 1)
|
||||||
{
|
{
|
||||||
actPlayerNo = 0;
|
actPlayerNo = 0;
|
||||||
}
|
}
|
||||||
@ -47,7 +86,7 @@ namespace WinGreed
|
|||||||
|
|
||||||
private void btnAddOk_Click(object sender, EventArgs e)
|
private void btnAddOk_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var item=lvMemberList.Items.Add(txtNewName.Text.Trim());
|
var item = lvMemberList.Items.Add(txtNewName.Text.Trim());
|
||||||
item.SubItems.Add("0");
|
item.SubItems.Add("0");
|
||||||
item.SubItems.Add("0");
|
item.SubItems.Add("0");
|
||||||
txtNewName.Text = "";
|
txtNewName.Text = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user