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()); }
public void paint(Graphics g) { Message("Copyright Feb, 2000 Weicon Conan Yuan.", "All Rights Reserved", 7); for (int i = 0; i < NUM_LOCATIONS; i++) { locs[i].draw(g, this); g.setColor(txtcolor); if (locs[i].ToDraw()) { g.drawString("" + i, locs[i].GetX(), locs[i].GetY() + 10); } } g.setColor(Color.red); g.drawRect(400, 200, 30, 30); g.fillRect(400, 200, 30, 30); Message("Cheat", 4); }
public void ShowSet() { String s = ""; for (int i = 0; i < num_todraw; i++) { for (int j = i + 1; j < num_todraw; j++) { for (int k = j + 1; k < num_todraw; k++) { if (IsSet(locs[i].GetImage(), locs[j].GetImage(), locs[k].GetImage())) { s += i + " " + j + " " + k + "; "; // Message(i + " " + j + " " + k, 3); // return; } } } } Message(s, 3); return; }