Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions SET/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
Expand Down
132 changes: 89 additions & 43 deletions SET/GameBoard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
public partial class GameBoard : Form
{
private Processing game = new Processing();
int cardsSelected;
int numCardsSelected;
List<Cards> currentSet = new List<Cards>();
// 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.

Expand All @@ -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();
}

/// <summary>
Expand All @@ -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
Expand All @@ -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();
}

/// <summary>
/// Event handler for user's cursor entering the button labeled set.
/// </summary>
Expand Down Expand Up @@ -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;
}

/// <summary>
/// Event handler for highlighting a card when selected.
/// </summary>
Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions SET/Processing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Processing
public void startGame(int[] options)
{
setOptions(options);
gameData.setUsers(1);
createDeck();
}

Expand Down Expand Up @@ -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<List<Cards>> getUserSets()
Expand Down
Binary file modified SET/bin/Debug/SET.exe
Binary file not shown.
Binary file modified SET/bin/Debug/SET.pdb
Binary file not shown.
Binary file modified SET/obj/Debug/SET.exe
Binary file not shown.
Binary file modified SET/obj/Debug/SET.pdb
Binary file not shown.