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 cff2570609efa4fed3ba1c40a0773883c8bfa372 parent fdf888ea996c0fd1652ca7c164fe7ea5c4b7c460 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Tue, 21 Jan 2025 17:42:07 +0100 On passe la liste des piles à display Moins d'arguments Par contre c'est trop chiant à indexer dans display donc faut que je regarde du côté des enums là Diffstat:
M | interface.c | | | 52 | ++++++++++++++++++++++++++-------------------------- |
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/interface.c b/interface.c @@ -115,53 +115,53 @@ pile file2pile(char* filename) { } -void display(pile* h, pile* p, pile* a, pile* curmenu, bool selection, char* cmd, char* res, char* intern) { +void display(pile** piles, pile curmenu, bool selection, char* cmd, char* res, char* intern) { tb_clear(); int i; int j; int w; - int biggestpile=max(p->cardCount,h->cardCount)+a->cardCount; - for (i=0;i<h->cardCount;i++) { - if (i==h->curline && curmenu->name=="hand") { + int biggestpile=max(piles[1]->cardCount,piles[0]->cardCount)+piles[2]->cardCount; + for (i=0;i<piles[0]->cardCount;i++) { + if (i==piles[0]->curline && curmenu.name=="hand") { if (selection) { - tb_printf(0, i, TB_BLACK, TB_BLUE, h->cards[i]); + tb_printf(0, i, TB_BLACK, TB_BLUE, piles[0]->cards[i]); } else { - tb_printf(0, i, TB_BLACK, TB_WHITE, h->cards[i]); + tb_printf(0, i, TB_BLACK, TB_WHITE, piles[0]->cards[i]); } } - else { tb_printf(0, i, TB_DEFAULT, TB_BLACK, h->cards[i]); } + else { tb_printf(0, i, TB_DEFAULT, TB_BLACK, piles[0]->cards[i]); } } - for (j=0;j<p->cardCount;j++) { - if (j==p->curline && curmenu->name=="played") { + for (j=0;j<piles[1]->cardCount;j++) { + if (j==piles[1]->curline && curmenu.name=="played") { if (selection) { - tb_printf(CARD_NAME_SIZE+2, j, TB_BLACK, TB_BLUE, p->cards[j]); + tb_printf(CARD_NAME_SIZE+2, j, TB_BLACK, TB_BLUE, piles[1]->cards[j]); } else { - tb_printf(CARD_NAME_SIZE+2, j, TB_BLACK, TB_WHITE, p->cards[j]); + tb_printf(CARD_NAME_SIZE+2, j, TB_BLACK, TB_WHITE, piles[1]->cards[j]); } } - else { tb_printf(CARD_NAME_SIZE+2, j, TB_DEFAULT, TB_BLACK, p->cards[j]); } + else { tb_printf(CARD_NAME_SIZE+2, j, TB_DEFAULT, TB_BLACK, piles[1]->cards[j]); } } - for (j=0;j<a->cardCount;j++) { - if (j==a->curline && curmenu->name=="args") { + for (j=0;j<piles[2]->cardCount;j++) { + if (j==piles[2]->curline && curmenu.name=="args") { if (selection) { - tb_printf(0, biggestpile+j, TB_BLACK, TB_BLUE, a->cards[j]); + tb_printf(0, biggestpile+j, TB_BLACK, TB_BLUE, piles[2]->cards[j]); } else { - tb_printf(0,biggestpile+j, TB_BLACK, TB_WHITE, a->cards[j]); + tb_printf(0,biggestpile+j, TB_BLACK, TB_WHITE, piles[2]->cards[j]); } } - else { tb_printf(0,biggestpile+j, TB_DEFAULT, TB_BLACK, a->cards[j]); } + else { tb_printf(0,biggestpile+j, TB_DEFAULT, TB_BLACK, piles[2]->cards[j]); } } - for (int w=0;w<biggestpile+a->cardCount;w++) { + for (int w=0;w<biggestpile+piles[2]->cardCount;w++) { tb_printf(CARD_NAME_SIZE,w,TB_DEFAULT, TB_BLACK, "|"); } - tb_printf(0, biggestpile+1+a->cardCount, TB_DEFAULT, TB_BLACK, cmd); - hr(biggestpile+1+a->cardCount+p->cardCount); - tb_printf(0, biggestpile+1+a->cardCount+p->cardCount+1+a->cardCount, TB_DEFAULT, TB_BLACK, res); + tb_printf(0, biggestpile+1+piles[2]->cardCount, TB_DEFAULT, TB_BLACK, cmd); + hr(biggestpile+1+piles[2]->cardCount+piles[1]->cardCount); + tb_printf(0, biggestpile+1+piles[2]->cardCount+piles[1]->cardCount+1+piles[2]->cardCount, TB_DEFAULT, TB_BLACK, res); int l=0; l=nblines(res); - hr(biggestpile+1+a->cardCount+p->cardCount+1+a->cardCount+l); - tb_printf(0, biggestpile+1+a->cardCount+p->cardCount+2+l, TB_DEFAULT, TB_BLACK, intern); - tb_printf(0,30,TB_DEFAULT,TB_DEFAULT,curmenu->name); - char str[100];sprintf(str,"%d",curmenu->cardCount); + hr(biggestpile+1+piles[2]->cardCount+piles[1]->cardCount+1+piles[2]->cardCount+l); + tb_printf(0, biggestpile+1+piles[2]->cardCount+piles[1]->cardCount+2+l, TB_DEFAULT, TB_BLACK, intern); + tb_printf(0,30,TB_DEFAULT,TB_DEFAULT,curmenu.name); + char str[100];sprintf(str,"%d",curmenu.cardCount); tb_printf(0,31,TB_DEFAULT,TB_DEFAULT,str); tb_present(); } @@ -194,7 +194,7 @@ int main(int argc, char **argv) { updatecmd(cmd, played); updateres(res, cmd, fp2); updateinterncmd(intern, played); - display(&hand,&played,&args,curmenu,selection,cmd,res,intern); + display(piles,*curmenu,selection,cmd,res,intern); tb_poll_event(&ev); switch(ev.key) { /* up */