Exemplo n.º 1
0
/*
 * Draw a cell on the board.
 */
static void
drawcell(POS pos)
{
    GR_COORD	x;
    GR_COORD	y;
    GR_SIZE		chwidth;
    GR_SIZE		chheight;
    GR_SIZE		chbase;
    CELL		cell;
    GR_CHAR		ch;

    cell = board[pos];
    if (!isknown(cell))
        return;

    ch = displaychar(cell);
    if (ch == F_WRONG) {
        drawbomb(pos, greengc, GR_FALSE);
        return;
    }

    if (isold(cell)) {
        clearcell(pos);
        cellcenter(pos, &x, &y);
        GrGetGCTextSize(boardgc, &ch, 1, GR_TFASCII, &chwidth,
                        &chheight, &chbase);
        GrText(boardwid, boardgc, x - chwidth / 2 + 1,
               y + chheight / 2, &ch, 1, GR_TFBOTTOM);
        return;
    }

    drawbomb(pos, redgc, GR_FALSE);
}
Exemplo n.º 2
0
void sngpos_(char *lv, int * ndec, int * nclust, char *lvaux)
{
    int i, k,ln[2];
    int ierr[2];
    char lvaux_cp[2][10];

    if (lv[0] == 1 && lv[1] == 2 && lv[2] == 0 && nin_int == 2) 
    {
	lvaux[0] = 0;
	*ndec = 0;
	*nclust = 0;
	return; 
    }
    
    for (i = 0; i < nout_int - 1; ++i)
    {  
      for (k = 0; k < 2; k++) 
      {
         ierr[k]=lvdiff_(lv,kinmtc_1[i].lvout[k],lvaux_cp[k]);
         if (!ierr[k]) ierr[k] = !isknown(lvaux_cp[k],i+1); 
         if (!ierr[k]) ln[k]=strlen(kinmtc_1[i].lvout[k])+strlen(lvaux_cp[k]);
      } 
      if (! (ierr[0]&&ierr[1]) )  
      {
         *ndec = i+1;
         if((!ierr[0]) && (!ierr[1])) k=(ln[0]<ln[1])? 1:2;
         else k=ierr[0]?2:1;
         *nclust = k;
         strcpy( lvaux,lvaux_cp[k-1]);
         return;
      }
    }
    printf("error in sngpos_\n"); sortie(51);
}
Exemplo n.º 3
0
/*
 * Remember or forget the location of a mine.
 * This is for informational purposes only and does not affect anything.
 */
static void
togglecell(POS pos)
{
    CELL	cell;

    if ((pos <= 0) || !playing)
        return;

    cell = board[pos];
    if (isknown(cell)) {
        if (!isseen(cell))
            return;
        board[pos] = (board[pos] & F_FLAGS) | F_EMPTY;
        clearcell(pos);
        return;
    }

    board[pos] = (board[pos] & F_FLAGS) | F_REMEMBER;
    drawcell(pos);
}