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 4636af8bcb33a875bd90a1e77310d52f929b1394 parent 6080a9ef006fc561b447937f774d09d7bc167e81 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Tue, 21 Jan 2025 11:16:25 +0100 Début de l'affichage de la commande complète Bug connu, si l'une des cartes a son code sur plusieurs lignes ça bug. Mais c'est que la dernière qui n'est pas affichée ? Diffstat:
M | interface.c | | | 20 | +++++++++++++++++--- |
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/interface.c b/interface.c @@ -59,6 +59,17 @@ void updatecmd(char* cmd, const pile p) { strcat(cmd," ) 2> /dev/null"); } +void updateinterncmd(char *res, const pile p) { + if (p.cardCount == 0 ) { return; } + for(int i=0;i<p.cardCount;i++) { + FILE *fp = fopen(p.cards[i], "r"); + char line[100];line[0]='\0'; + while(fgets(line, sizeof(line), fp)) { + strcat(res, line); + } + } +} + void updateres(char *res, const char *cmd, FILE *fp) { fp = popen(cmd,"r"); char line[1000]; @@ -83,7 +94,7 @@ pile file2pile(FILE *fp) { } -void display(pile* h, pile* p, int handcurline, int playedcurline, char* curmenu,bool selection, char* cmd, char* res) { +void display(pile* h, pile* p, int handcurline, int playedcurline, char* curmenu,bool selection, char* cmd, char* res, char* intern) { tb_clear(); int i; int j; int w; int biggestpile=max(p->cardCount,h->cardCount); @@ -112,6 +123,7 @@ void display(pile* h, pile* p, int handcurline, int playedcurline, char* curmenu } 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_present(); } @@ -120,6 +132,7 @@ int main(int argc, char **argv) { FILE *fp = fopen("hand", "r"); char res[2000]; + char intern[2000]; FILE *fp2; char cmd[2000]; @@ -138,10 +151,11 @@ int main(int argc, char **argv) { char* curmenu="hand"; while(!quit) { - cmd[0]='\0';res[0]='\0'; + cmd[0]='\0';res[0]='\0';intern[0]='\0'; updatecmd(cmd, played); updateres(res, cmd, fp2); - display(h,p,hand.curline,played.curline,curmenu,selection,cmd,res); + updateinterncmd(intern, played); + display(h,p,hand.curline,played.curline,curmenu,selection,cmd,res,intern); tb_poll_event(&ev); switch(ev.key) { /* up */