Format using tabs

This commit is contained in:
Charles Gould 2015-06-23 15:13:26 -04:00
parent 1b0d06f20c
commit 43bf9f9adf
17 changed files with 823 additions and 827 deletions

View File

@ -19,10 +19,8 @@ public class FreeCellApplication extends Application {
@Override @Override
public void start(Stage stage) throws Exception { public void start(Stage stage) throws Exception {
VBox root = new VBox(); VBox root = new VBox();
root.setBackground(new Background(new BackgroundImage(new Image( root.setBackground(new Background(new BackgroundImage(new Image("/deck/FELT.jpg"), BackgroundRepeat.NO_REPEAT,
"/deck/FELT.jpg"), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, BackgroundSize.DEFAULT)));
BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
BackgroundSize.DEFAULT)));
Game game = new Game(); Game game = new Game();
GameMenuBar menuBar = new GameMenuBar(); GameMenuBar menuBar = new GameMenuBar();

View File

@ -42,8 +42,7 @@ public class Card {
faceImages = new DoubleKeyedMap<>(); faceImages = new DoubleKeyedMap<>();
} }
if (!faceImages.contains(rank, suit)) { if (!faceImages.contains(rank, suit)) {
faceImages.put(rank, suit, new Image("/deck/" + rank.value faceImages.put(rank, suit, new Image("/deck/" + rank.value + suit.firstLetter + ".png"));
+ suit.firstLetter + ".png"));
} }
return faceImages.get(rank, suit); return faceImages.get(rank, suit);
} }

View File

@ -29,8 +29,6 @@ public class MoveAction implements Action {
return false; return false;
} }
MoveAction action = (MoveAction) other; MoveAction action = (MoveAction) other;
return fromPile == action.fromPile return fromPile == action.fromPile && toPile == action.toPile && numCards == action.numCards;
&& toPile == action.toPile
&& numCards == action.numCards;
} }
} }

View File

@ -17,8 +17,7 @@ public class Foundation extends AbstractPile {
} }
Rank thisRank = topCard().rank; Rank thisRank = topCard().rank;
Suit thisSuit = topCard().suit; Suit thisSuit = topCard().suit;
return otherSuit == thisSuit return otherSuit == thisSuit && otherRank.value == thisRank.value + 1;
&& otherRank.value == thisRank.value + 1;
} }
@Override @Override

View File

@ -27,7 +27,8 @@ public interface Pile extends Iterable<Card> {
int moveFrom(Pile other); int moveFrom(Pile other);
/** /**
* Moves cards from another pile to this pile, whether or not the tryMove is valid. * Moves cards from another pile to this pile, whether or not the tryMove is
* valid.
*/ */
void moveFromBlindly(Pile other, int numCards); void moveFromBlindly(Pile other, int numCards);

View File

@ -21,8 +21,7 @@ public class Tableau extends AbstractPile {
private void countAddedCard(Card card) { private void countAddedCard(Card card) {
if (isEmpty() || orderStack.isEmpty()) { if (isEmpty() || orderStack.isEmpty()) {
orderStack.push(1); orderStack.push(1);
} else if (card.color != topCard().color && } else if (card.color != topCard().color && card.rank.value == topCard().rank.value - 1) {
card.rank.value == topCard().rank.value - 1) {
orderStack.push(orderStack.pop() + 1); orderStack.push(orderStack.pop() + 1);
} else { } else {
orderStack.push(1); orderStack.push(1);

View File

@ -6,9 +6,12 @@ import java.util.Map;
/** /**
* Maps a pair of coordinates to an object. * Maps a pair of coordinates to an object.
* *
* @param <K1> the first coordinate * @param <K1>
* @param <K2> the second coordinate * the first coordinate
* @param <V> the treasure * @param <K2>
* the second coordinate
* @param <V>
* the treasure
*/ */
public class DoubleKeyedMap<K1, K2, V> { public class DoubleKeyedMap<K1, K2, V> {

View File

@ -41,8 +41,7 @@ public class CascadingPileView extends PileView {
int multiplier = ((Tableau) pile).topInOrder(); int multiplier = ((Tableau) pile).topInOrder();
int heightOfRect = (multiplier - 1) * CARD_MARGIN; int heightOfRect = (multiplier - 1) * CARD_MARGIN;
gc.setFill(highlight); gc.setFill(highlight);
gc.fillRect(x, yCurrent - heightOfRect, Card.width, heightOfRect gc.fillRect(x, yCurrent - heightOfRect, Card.width, heightOfRect + Card.height);
+ Card.height);
} }
} }
} }