summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-03-29 17:51:43 -0400
committerJune McEnroe <june@causal.agency>2019-03-29 17:51:43 -0400
commit588702418fb14c36bee9c2ca5c0164a65f889ed8 (patch)
treedb6fb1a6816caa3cf8e97e15d1a35d0e3695069b
parentChange king face direction (diff)
downloadwep-588702418fb14c36bee9c2ca5c0164a65f889ed8.tar.gz
wep-588702418fb14c36bee9c2ca5c0164a65f889ed8.zip
Add king win face
-rw-r--r--freecell.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/freecell.c b/freecell.c
index ea7b8b6..2d1b97c 100644
--- a/freecell.c
+++ b/freecell.c
@@ -69,6 +69,13 @@ static void gameDeal(void) {
 	kingFace = Cards_KingRight;
 }
 
+static bool gameWin(void) {
+	for (uint i = Foundation1; i <= Foundation4; ++i) {
+		if (stacks[i].len != 13) return false;
+	}
+	return true;
+}
+
 static bool gameFind(uint *stack, uint *index, Card card) {
 	for (*stack = 0; *stack < StacksLen; ++*stack) {
 		for (*index = 0; *index < stacks[*stack].len; ++*index) {
@@ -156,13 +163,17 @@ enum {
 
 	TableauX = StackMarginX,
 	TableauY = CellY + CardHeight + StackMarginY,
-
 	FanDownDeltaY = 17,
 
+	KingWinMarginX = 10,
+	KingWinMarginY = 10,
+	KingWinX = KingWinMarginX,
+	KingWinY = CellY + CardHeight + KingWinMarginY,
+	KingWinWidth = 320,
+	KingWinHeight = 320,
+
 	WindowWidth = 8 * CardWidth + 9 * StackMarginX + 1,
-	WindowHeight = TableauY + CardHeight
-		+ 13 * FanDownDeltaY
-		+ StackMarginY,
+	WindowHeight = KingWinY + KingWinHeight + KingWinMarginY,
 };
 
 static const struct Style FanDown = { 1, 0, 0, 0, FanDownDeltaY };
@@ -316,11 +327,16 @@ static void renderOutlines(void) {
 static void renderKing(SDL_Texture *textures[]) {
 	SDL_Rect box = { KingX, KingY, KingWidth, KingHeight };
 	renderOutline(box, true);
-	SDL_Rect king = {
-		KingX + KingPadX, KingY + KingPadY,
-		Cards_KingWidth, Cards_KingHeight,
-	};
-	SDL_RenderCopy(render, textures[kingFace], NULL, &king);
+	if (gameWin()) {
+		SDL_Rect king = { KingWinX, KingWinY, KingWinWidth, KingWinHeight };
+		SDL_RenderCopy(render, textures[Cards_KingWin], NULL, &king);
+	} else {
+		SDL_Rect king = {
+			KingX + KingPadX, KingY + KingPadY,
+			Cards_KingWidth, Cards_KingHeight,
+		};
+		SDL_RenderCopy(render, textures[kingFace], NULL, &king);
+	}
 }
 
 static void renderList(SDL_Texture *textures[], const struct List *list) {