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) {
nroe 2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe 2021-01-12Split fields by tab onlyJune McEnroe 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe 2021-01-09Add c -t flag to print expression typeJune McEnroe 2021-01-05Update taglineJune McEnroe