about summary refs log tree commit diff
path: root/freecell.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--freecell.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/freecell.c b/freecell.c
index 178da57..ea7b8b6 100644
--- a/freecell.c
+++ b/freecell.c
@@ -49,6 +49,8 @@ enum {
 
 static struct Stack stacks[StacksLen];
 
+static uint kingFace = Cards_KingRight;
+
 static void gameDeal(void) {
 	for (uint i = 0; i < StacksLen; ++i) {
 		stackClear(&stacks[i]);
@@ -64,6 +66,7 @@ static void gameDeal(void) {
 	for (uint i = Tableau5; i <= Tableau8; ++i) {
 		stackMoveTo(&stacks[i], &deck, 6);
 	}
+	kingFace = Cards_KingRight;
 }
 
 static bool gameFind(uint *stack, uint *index, Card card) {
@@ -90,11 +93,13 @@ static bool gameMove(uint dest, Card card) {
 	if (source == dest) return false;
 	if (dest >= Cell1 && dest <= Cell4) {
 		if (stacks[dest].len) return false;
+		kingFace = Cards_KingLeft;
 	}
 	if (dest >= Foundation1 && dest <= Foundation4) {
 		if (!destTop && cardRank(card) != Cards_A) return false;
 		if (destTop && cardSuit(card) != cardSuit(destTop)) return false;
 		if (destTop && cardRank(card) != cardRank(destTop) + 1) return false;
+		kingFace = Cards_KingRight;
 	}
 	if (dest >= Tableau1 && dest <= Tableau8) {
 		if (destTop && cardColor(card) == cardColor(destTop)) return false;
@@ -315,8 +320,7 @@ static void renderKing(SDL_Texture *textures[]) {
 		KingX + KingPadX, KingY + KingPadY,
 		Cards_KingWidth, Cards_KingHeight,
 	};
-	// TODO: Determine king direction.
-	SDL_RenderCopy(render, textures[Cards_KingRight], NULL, &king);
+	SDL_RenderCopy(render, textures[kingFace], NULL, &king);
 }
 
 static void renderList(SDL_Texture *textures[], const struct List *list) {