From 6b2711b1838314710eb4bb435e73d6112924b3fc Mon Sep 17 00:00:00 2001 From: sili98 <sili98@sch.bme.hu> Date: Mon, 9 Dec 2019 21:36:02 +0100 Subject: [PATCH] Almost done. GameOver condition is buggy, overall game seems to work. --- zsirozas/Form1.Designer.cs | 4 ++-- zsirozas/Form1.cs | 47 +++++++++++++++++++------------------- zsirozas/Game.cs | 7 +++--- zsirozas/GameClient.cs | 1 - 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/zsirozas/Form1.Designer.cs b/zsirozas/Form1.Designer.cs index b3c655b..641e724 100644 --- a/zsirozas/Form1.Designer.cs +++ b/zsirozas/Form1.Designer.cs @@ -482,7 +482,7 @@ this.labelDeckCnt.Name = "labelDeckCnt"; this.labelDeckCnt.Size = new System.Drawing.Size(93, 31); this.labelDeckCnt.TabIndex = 0; - this.labelDeckCnt.Text = "12 lap"; + this.labelDeckCnt.Text = "XYZ lap"; // // panelCards // @@ -550,7 +550,7 @@ this.buttonEndTurn.Name = "buttonEndTurn"; this.buttonEndTurn.Size = new System.Drawing.Size(143, 69); this.buttonEndTurn.TabIndex = 5; - this.buttonEndTurn.Text = "button1"; + this.buttonEndTurn.Text = "Kör vége"; this.buttonEndTurn.UseVisualStyleBackColor = true; this.buttonEndTurn.Click += new System.EventHandler(this.buttonEndTurn_Click); // diff --git a/zsirozas/Form1.cs b/zsirozas/Form1.cs index 5d75b36..c47c63f 100644 --- a/zsirozas/Form1.cs +++ b/zsirozas/Form1.cs @@ -33,8 +33,8 @@ namespace zsirozas { if (client.UseCard(3)) { - buttonCard0.Enabled = false; - buttonCard0.Visible = false; + buttonCard3.Enabled = false; + buttonCard3.Visible = false; } } @@ -42,8 +42,8 @@ namespace zsirozas { if (client.UseCard(2)) { - buttonCard0.Enabled = false; - buttonCard0.Visible = false; + buttonCard2.Enabled = false; + buttonCard2.Visible = false; } } @@ -51,8 +51,8 @@ namespace zsirozas { if (client.UseCard(1)) { - buttonCard0.Enabled = false; - buttonCard0.Visible = false; + buttonCard1.Enabled = false; + buttonCard1.Visible = false; } } @@ -192,43 +192,42 @@ namespace zsirozas labelDeckCnt.Text = client.gameState.remainsInDeck + "lap"; if (client.gameState.cardsOnTable.Length > 0) { - labelTurnCard.Text = client.gameState.cardsOnTable[0].ToString(); } else { labelTurnCard.Text = ""; } - for (int i = 1; i < client.gameState.numofCardsInHands.Length; i++) + for (int i = 0; i < client.gameState.numofCardsInHands.Length - 1; i++) { - int idx = (i + client.playerIDX) % client.gameState.numofCardsInHands.Length; - playerNameLabels[idx].Visible = true; - playerNameLabels[idx].Visible = true; + int idx = (i + client.playerIDX + 1) % client.gameState.numofCardsInHands.Length; + playerNameLabels[i].Visible = true; + playerNameLabels[i].Visible = true; - playerNameLabels[idx].Text = client.gameState.playersByOrder[i]; - playerCardLabels[idx].Text = client.gameState.numofCardsInHands.Length.ToString(); - if (client.gameState.startingPlayer == i) + playerNameLabels[i].Text = client.gameState.playersByOrder[idx]; + playerCardLabels[i].Text = client.gameState.numofCardsInHands[idx].ToString(); + if (client.gameState.startingPlayer == idx) { - playerNameLabels[idx].BackColor = Color.Cyan; - playerNameLabels[idx].BackColor = Color.Cyan; + playerNameLabels[i].BackColor = Color.Cyan; + playerNameLabels[i].BackColor = Color.Cyan; } else { - playerNameLabels[idx].BackColor = Color.Transparent; - playerNameLabels[idx].BackColor = Color.Transparent; + playerNameLabels[i].BackColor = Color.Transparent; + playerNameLabels[i].BackColor = Color.Transparent; } - if (client.gameState.lastToHit == i) + if (client.gameState.lastToHit == idx) { - playerNameLabels[idx].BackColor = Color.Yellow; - playerNameLabels[idx].BackColor = Color.Yellow; + playerNameLabels[i].BackColor = Color.Yellow; + playerNameLabels[i].BackColor = Color.Yellow; } else { - playerNameLabels[idx].BackColor = Color.Transparent; - playerNameLabels[idx].BackColor = Color.Transparent; + playerNameLabels[i].BackColor = Color.Transparent; + playerNameLabels[i].BackColor = Color.Transparent; } } - for (int i = 0; i < playerNameLabels.Length; i++) + for (int i = client.gameState.numofCardsInHands.Length - 1; i < playerNameLabels.Length; i++) { playerNameLabels[i].Visible = false; playerCardLabels[i].Visible = false; diff --git a/zsirozas/Game.cs b/zsirozas/Game.cs index 592e5bb..8778980 100644 --- a/zsirozas/Game.cs +++ b/zsirozas/Game.cs @@ -83,7 +83,7 @@ namespace zsirozas public void ValidPlayerMakesCardActionInValidTurnWithValidCard(string playerID, int cardID) { - //Id said player has started the turn... + //If said player has started the turn... if (playersByOrder[currentRound.startingPlayer] == playerID) { //...he has to hit it to continue @@ -116,8 +116,8 @@ namespace zsirozas currentRound.nextUp = (currentRound.nextUp + 1) % playersByOrder.Length; NotifyPlayers(GameEvent.CardAction); } - - //playersByID[playersByOrder[currentRound.nextUp]].Invoke(); + currentRound.nextUp = (currentRound.nextUp + 1) % playersByOrder.Length; + NotifyPlayers(GameEvent.CardAction); } @@ -132,6 +132,7 @@ namespace zsirozas //Has this turn tecnically ended? if (playersByOrder[currentRound.lastToHit] == playerID && currentRound.playedCards.Count > 0) { + //TODO: BUG: akkor is ezt adja, ha nem mi jövünk Complain("Objection! You already won this round!"); } else diff --git a/zsirozas/GameClient.cs b/zsirozas/GameClient.cs index 51c170d..4e0b23c 100644 --- a/zsirozas/GameClient.cs +++ b/zsirozas/GameClient.cs @@ -323,6 +323,5 @@ namespace zsirozas // to infer the type to cast x to return (T)x; } - } } -- GitLab