home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / top2src.zip / GAMES.ZIP / POKERSYS.C < prev    next >
C/C++ Source or Header  |  1995-05-05  |  3KB  |  113 lines

  1. #include "top.h"
  2.  
  3. XINT poker_getplayernum(char gpntype, XINT gpnnode, poker_game_typ *gpngame)
  4.     {
  5.     XINT gpnd;
  6.  
  7.     for (gpnd = 0; gpnd < gpngame->maxpl; gpnd++)
  8.         {
  9.         if ((gpntype == POKPL_WAITING || gpntype == POKPL_JOINED) &&
  10.             gpngame->wanttoplay[gpnd] == gpnnode)
  11.             {
  12.             return gpnd;
  13.             }
  14.         if ((gpntype == POKPL_PLAYING || gpntype == POKPL_JOINED) &&
  15.             gpngame->player[gpnd].node == gpnnode)
  16.             {
  17.             return gpnd;
  18.             }
  19.         }
  20.  
  21.     return -1;
  22.     }
  23.  
  24. XINT poker_gethighplayer(char ghptype, poker_game_typ *ghpgame)
  25.     {
  26.     XINT ghpd;
  27.  
  28.     for (ghpd = ghpgame->maxpl - 1; ghpd >= 0; ghpd--)
  29.         {
  30.         if ((ghptype == POKPL_WAITING || ghptype == POKPL_JOINED) &&
  31.             ghpgame->wanttoplay[ghpd] >= 0)
  32.             {
  33.             return ghpd;
  34.             }
  35.         if ((ghptype == POKPL_PLAYING || ghptype == POKPL_JOINED) &&
  36.             ghpgame->player[ghpd].node >= 0)
  37.             {
  38.             return ghpd;
  39.             }
  40.         }
  41.  
  42.     return -1;
  43.     }
  44.  
  45. void poker_displayhand(poker_game_typ *dhgame, char *dhhand)
  46.     {
  47.     XINT dhd;
  48.     unsigned char ltname[41];
  49.  
  50.     top_output(OUT_SCREEN, getlang("PokerDispHandPref"));
  51.  
  52.     for (dhd = 0; dhd < dhgame->numcards; dhd++)
  53.         {
  54.         top_output(OUT_SCREEN, getlang("PokerDispCardPref"));
  55.  
  56.         itoa(pokerdefcardsuits[dhhand[dhd]] + 1, outnum[0], 10);
  57.         sprintf(ltname, "CardShrtColour%s", outnum[0]);
  58.         top_output(OUT_SCREEN, getlang(ltname));
  59.  
  60.         itoa(pokerdefcardvals[dhhand[dhd]], outnum[0], 10);
  61.         sprintf(ltname, "CardShrtSngValue%s", outnum[0]);
  62.         top_output(OUT_SCREEN, getlang(ltname));
  63.  
  64.         itoa(pokerdefcardsuits[dhhand[dhd]] + 1, outnum[0], 10);
  65.         // Change A below to check for IBM ASCII pref...
  66.         sprintf(ltname, "CardShrtSngSuit%c%s", 'A', outnum[0]);
  67.         top_output(OUT_SCREEN, getlang(ltname));
  68.  
  69.         top_output(OUT_SCREEN, getlang("PokerDispCardSuf"));
  70.         }
  71.  
  72.     top_output(OUT_SCREEN, getlang("PokerDispHandSuf"));
  73.  
  74.     }
  75.  
  76. void poker_endgamedisplay(poker_game_typ *egame)
  77.     {
  78.     XINT egd, xxq, maxnamlen; ///!!! this func!
  79.  
  80.     for (egd = 0, maxnamlen = 0; egd < MAXNODES; egd++)
  81.         {
  82.         if (egame->player[egd].node > -1)
  83.             {
  84.             if (strlen(handles[egd].string) > maxnamlen)
  85.                 {
  86.                 maxnamlen = strlen(handles[egd].string);
  87.                 }
  88.             }
  89.         }
  90.     top_output(OUT_SCREEN, getlang("PokerHandsWere"));
  91.     for (egd = 0; egd < egame->maxpl; egd++)
  92.         {
  93.         if (egame->player[egd].node > -1)
  94.             {
  95.             sprintf(outbuf, "^l%*s  ", maxnamlen,
  96.                     handles[egame->player[egd].node].string);
  97.             top_output(OUT_SCREEN, outbuf);
  98.             poker_displayhand(egame, egame->player[egd].cards);
  99.             top_output(OUT_SCREEN, " ");
  100.             xxq = wherex();
  101.             top_output(OUT_SCREEN,
  102.                        poker_getshortname(egame, egame->player[egd].cards));
  103.             od_repeat(' ', 20 - (wherex() - xxq));
  104.             if (egame->winners[egd])
  105.                 {
  106.                 top_output(OUT_SCREEN, "  ^I^k<-- Winner!^A^h");
  107.                 }
  108.             top_output(OUT_SCREEN, "\r\n");
  109.             }
  110.         }
  111.  
  112.     }
  113.