Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6bec5c5
Added suits enumerator
tomaszFijalkowski Sep 4, 2018
2360b73
shuffling cards
WeronikaDebowska Sep 4, 2018
3e65a53
Merge pull request #2 from tomaszFijalkowski/newGame
WeronikaDebowska Sep 4, 2018
af39189
dealing cards on tableau
EwelinaKi Sep 4, 2018
3ad6dac
Merge branch 'newGame' of github.com:tomaszFijalkowski/javase-klondik…
EwelinaKi Sep 4, 2018
a2cb3a2
Merge pull request #1 from tomaszFijalkowski/enums
EwelinaKi Sep 4, 2018
e422609
Converted card ranks and suits to enumerators
tomaszFijalkowski Sep 4, 2018
d2e6a04
Merge pull request #3 from tomaszFijalkowski/enums
tomaszFijalkowski Sep 4, 2018
1c247ba
Merge pull request #4 from tomaszFijalkowski/newGame
EwelinaKi Sep 4, 2018
e41817d
covered cards unundraggable
WeronikaDebowska Sep 4, 2018
f4db56e
cards at the top of tableau piles flip automatically
WeronikaDebowska Sep 4, 2018
6d2e132
cards flipping properly
WeronikaDebowska Sep 4, 2018
729569b
code refactor and card drop bugfix
EwelinaKi Sep 4, 2018
912598b
Merge pull request #5 from tomaszFijalkowski/newGame
tomaszFijalkowski Sep 4, 2018
69287bc
Added getColour() to Suits
tomaszFijalkowski Sep 5, 2018
f15351f
Added Tableau placing validation
tomaszFijalkowski Sep 5, 2018
c0306f5
Resolved conflict
tomaszFijalkowski Sep 5, 2018
0ea502f
Merge pull request #6 from tomaszFijalkowski/moves
WeronikaDebowska Sep 5, 2018
39451c9
flipping cards once again
WeronikaDebowska Sep 5, 2018
1d3a397
a bit of refactoring
WeronikaDebowska Sep 5, 2018
48e2e8f
regulate placing cards on foundation piles
EwelinaKi Sep 5, 2018
ff569e1
Merge pull request #7 from tomaszFijalkowski/foundation
tomaszFijalkowski Sep 5, 2018
78011aa
Update Game.java
EwelinaKi Sep 5, 2018
99eae4b
flipping cards extracted to separate method
WeronikaDebowska Sep 5, 2018
ac62d43
testing2
WeronikaDebowska Sep 5, 2018
24ce203
probably working gamelogic
WeronikaDebowska Sep 5, 2018
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
46 changes: 20 additions & 26 deletions src/com/codecool/klondike/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

public class Card extends ImageView {

private int suit;
private int rank;
private Suits suit;
private Ranks rank;
private boolean faceDown;

private Image backFace;
Expand All @@ -23,7 +23,7 @@ public class Card extends ImageView {
public static final int WIDTH = 150;
public static final int HEIGHT = 215;

public Card(int suit, int rank, boolean faceDown) {
public Card(Suits suit, Ranks rank, boolean faceDown) {
this.suit = suit;
this.rank = rank;
this.faceDown = faceDown;
Expand All @@ -34,14 +34,18 @@ public Card(int suit, int rank, boolean faceDown) {
setEffect(dropShadow);
}

public int getSuit() {
public Suits getSuit() {
return suit;
}

public int getRank() {
public Ranks getRank() {
return rank;
}

public int getRankNumber() {
return Integer.parseInt(rank.getNumber());
}

public boolean isFaceDown() {
return faceDown;
}
Expand Down Expand Up @@ -88,39 +92,29 @@ public static boolean isSameSuit(Card card1, Card card2) {

public static List<Card> createNewDeck() {
List<Card> result = new ArrayList<>();
for (int suit = 1; suit < 5; suit++) {
for (int rank = 1; rank < 14; rank++) {
for (Suits suit : Suits.values()) {
for (Ranks rank : Ranks.values()) {
result.add(new Card(suit, rank, true));
}
}

Collections.shuffle(result);
return result;
}


public static void loadCardImages() {
cardBackImage = new Image("card_images/card_back.png");
String suitName = "";
for (int suit = 1; suit < 5; suit++) {
switch (suit) {
case 1:
suitName = "hearts";
break;
case 2:
suitName = "diamonds";
break;
case 3:
suitName = "spades";
break;
case 4:
suitName = "clubs";
break;
}
for (int rank = 1; rank < 14; rank++) {
String cardName = suitName + rank;
for (Suits suit : Suits.values()) {
String suitName = suit.getName();
for (Ranks rank : Ranks.values()) {
String rankNumber = rank.getNumber();
String cardName = suitName + rankNumber;
String cardId = "S" + suit + "R" + rank;
String imageFileName = "card_images/" + cardName + ".png";
cardFaceImages.put(cardId, new Image(imageFileName));
}
}
}

}
Loading