Un jeu de cartes à piper les une dans les autres - retour accueil
git clone git://bebou.netlib.re/pipe-game
Log | Files | Refs | README |
commit d449248b5e7f851f1ffdc46460468b107e84598f parent 4636af8bcb33a875bd90a1e77310d52f929b1394 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Tue, 21 Jan 2025 11:24:10 +0100 Bon affichage des commandes et résultats Avant on décalait du nombre de cartes, maintenant du vrai nombre de lignes dans les cartes Diffstat:
M | interface.c | | | 11 | ++++++++++- |
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/interface.c b/interface.c @@ -18,6 +18,12 @@ typedef struct int max(int a, int b) { return a > b ? a : b; } +int nblines(char *str) { + int l=0; + for (int i = 0; str[i] != '\0'; i++) { if (str[i]=='\n') { l++; } } + return l; +} + void addcardtopile(char* cardname, pile* p) { p->cards[p->cardCount] = malloc(CARD_NAME_SIZE); strcpy(p->cards[p->cardCount], cardname); @@ -121,12 +127,15 @@ void display(pile* h, pile* p, int handcurline, int playedcurline, char* curmenu } else { tb_printf(CARD_NAME_SIZE+2, j, TB_DEFAULT, TB_BLACK, p->cards[j]); } } + int l=0; + l=nblines(res); tb_printf(0, biggestpile+1, TB_DEFAULT, TB_BLACK, cmd); tb_printf(0, biggestpile+1+p->cardCount+1, TB_DEFAULT, TB_BLACK, res); - tb_printf(0, biggestpile+1+p->cardCount*2+1, TB_DEFAULT, TB_BLACK, intern); + tb_printf(0, biggestpile+1+p->cardCount+2+l, TB_DEFAULT, TB_BLACK, intern); tb_present(); } + int main(int argc, char **argv) { struct tb_event ev;