public void deal() { if (c.EOD() && !SetExists() && EODtag) { EODtag = false; Message("Shuffle", 2); int temp = num_todraw; for (int i = 0; i < temp; i++) { locs[i].dontdraw(); } c.shuffle(); } else if (c.EOD() && !SetExists()) { Message("End of Deck: No More Sets", "Click Mouse to Deal Again", 2); EODtag = true; return; } while (!c.EOD() && ((num_todraw < INIT_NUM_ROWS * NUM_COLS) || (!SetExists()))) { int temp = num_todraw; locs[temp].SetImage(c.NextCard()); locs[temp + 1].SetImage(c.NextCard()); locs[temp + 2].SetImage(c.NextCard()); locs[temp].dodraw(); locs[temp + 1].dodraw(); locs[temp + 2].dodraw(); } if (c.EOD()) { Message("End of Deck", 2); } }
public void CheckSet() { int[] s = new int[3]; s[0] = s[1] = s[2] = 0; if (num_selected < 3) return; for (int i = 0; i < 3; i++) { while (!locs[s[i]].Selected() && (s[i] < num_todraw)) { s[i]++; } if (i < 2) s[i + 1] = s[i] + 1; } /* while (!locs[s[0]].Selected() && (s[0] < num_todraw)) { s[0]++; } s[1] = s[0] + 1; while (!locs[s[1]].Selected() && (s[1] < num_todraw)) { s[1]++; } s[2] = s[1] + 1; while (!locs[s[2]].Selected() && (s[2] < num_todraw)) { s[2]++; } */ if ((s[0] == s[1]) || (s[1] == s[2]) || (s[0] == s[2]) || (s[0] >= num_todraw) || (s[1] >= num_todraw) || (s[2] >= num_todraw)) return; if (IsSet(locs[s[0]].GetImage(), locs[s[1]].GetImage(), locs[s[2]].GetImage())) { Message("You Found a Set!", 1); if ((num_todraw <= INIT_NUM_ROWS * NUM_COLS) && !c.EOD()) { for (int i = 0; i < 3; i++) { locs[s[i]].SetImage(c.NextCard()); } } else { int temp = num_todraw; for (int i = 0, j = temp - 1; j > temp - 4; j--) { if ((j != s[0]) && (j != s[1]) && (j != s[2])) { locs[s[i]].SetImage(locs[j].GetImage()); i++; } locs[j].dontdraw(); // locs[j].draw(getGraphics(), this); } } } else { Message( "Not a Set!: " + locs[s[0]].GetImage() + " " + locs[s[1]].GetImage() + " " + locs[s[2]].GetImage(), 1); } update(this.getGraphics()); ClearSelected(); update(this.getGraphics()); deal(); update(this.getGraphics()); }