static char * card_to_string(Card card, char * buf) { rank_to_string(card&0x0F,buf); suit_to_string(card>>4,buf+1); return buf; }
char * fc_solve_fc_pro_position_to_string(Position * pos, int num_freecells) { int a, stack; char buffer[4000], temp[4][20]; char * s_end; buffer[0] = '\0'; s_end = buffer; for(a=0;a<4;a++) { if (pos->foundations[a] != 0) { break; } } if (a < 4) { s_end += sprintf(s_end, "Foundations:"); for(a=0;a<4;a++) { if (pos->foundations[a] != 0) { s_end += sprintf( s_end, " %s-%s", suit_to_string(a, temp[0]), rank_to_string(pos->foundations[a], temp[1]) ); } } *s_end = '\n'; s_end++; } s_end += sprintf(s_end, "Freecells:"); for(a=0;a<num_freecells;a++) { if (pos->hold[a] == 0) { s_end += sprintf(s_end, " -"); } else { s_end += sprintf(s_end, " %s", card_to_string(pos->hold[a], temp[0])); } } *s_end = '\n'; s_end++; for(stack=0;stack<8;stack++) { for(a=0;a<pos->tableau[stack].count;a++) { s_end += sprintf( s_end, "%s%s", ((a == 0)? "" : " "), card_to_string(pos->tableau[stack].cards[a], temp[0]) ); } *s_end = '\n'; s_end++; } *s_end = '\0'; return strdup(buffer); }
std::string card_to_string() { return "[" + rank_to_string(card_rank) + "~" + color_to_string(card_color) + "]" + Enter(); }