From 1a55403d9de86cd4a4af2b5c017c01365778bccd Mon Sep 17 00:00:00 2001
From: quenousimporte <quenousimporte@riseup.net>
Date: Sun, 30 Mar 2025 10:53:05 +0200
Subject: [PATCH] refactor add macros add readme update map

---
 w/readme.md |   4 ++
 w/w.c       | 103 ++++++++++++++++++++++++++++++++++++++++------------
 w/w.map     |  12 +++---
 3 files changed, 89 insertions(+), 30 deletions(-)
 create mode 100644 w/readme.md

diff --git a/w/readme.md b/w/readme.md
new file mode 100644
index 0000000..140f966
--- /dev/null
+++ b/w/readme.md
@@ -0,0 +1,4 @@
+mac: ‘gcc -std=c99 w.c‘
+windows: launch chcp 65001 before
+
+
diff --git a/w/w.c b/w/w.c
index 3f0cd04..b752ac5 100644
--- a/w/w.c
+++ b/w/w.c
@@ -1,27 +1,28 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <stdbool.h>
 
 #define CMD_LEN 	10
 #define NAME_LEN 	10
 #define POV_3D_SIZE 10
 #define POV_SIZE 	3
+#define NULL_CMD	"-"
 
 #define PLACE_TITLE		0
-#define PLACE_STATION	1
-#define PLACE_MAP		2
+#define PLACE_SETNAME	1
+#define PLACE_STATION	2
+#define PLACE_MAP		3
 
 typedef struct {
 	int x;
 	int y;
 	char orientation;
-} Location;
+} Location; // rename position
 
 typedef struct {
 	char name[NAME_LEN];
 	Location location;
-	char place;
+	char place; // rename screen
 } Gamestate;
 
 const char* statepath = "w.state";
@@ -212,14 +213,14 @@ void update3dpov()
 		}
 	}
 
-	const char doorchar = 177;
+	const char doorchar = '#';
 	if (pov[1][1] == 'd')
 	{
 		// front door
 		for (int i = 4; i <= 7; i++)
 		{
 			for (int j = 3; j < 7; j++)
-			pov3d[i][j] = doorchar;
+				pov3d[i][j] = doorchar;
 		}
 	}
 	if (pov[2][0] == 'd')
@@ -342,7 +343,6 @@ void clearscreen()
 {
 #ifdef _WIN32
 	system("cls");
-	// launch chcp 65001 before
 #else
 	system("clear");
 #endif
@@ -385,6 +385,13 @@ void update(char command[CMD_LEN])
 		updatepov();
 	}
 	else if (state.place == PLACE_TITLE)
+	{
+		if (strcmp(command, NULL_CMD) != 0)
+		{
+			state.place = PLACE_SETNAME;
+		}
+	}
+	else if (state.place == PLACE_SETNAME)
 	{
 		if (strlen(command) > 0)
 		{
@@ -408,44 +415,92 @@ void update(char command[CMD_LEN])
 void draw()
 {
 	clearscreen();
-
+	
+	int screenwidth = 30;
+	for (int i = 0; i < screenwidth; i++) printf("-");
+	printf("\n");
+	
 	if (state.place == PLACE_TITLE)
 	{
-		printf("\n\n      La légende des dongeons de l'espace\n\n\n");
-		printf("Bonjour.\n");
-		printf("Bienvenue la station spaciale intergalactique.\n");
-		printf("Veuillez saisir votre nom:\n");
-		printf("> ");
-
+		printf("        _        _\n");
+		printf("       / /      / /\n");
+		printf("      / /      / /\n");
+		printf("     / /__a   / /__égende\n");
+		printf("    |____/   |____/\n");
+		printf("\n");
+		printf("        du  ___\n");
+		printf("           / _ \\ \n");
+		printf("          / / | |\n");
+		printf("         / /_/ /ongeon\n");
+		printf("        /____ /\n");
+		printf("\n");
+		printf("          _____\n");
+		printf("   de l' / ___/\n");
+		printf("        / /_\n");
+		printf("       / /___space\n");
+		printf("      /_____/\n");
+	}
+	else if (state.place == PLACE_SETNAME)
+	{
+		printf("Bonjour.\n\n");
+		printf("Bienvenue à la station\n");
+		printf("spaciale intergalactique.\n\n");
+		printf("Veuillez saisir votre nom.\n");
 	}
 	else if (state.place == PLACE_MAP)
 	{
-		int shift = 5;
-		for (int i = 0; i < shift; i++) printf("\n");
-
+		int shift = 9;
 		for (int i = 0; i < shift; i++) printf(" ");
 		printf("o----------o\n");
 
-		for (int i = 0; i < 10; i++)
+		for (int i = 0; i < POV_3D_SIZE; i++)
 		{
 			for (int s = 0; s < shift; s++) printf(" ");
 			printf("|");
-			for (int j = 0; j < 10; j++)
+			for (int j = 0; j < POV_3D_SIZE; j++)
 			{
 				printf("%c", pov3d[i][j]);
 			}
 			printf("|\n");
 		}
 		for (int i = 0; i < shift; i++) printf(" ");
-		printf("o----------o\n\n");
+		printf("o----------o");
 
+		if (charatpos(state.location.x, state.location.y) == 's')
+		{
+			// dessiner un hublot au plafond (dans updatepov3d)
+			printf("\n\nr: Retour à la station\n");
+		}
+		else 
+		{
+			printf("\n               ^\n");
+			printf("            <w s x>\n");
+		}
 		//drawmap();
 	}
 	else if (state.place == PLACE_STATION)
 	{
-		printf("%s est à la station intergalactique.\n\n", state.name);
-		printf("n: prendre la navette pour le dongeon de l'espace\n");
+		printf("\n");
+		printf("      STATION  SPACIALE\n");
+		printf("       INTERGALACTIQUE\n");
+		printf("\n");
+
+		printf("n: Prendre la navette\n");
 	}
+
+	if (state.place == PLACE_STATION || state.place == PLACE_MAP)
+	{
+		printf("\n");
+		for (int i = 0; i < screenwidth; i++) printf("-");
+		printf("\n");
+		printf("%s | PV:10 | CG:0 | PSI:0", state.name);
+
+	}
+
+	printf("\n");
+	for (int i = 0; i < screenwidth; i++) printf("-");
+	printf("\n> ");
+	
 }
 
 void drawtopdownpov()
@@ -481,7 +536,7 @@ int main()
 {
 	init();
 
-	char command[CMD_LEN] = "";
+	char command[CMD_LEN] = NULL_CMD;
 
 	while (command[0] != 'q')
 	{
diff --git a/w/w.map b/w/w.map
index 46d214e..cadf0a9 100644
--- a/w/w.map
+++ b/w/w.map
@@ -1,14 +1,14 @@
 wwwwwwwwwwwwwww
 w             w
 w wwwww wwwww w
+w w w d w   w w
 w w w w w   w w
-w w wdw w   w w
 w w   w w   w w
-wdw   wdw     w
-w d     wwwww w
-wwwwwwwww   w w
-w           w w
-w           w w
+wdwwwwwdw     w
+w   w w wwwwwdw
+w   www     w w
+ws  w       w w
+wwwwwww     w w
 w           w w
 w           w w
 w           d w