diff --git a/SET/Data.cs b/SET/Data.cs index 5a4c65d..14439a4 100644 --- a/SET/Data.cs +++ b/SET/Data.cs @@ -48,6 +48,13 @@ public void changeNumberOfSets(int sets) numberOfSets = sets; } + public void setUsers(int v) + { + // right now just set users to 1 + Players player1 = new Players(); + players.Add(player1); + } + // Unfinished public void buildDeck() { @@ -235,15 +242,22 @@ public int getUsers() } // Unfinished - public int getUserScore() + public int getUserScore(int v) { - return 0; + return players[v - 1].Score; } // Unfinished - public void setUserScore(int score) + public void setUserScore(int player, int score) { - + if (score > 0) + { + players[player - 1].Score++; + } + else + { + players[player - 1].Score--; + } } // Unfinished diff --git a/SET/GameBoard.cs b/SET/GameBoard.cs index 22fc493..d96aa4e 100644 --- a/SET/GameBoard.cs +++ b/SET/GameBoard.cs @@ -18,10 +18,11 @@ public partial class GameBoard : Form { private Processing game = new Processing(); - int cardsSelected; + int numCardsSelected; List currentSet = new List(); // create holder for the 12 cards for the game board. These need to be set when we call for a new card to be put on the board. private Cards[] cardsOnBoard; + int[] cardsSelected = { 0, 0, 0 } ; // private int[] options; // dont think we need this since the settings are sent to game when form is created. @@ -47,6 +48,8 @@ public GameBoard(int[] options) pictureBox11.BackgroundImage = Image.FromFile(cardsOnBoard[10].Image); pictureBox12.BackgroundImage = Image.FromFile(cardsOnBoard[11].Image); + // set score + updateScoreBoard(); } /// @@ -57,17 +60,21 @@ public GameBoard(int[] options) private void SetButtonClick(object sender, EventArgs e) { // Set Logic - if (cardsSelected == 3) + if (numCardsSelected == 3) { if(currentSet.Count() == 3 && game.ConfirmSet(currentSet) == true) { + game.setUserScore(1, 1); + // update scoreboard + updateScoreBoard(); + // get rid of selected cards from board and get new cards MessageBox.Show("You have a valid set, YAY!"); - // add 1 to score } else - { + { + game.setUserScore(1, -1); + updateScoreBoard(); MessageBox.Show("Your SET is NOT valid!"); - // subtract 1 from score } } else @@ -76,6 +83,15 @@ private void SetButtonClick(object sender, EventArgs e) } } + private void updateScoreBoard() + { + player1Score.Text = game.getUserScore(1).ToString(); + // player2Score.Text = game.getUserScore(2).ToString(); + // player3Score.Text = game.getUserScore(3).ToString(); + // player4Score.Text = game.getUserScore(4).ToString(); + // player5Score.Text = game.getUserScore(5).ToString(); + } + /// /// Event handler for user's cursor entering the button labeled set. /// @@ -172,17 +188,47 @@ private void PictureBox1_Click(object sender, EventArgs e) if (pictureBox1.BackColor == Color.Gold) { pictureBox1.BackColor = Color.FromArgb(0x575757); - // take card out of the set array - --cardsSelected; + removeCurrentCard(1); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox1.BackColor = Color.Gold; - // add card to set array - ++cardsSelected; + addCurrentCard(1); } } + private void addCurrentCard(int v) + { + currentSet.Add(cardsOnBoard[v - 1]); + for(int i = 0; i < 3; i++) + { + if (cardsSelected[i] == 0) + { + cardsSelected[i] = v; + break; + } + } + ++numCardsSelected; + } + + private void removeCurrentCard(int v) + { + for (int i = 0; i < 3; i++) + { + if (cardsSelected[i] == v) + { + currentSet.RemoveAt(i); + for (int j = i; j < 2; j++) + { + cardsSelected[j] = cardsSelected[j + 1]; + } + cardsSelected[2] = 0; + break; + } + } + --numCardsSelected; + } + /// /// Event handler for highlighting a card when selected. /// @@ -193,12 +239,12 @@ private void PictureBox2_Click(object sender, EventArgs e) if (pictureBox2.BackColor == Color.Gold) { pictureBox2.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(2); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox2.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(2); } } @@ -212,12 +258,12 @@ private void PictureBox3_Click(object sender, EventArgs e) if (pictureBox3.BackColor == Color.Gold) { pictureBox3.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(3); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox3.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(3); } } @@ -231,12 +277,12 @@ private void PictureBox4_Click(object sender, EventArgs e) if (pictureBox4.BackColor == Color.Gold) { pictureBox4.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(4); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox4.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(4); } } @@ -250,12 +296,12 @@ private void PictureBox5_Click(object sender, EventArgs e) if (pictureBox5.BackColor == Color.Gold) { pictureBox5.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(5); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox5.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(5); } } @@ -269,12 +315,12 @@ private void PictureBox6_Click(object sender, EventArgs e) if (pictureBox6.BackColor == Color.Gold) { pictureBox6.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(6); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox6.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(6); } } @@ -288,12 +334,12 @@ private void PictureBox7_Click(object sender, EventArgs e) if (pictureBox7.BackColor == Color.Gold) { pictureBox7.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(7); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox7.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(7); } } @@ -307,12 +353,12 @@ private void PictureBox8_Click(object sender, EventArgs e) if (pictureBox8.BackColor == Color.Gold) { pictureBox8.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(8); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox8.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(8); } } @@ -326,12 +372,12 @@ private void PictureBox9_Click(object sender, EventArgs e) if (pictureBox9.BackColor == Color.Gold) { pictureBox9.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(9); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox9.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(9); } } @@ -345,12 +391,12 @@ private void PictureBox10_Click(object sender, EventArgs e) if (pictureBox10.BackColor == Color.Gold) { pictureBox10.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(10); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox10.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(10); } } @@ -364,12 +410,12 @@ private void PictureBox11_Click(object sender, EventArgs e) if (pictureBox11.BackColor == Color.Gold) { pictureBox11.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(11); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox11.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(11); } } @@ -383,12 +429,12 @@ private void PictureBox12_Click(object sender, EventArgs e) if (pictureBox12.BackColor == Color.Gold) { pictureBox12.BackColor = Color.FromArgb(0x575757); - --cardsSelected; + removeCurrentCard(12); } - else if (cardsSelected < 3) + else if (numCardsSelected < 3) { pictureBox12.BackColor = Color.Gold; - ++cardsSelected; + addCurrentCard(12); } } } diff --git a/SET/Processing.cs b/SET/Processing.cs index 3ef5fe6..cfde5eb 100644 --- a/SET/Processing.cs +++ b/SET/Processing.cs @@ -18,6 +18,7 @@ public class Processing public void startGame(int[] options) { setOptions(options); + gameData.setUsers(1); createDeck(); } @@ -53,9 +54,14 @@ public int getNumberUsers() return gameData.getUsers(); } - public int getUserScore() + public int getUserScore(int v) { - return gameData.getUserScore(); + return gameData.getUserScore(v); + } + + public void setUserScore(int player, int score) + { + gameData.setUserScore(player, score); } public List> getUserSets() diff --git a/SET/bin/Debug/SET.exe b/SET/bin/Debug/SET.exe index 8c5c7b4..a9030a3 100644 Binary files a/SET/bin/Debug/SET.exe and b/SET/bin/Debug/SET.exe differ diff --git a/SET/bin/Debug/SET.pdb b/SET/bin/Debug/SET.pdb index b4617fb..5f17156 100644 Binary files a/SET/bin/Debug/SET.pdb and b/SET/bin/Debug/SET.pdb differ diff --git a/SET/obj/Debug/SET.exe b/SET/obj/Debug/SET.exe index 8c5c7b4..a9030a3 100644 Binary files a/SET/obj/Debug/SET.exe and b/SET/obj/Debug/SET.exe differ diff --git a/SET/obj/Debug/SET.pdb b/SET/obj/Debug/SET.pdb index b4617fb..5f17156 100644 Binary files a/SET/obj/Debug/SET.pdb and b/SET/obj/Debug/SET.pdb differ