Professional Documents
Culture Documents
Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.io.File;
import java.net.URL;
import java.util.List;
import javax.imageio.ImageIO;
if(!(playingPiles[playingPile]==playingPiles[las
tClick])){// not the same pile
System.out.println("adding cards to empt
y pile");
PlayingPile tempPlayingPile = getPlaying
Pile(playingPile);// moving to
if(tempPlayingPile.size()==0){// trying
to move to an empty pile
if(tempList.get(0).pointValue()=
=13){// king
for(int i = 0; i<tempLis
t.size(); i++){
tempPlayingPile.
add(tempList.get(i));
}
tempList = playingPiles[
lastClick].removeSelected();
for(Card a: tempList){
playingPiles[pla
yingPile].add(a);
}
return;
}
else{
// you are trying to mov
e non-king to open spot, reset
//deselect()
}
}
else{// at least one card, is it face up
?
System.out.println("trying to mo
ve "+tempList.get(0));
Card tempCard = tempPlayingPile.
getCard(tempPlayingPile.size()-1);
if(!tempCard.isFacingUp()){
//deselect
return;
}
System.out.println("temp card "+
tempCard+" is face up");
// face up, so check
if (tempCard.pointValue() - 1 ==
tempList.get(0).pointValue()){// ranks line up
System.out.println("tryi
ng to move "+tempList.get(0)+" onto "+tempCard);
if(tempCard.isRed() != t
empList.get(0).isRed()){
System.out.print
ln("Opposite color");
for(int i = 0; i
<tempList.size(); i++){
tempPlay
ingPile.add(tempList.get(i));
}
//playingPiles[p
layingPile] = tempPlayingPile;
}
// else if (!tempCard.isRed
() && tempList.get(0).isRed()){
// for(int i = 0; i
<tempList.size(); i++){
// tempPlay
ingPile.add(tempList.get(i));
// }
// playingPiles[pla
yingPile] = tempPlayingPile;
// }
}
else{
// point values not with
in one
//deselect
return;
}
// tempList = playingPiles[lastClic
k].removeSelected();
// for(Card a: tempList){
// playingPiles[playingPile
].add(a);
// }
}
}
}
playingPiles[lastClick].deselect();
firstClick = true;
}
}
System.out.println("deck click");
if (deck.size() >=3) {
for (int i=0; i<3; i++){
cardPile.add(deck.deal());
System.out.println("DEAL DEAL DEAL");
}
}
else if (deck.size()==0){
while(cardPile.size() != 0) {
Card test = cardPile.remove(cardPile.size() - 1)
;
System.out.println(test);
deck.add(test);
}
System.out.println(deck.size()+"*");
System.out.println(cardPile.size()+"!");
}
else {
for (int i=0; i<deck.size(); i++){
cardPile.add(deck.deal());
System.out.println("LESS THAN 3 CARDS");
}
}
}
}