Beispiel #1
0
/* ============================================================================
* Funktion:        createTableHead
* Input:           int width  Fensterbreite in Cols
* Output:          -
*
* Beschreibung:    Gibt den Tabellenkopf aus
* =============================================================================
*/
void createTableHead(int width)
{
   char borderTopSide[2], borderTopRight[2], borderTopLeft[2], borderSide[2];
   char borderTopBot[2], borderLeftSide[2], borderRightSide[2], borderCross[2];
   int i=0;

   sprintf(borderTopSide, "%c", 203);
   sprintf(borderTopRight, "%c", 187);
   sprintf(borderTopLeft, "%c", 201);
   sprintf(borderSide, "%c", 186);
   sprintf(borderTopBot, "%c", 205);
   sprintf(borderLeftSide, "%c", 204);
   sprintf(borderRightSide, "%c", 185);
   sprintf(borderCross, "%c", 206);

   /* top border */
   for(i=0;i<80;i++)
   {
      if(i==20||i==40||i==60)
      {
         printTo(((width) / 2)-40+i, 4, borderTopSide, 0 );
      }
      else
      {
         printTo(((width) / 2)-40+i, 4, borderTopBot, 0 );
      }
   }
   printTo(((width)/ 2)-40, 4, borderTopLeft, 0);
   printTo(((width)/ 2)+40, 4, borderTopRight, 0);
   createTableRow("Rank", "Username", "Score", "Time", 5, width);
   createRowSplitter(width, 6);
}
Beispiel #2
0
/* ============================================================================
* Funktion:        printBox
* Input:           int startHeight  Mindesthoehe der Box
*                  char Text[]      Ausgabetext
*
* Output:          -
*
* Beschreibung:    Gibt char Text[] in einer weiss umrandeten Box der Mindest-
*                  hoehe startHeight aus.
* =============================================================================
*/
void printBox(int startHeight, char Text[] )
{
   int i;
   char rightTopBorder[2], leftTopBorder[2], leftBottomBorder[2];
   char rightBottomBorder[2], side[2], top_bot[2];

   sprintf(leftTopBorder, "%c", 218);
   sprintf(leftBottomBorder, "%c", 192);
   sprintf(rightTopBorder, "%c", 191);
   sprintf(rightBottomBorder, "%c", 217);
   sprintf(side, "%c", 179);
   sprintf(top_bot, "%c", 196);

   printTo(40, startHeight, rightTopBorder, 0);
   printTo(10, startHeight, leftTopBorder , 0);

   for(i=0;i<29;i++)
   {
      printTo(11+i, startHeight, top_bot, 0);
   }

   printTo(10, startHeight+1, side, 0);
   printTo(12, startHeight+1, Text, 0);
   printTo(40, startHeight+1, side, 0);

   printTo(40, startHeight+2, rightBottomBorder, 0);
   printTo(10, startHeight+2, leftBottomBorder, 0);

   for(i=0;i<29;i++)
   {
      printTo(11+i, startHeight+2, top_bot, 0);
   }
}
Beispiel #3
0
/* ============================================================================
* Funktion:        LoadDifficultyMenue
* Input:           ACCOUNT user
* Output:               -
*
* Beschreibung:    Laden eines neuen Spiels bzw. Auswahl der gewuenschten
*                   Schwierigkeitsstufe.
* ============================================================================
*/
void LoadDifficultyMenue(ACCOUNT user) {
   /* Initialisierung der Variablen */
	int iStatus = 0, iTemp = 1, iLength = 0, i, m_Exit = 0;
   char *cMenu[SUDOKU_DIFFICULTIES] = { "Easy                   ", 
												"Medium                 ", 
												"Hard                   ",
												"Exit                   "
											 }
			,highLight[2];
	
	sprintf(highLight, "%c", 16);
	for (i = 0; i < SUDOKU_DIFFICULTIES; i++)
	{
		printTo((WINDOW_WIDTH-17)/2, 43+i, cMenu[i], 0);
	}
	printTo((WINDOW_WIDTH-17)/2, 47, "                         ", 0);
   printTo(((WINDOW_WIDTH-17)/2)-5, 43, highLight, 0);
   gotoxy(WINDOW_WIDTH-1,0);

   /* Bewegen der Pfeile in der Navigation */
   do
   {
		iStatus = control();

		printTo(((WINDOW_WIDTH-17)/2)-5, 42+iTemp, " ", 0);

		if (iStatus == 2) 
		{
			if (iTemp > 1) 
			{
				iTemp--;
			}
		}
		else if (iStatus == 3) 
		{
			if (iTemp < SUDOKU_DIFFICULTIES && iTemp > 0)
			{
				iTemp++;
			}
		}
		
        printTo(((WINDOW_WIDTH-17)/2)-5, 42+iTemp, highLight, 0);
        gotoxy(WINDOW_WIDTH-1,0);
   } while (iStatus != 6);

   /* Generierung des Spiels */
	if(iTemp != 4) 
   {
		generateGame(iTemp, user);
	}
	return;
}
Beispiel #4
0
/* ============================================================================
* Funktion:        closingRow
* Input:           int height   Zeilenhohe
*                  int width    Zeilenbreite
* Output:          -
*
* Beschreibung:    Gibt die Schlusszeile der Tabelle aus
* =============================================================================
*/
void closingRow(int height, int width)
{
   char borderBottomSide[2], borderBottomRight[2], borderBottomLeft[2];

   sprintf(borderBottomSide, "%c", 202);
   sprintf(borderBottomRight, "%c", 188);
   sprintf(borderBottomLeft, "%c", 200);

   printTo(((width)/ 2)-20, height, borderBottomSide, 0 );
   printTo(((width)/ 2), height, borderBottomSide, 0 );
   printTo(((width)/ 2)+20, height, borderBottomSide, 0);

   printTo(((width)/ 2)-40, height, borderBottomLeft, 0);
   printTo(((width)/ 2)+40, height, borderBottomRight, 0);
}
String JsonVariant::as<String>() const {
  String s;
  if ((_type == JSON_STRING || _type == JSON_UNPARSED) &&
      _content.asString != NULL)
    s = _content.asString;
  else
    printTo(s);
  return s;
}
Beispiel #6
0
/* ============================================================================
* Funktion:        createTableRow
* Input:           char col1[], char col2[], char col3[], char col4[]
*                     -> Inhalte der Spalten
*                  int height   Zeilenhohe
*                  int width    Zeilenbreite
* Output:          -
*
* Beschreibung:    Gibt eine befuellte Tabellenzeile aus
* =============================================================================
*/
void createTableRow(char col1[], char col2[], char col3[], char col4[],
                    int height, int width)
{
	char borderSide[2];

   sprintf(borderSide, "%c", 186);
   printTo(((width) / 2)-40, height, borderSide, 0 );
   printTo(((width) / 2)-35, height, col1, 0 );
   printTo(((width) / 2)-20, height, borderSide, 0 );
   printTo(((width) / 2)-15, height, col2, 0);
   printTo(((width) / 2), height, borderSide, 0 );
   printTo(((width) / 2)+5, height, col3, 0 );
   printTo(((width) / 2)+20, height, borderSide, 0 );
   printTo(((width) / 2)+25, height, col4, 0 );
   printTo(((width) / 2)+40, height, borderSide, 0 );
   createRowSplitter( width, height+1);
}
Beispiel #7
0
String IPAddress::toString() const
{
    StreamString sstr;
#if LWIP_IPV6
    if (isV6())
        sstr.reserve(40); // 8 shorts x 4 chars each + 7 colons + nullterm
    else
#endif
        sstr.reserve(16); // 4 bytes with 3 chars max + 3 dots + nullterm, or '(IP unset)'
    printTo(sstr);
    return sstr;
}
Beispiel #8
0
/* ============================================================================
* Funktion:        renderToplist
* Input:           int width    Fensterbreite in Cols
* Output:          -
*
* Beschreibung:    Gibt einen Teil der Topliste aus.
* =============================================================================
*/
void renderToplist(int width)
{
   int i = 0, k = 0;
   /* 5 - 19*/

   for (i = 20; i < ((width + 90) / 2); i++)
   {
      for (k = 1; k < 26; k++)
      {
         printTo(i, k, " ", 0);
      }
   }
}
Beispiel #9
0
String JsonVariant::as<String>() const {
  if ((_type == JSON_STRING || _type == JSON_UNPARSED) &&
      _content.asString != NULL)
    return String(_content.asString);

  if (_type == JSON_INTEGER || _type == JSON_BOOLEAN)
    return String(_content.asInteger);

  if (_type >= JSON_FLOAT_0_DECIMALS) {
    uint8_t decimals = static_cast<uint8_t>(_type - JSON_FLOAT_0_DECIMALS);
    return String(_content.asFloat, decimals);
  }

  String s;
  printTo(s);
  return s;
}
Beispiel #10
0
/* ============================================================================
* Funktion:        createRowSplitter
* Input:           int height   Zeilenhohe
*                  int width    Zeilenbreite
* Output:          -
*
* Beschreibung:    Gibt einen Zeilentrennstrich aus
* =============================================================================
*/
void createRowSplitter( int width, int height)
{
   char borderTopBot[2],borderLeftSide[2], borderRightSide[2], borderCross[2];
   int i=0;

   sprintf(borderLeftSide, "%c", 204);
   sprintf(borderRightSide, "%c", 185);
   sprintf(borderCross, "%c", 206);
   sprintf(borderTopBot, "%c", 205);
   printTo(((width)/2)-40, height, borderRightSide, 0 );
   printTo(((width)/2)+40, height, borderLeftSide, 0 );

   for(i=0;i<80;i++) {
      if(i==20||i==40||i==60) {
         printTo(((width) / 2)-40+i, height, borderCross, 0 );
      } else {
         printTo(((width) / 2)-40+i, height, borderTopBot, 0 );
      }
   }

   printTo(((width)/2)+40, height, borderRightSide, 0 );
   printTo(((width)/2)-40, height, borderLeftSide, 0 );
}
/**
 * Prints an instant from milliseconds since 1970-01-01T00:00:00Z,
 * using ISO Chronology *in the default DateTimeZone.
 *
 * @param out  the destination to format to, not NULL
 * @param instant  millis since 1970-01-01T00:00:00Z
 */
void DateTimeFormatter::printTo(stringstream &out, int64_t instant) {
    printTo(out, instant, NULL);
}
Beispiel #12
0
/* ============================================================================
* Funktion:        LoadGameMenue
* Input:           ACCOUNT user
* Output:               -
*
* Beschreibung:    Laden des Gamemenues, wenn User eingeloggt ist
* ============================================================================
*/
void LoadGameMenue(ACCOUNT user) {
   /* Initialisierung der Variablen */
	int iStatus = 0, iTemp = 1, iLength = 0, i, m_Exit = 0;
   char *cMenu[GAME_MENUE_SIZE] = { "Play Sudoku", 
												"How To Play", 
												"Top List",
												"Imprint",
												"Log Out"}
			,highLight[2];
	
	sprintf(highLight, "%c", 16);
   resizeWindow(WINDOW_WIDTH, WINDOW_HEIGHT);

	do
	{
		resizeWindow(WINDOW_WIDTH, WINDOW_HEIGHT);
		system("cls");
		createBlockView(WINDOW_WIDTH, 37);
		createBlockView(WINDOW_WIDTH, 10);
		loadMainLogo();
		printTo(((WINDOW_WIDTH-17)/2), 40, "G A M E M E N U E", 0);
		printTo(((WINDOW_WIDTH-17)/2), 41, "= = = = = = = = =", 0);
		for (i = 0; i < GAME_MENUE_SIZE; i++)
		{
                printTo((WINDOW_WIDTH-17)/2, 43+i, cMenu[i], 0);
		}
      printTo(((WINDOW_WIDTH-17)/2)-5, 42+iTemp, highLight, 0);
      gotoxy(WINDOW_WIDTH-1,0);
      
      /* Bewegen der Pfeile fuer Menuepunkte */
		do
		{
			iStatus = control();
         printTo(((WINDOW_WIDTH-17)/2)-5, 42+iTemp, " ", 0);

			if (iStatus == 2) 
			{
				if (iTemp > 1) 
				{
					iTemp--;
				}
			}
			else if (iStatus == 3) 
			{
				if (iTemp < GAME_MENUE_SIZE && iTemp > 0)
				{
					iTemp++;
				}
			}
         printTo(((WINDOW_WIDTH-17)/2)-5, 42+iTemp, highLight, 0);
         gotoxy(WINDOW_WIDTH-1,0);
		} while (iStatus != 6);

      /* Je nach Position des Pfeils soll Funktion geladen werden */
		switch(iTemp) 
		{
			case 1:
				LoadDifficultyMenue(user);
			break;
			case 2:
				howToPlay();
			break;
			case 3:
				toplist(user);
			break;
			case 4:
				imprint();
			break;
			default:
				m_Exit = 1;
			break;
		}
	} while(!m_Exit);
}
/**
 * Prints a ReadableInstant to a String.
 * <p>
 * This method will use the override zone and the override chronololgy if
 * they are set. Otherwise it will use the Chronology *and zone of the instant.
 *
 * @param instant  instant to format, NULL means now
 * @return the printed result
 */
string DateTimeFormatter::print(ReadableInstant *instant) {
    string buf;
    printTo(buf, instant);
    return buf;
}
 typename TypeTraits::EnableIf<StringFuncs<TString>::has_append, size_t>::type
 printTo(TString &str) const {
   DynamicStringBuilder<TString> sb(str);
   return printTo(sb);
 }
/**
 * Prints a millisecond instant to a String.
 * <p>
 * This method will use the override zone and the override chronololgy if
 * they are set. Otherwise it will use the ISO Chronology *and default zone.
 *
 * @param instant  millis since 1970-01-01T00:00:00Z
 * @return the printed result
 */
string DateTimeFormatter::print(int64_t instant) {
    string buf;
    printTo(buf, instant);
    return buf;
}
Beispiel #16
0
 size_t printTo(String &str) const {
   DynamicStringBuilder sb(str);
   return printTo(sb);
 }
Beispiel #17
0
/**
 * ============================================================================
 * Funktion:    	login
 * Input: 	   	-
 * Output: 	     userAccount
 *
 * Beschreibung:	Prüft nach ob Passwort und User Name in der Datenbank
 *                 vorhanden und Korrekt sind.
 * 			       Bei Erfolg gibt die Funktion Infos zum Nutzer in einer
 *                 ACCOUNT struct zurück.
 * ============================================================================
 **/
ACCOUNT login(void)
{
    /* Variablen initialisieren */
    int iStatus=0, j=0, i=0, k=0;
    char cNickname[20], cPassword[28]="", c=' ';
    ACCOUNT userAccount;

    resizeWindow(50, 20);
    do
    {
        /* Passwort maskieren */
        for(i=0; i<(sizeof(cPassword)/sizeof(char)); i++)
        {
            cPassword[i]='\0';
        }

        /* Loginmaske darstellen */
        system("cls");
        printTo(20, 2,"L O G I N", 0);
        printTo(20, 3,"= = = = =", 0);
        printBox(10, "User:"******"Pasword:");

        /* Fehlerausgaben: */
        if(iStatus==0 && j!=0)
        {
            /* Wurde der Nutzer im letzten Schleifendurchlauf nicht gefunden,
               einen entsprechenden Fehler ausgeben */
            printTo(10, 7, "Error! The user does not exsist.", 12);
        }
        else if( iStatus == 1)
        {
            /* Wurde im letzten Schleifendurchlauf ein falsches Kennwort
               angegeben, einen entsprechenden Fehler ausgeben */
            printTo(14, 7, "Error! Wrong password", 12);
        }

        /* Nickname einlesen */
        fflush(stdin);
        gotoxy(22, 11);
        scanf("%s", &cNickname);

        /* Kennwort einlesen */
        fflush(stdin);
        gotoxy(22, 16);
        GetPassword( cPassword );

        /* Status abfragen (-> Logindaten gueltig?) */
        iStatus = authentificationStatus(cNickname, cPassword);
        j++;
    } while(iStatus!=2 && j<5); /* Abbruch wenn 5. Loginversuch fehlgeschlagen
                                  oder Nutzer erfolgreich angemeldet. */

    /* Accountdaten abfragen */
    if(iStatus == 2) {
        userAccount = getUser(cNickname, cPassword);
    }
    else
    {
        userAccount.ID = 0;
    }

    return userAccount;
}
/**
 * Prints an instant from milliseconds since 1970-01-01T00:00:00Z,
 * using ISO Chronology *in the default DateTimeZone.
 *
 * @param buf  the destination to format to, not NULL
 * @param instant  millis since 1970-01-01T00:00:00Z
 */
void DateTimeFormatter::printTo(string &buf, int64_t instant) {
    printTo(buf, instant, NULL);
}
Beispiel #19
0
/* ============================================================================
* Funktion:        registrierung
* Input:           -
* Output:          -
*
* Beschreibung:    Logik fuer komplette Registrierung eines Users
* =============================================================================
*/
void registrierung(void)
{
   MYSQL_RES *result = NULL, *userresult = NULL;
   char cVorname[25], cNachname[25], cNickname[20], cPasswort[28];
   char cQuery[300], c;
   MYSQL *Connection = MySQLConnect ();
	int iSuccess=0, num_fields=0;

   /* Fenstergroesse anpassen */
   resizeWindow(50, 27);
   system("cls");

   /* Ausgabe fuer Registrierungsinfos */
   printTo(18,2,"R E G I S T E R", 0);
   printTo(18,3,"= = = = = = = =", 0);
   printBox(7, "First name:");
   printBox(12, "Last name:");
   printBox(17, "Username:"******"Password:"******"%s", &cVorname);
   fflush(stdin);
   gotoxy(24, 13);
   scanf("%s", &cNachname);
   fflush(stdin);
   gotoxy(24, 18);
   scanf("%s", &cNickname);
   fflush(stdin);
   gotoxy(24, 23);
   GetPassword(cPasswort);

	sprintf(
		cQuery,
		"SELECT id FROM accounts WHERE username = '******';",
		cNickname
	);
   /* SQL Anfrage schicken */
   userresult = QueryBuilder (Connection, cQuery);

	if( userresult ) /* Wenn Query erfolgreich */
	{
		num_fields = mysql_num_rows(userresult);
		if(num_fields == 0) /* und Ergebnismenge 0 Zeilen lang */
		{
			iSuccess=1;
		}
		mysql_free_result(userresult);
	}
	if(iSuccess)
	{
		/* Query festlegen */
		sprintf(
		  cQuery,
		  "INSERT INTO accounts VALUES (NULL, '%s', '%s', '%s', MD5('%s'), %i, %i)",
		  cVorname,
		  cNachname,
		  cNickname,
		  cPasswort,
		  WINDOW_WIDTH,
		  WINDOW_HEIGHT
		);

		/* SQL Anfrage schicken */
		result = QueryBuilder (Connection, cQuery);

		/* Speicher freigeben und Verbindung beenden */
		mysql_free_result(result);

		/* Ausgabe bei Erfolg */
		system("cls");
		printf("\nThank you for your registration.\n");
		printf("Your account has been created.\n\n\n\n\n\n\n");
		printf("Please press a key to return.");
	}
	else 
	{
		system("cls");
		printTo(0,0,"Error! The username is already token.\nReturning to the main menue.", 12);
	}

   MySQLClose (Connection);
   getchar();

   return;
}
 size_t measureLength() const {
   DummyPrint dp;
   return printTo(dp);
 }
 size_t prettyPrintTo(IndentedPrint &print) const {
   Prettyfier p(print);
   return printTo(p);
 }
 size_t printTo(char *buffer, size_t bufferSize) const {
   StringBuilder sb(buffer, bufferSize);
   return printTo(sb);
 }
Beispiel #23
0
/* ============================================================================
* Funktion:        loadMainMenue
* Input:           -
* Output:          
*
* Beschreibung:    Gibt das Mainmenue aus
* ============================================================================
*/
int LoadMainMenue(void) {
   /* Initialisierung der Variablen */
	int iStatus = 0, iTemp = 1, i, m_Exit=0;
   char *cMenu[MAIN_MENUE_SIZE] = { "Register", "Login", "Exit"},highLight[2];
   ACCOUNT user;
   
	sprintf(highLight, "%c", 16);
   /* Bildschirm loeschen */
	system("cls");
	createBlockView(WINDOW_WIDTH, 37);
	createBlockView(WINDOW_WIDTH, 10);
   /* Logo laden */
	loadMainLogo();
   printTo(((WINDOW_WIDTH-9)/2), 40, "M E N U E", 0);
   printTo(((WINDOW_WIDTH-9)/2), 41, "= = = = =", 0);
	for (i = 0; i < MAIN_MENUE_SIZE; i++)
	{
            printTo((WINDOW_WIDTH-9)/2, 43+i, cMenu[i], 0);
	}
   printTo(((WINDOW_WIDTH-9)/2)-5, 43, highLight, 0);
	gotoxy(WINDOW_WIDTH-1,0);
   /* Navigation (Rendern der Pfeile bei Tastendruck) */
   do
   {
		iStatus = control();
      printTo(((WINDOW_WIDTH-9)/2)-5, 42+iTemp, " ", 0);
		if (iStatus == 2) 
		{
			if (iTemp > 1) 
			{
				iTemp--;
			}
		}
		else if (iStatus == 3) 
		{
			if (iTemp < MAIN_MENUE_SIZE && iTemp > 0)
			{
				iTemp++;
			}
		}
      printTo(((WINDOW_WIDTH-9)/2)-5, 42+iTemp, highLight, 0);
		gotoxy(WINDOW_WIDTH-1,0);
   } while (iStatus != 6);

   system("cls");
   /* Je nach Position der Pfeile bei Menuepunkten wird Funktion aufgerufen */
   switch(iTemp) 
   {
		case 1:
			registrierung();
			system("cls");
		break;
		case 2:
			user = login();
			system("cls");
			if( user.ID == 0 )
			{
				printf("\n\n\n\nError, couldn't log in, the "
               "game will shut down automatically now.");
				m_Exit = 1;
				getchar( );
			}
			else
			{
				LoadGameMenue(user);
			}
		break;
		default:
			m_Exit=1;
			break;
   }
	return m_Exit;
}
/**
 * Prints a ReadablePartial to a new String.
 * <p>
 * Neither the override Chronology *nor the override zone are used
 * by this method.
 *
 * @param partial  partial to format
 * @return the printed result
 */
string DateTimeFormatter::print(ReadablePartial *partial) {
    string buf;
    printTo(buf, partial);
    return buf;
}
Beispiel #25
0
/* ============================================================================
* Funktion:        howToPlay
* Input:              -
* Output:             -
*
* Beschreibung:    Gibt eine Anleitung fuer das Spielen auf der Konsole aus.
* =============================================================================
*/
void howToPlay() {
   /* Initialisierung der Variablen */
   char *cMenu[1] = {
      "Back to Menue"
   }, highLight[2];
	int iStatus;

   /* Highlighter fuer Menue */
   sprintf(highLight, "%c", 16);
   /* Bildschirm loeschen */
   system("cls");
   /* Bloecke erstellen */
   createBlockView(WINDOW_WIDTH, 37);
   createBlockView(WINDOW_WIDTH, 10);

   /* Den HowToPlay Text richtig ausgeben */
   printTo(50, 2, "How to play Sudoku", 0);
   printTo(35, 4, "A sudoku puzzle initially displays a partially", 0);
   printTo(35, 5, "filled grid. The aim of the game is to fill each square", 0);
   printTo(35, 6, "with a number from 1 - 9. Each number can only appear", 0);
   printTo(35, 7, "once in the same row, column or 3 x 3 box. ", 0);
   printTo(35, 8, "Solving sudoku puzzles takes pure logic, there is no", 0);
   printTo(35, 9, "maths involved in finding a solution. Sudoku can be ", 0);
   printTo(35, 10, "played with 9 different numbers and there is only one", 0);
   printTo(35, 12, "Step 1: Look at the puzzle and find a mini grid that", 0);
   printTo(35, 13, "has lots of hints", 0);
   printTo(35, 15, "Step 2: Look at each row and columns of the mini", 0);
   printTo(35, 16, "grid and fill in the missing numbers.", 0);
   printTo(35, 17, "Each number can only be used once!", 0);
   printTo(35, 19, "Step 3: Look at the columns and rows again.", 0);
   printTo(35, 20, "Check to make sure none of the numbers are the same.", 0);
   printTo(35, 21, "Move any that are the same.", 0);
   printTo(35, 23, "Step 4: Do these steps again for each mini grid", 0);
   printTo(35, 26, "The rules of the Sudoku are quite simple. A classic", 0);
   printTo(35, 27, "Sudoku grid is made of nine rows and nine columns,", 0);
   printTo(35, 28, "giving 81 cells. You must fill each cell with numbers", 0);
   printTo(35, 29, "going from 1 to 9, with the restriction that one", 0);
   printTo(35, 30, "single number can only appear once in the same row,", 0);
   printTo(35, 31, "in the same column, or in the same box of 3x3 cells.", 0);
   printTo(35, 32, "To find the missing numbers, you must use logic and", 0);
   printTo(35, 33, "observation To ease your game, we give you a few tips", 0);
   printTo(35, 34, "and tricks quite easy to remember. Use them wisely,", 0);
   printTo(35, 35, "and you will be able to complete your Sudoku faster!", 0);

   /* Ueberschrift ausgeben */
   printTo(((WINDOW_WIDTH - 13) / 2), 40,
      "H O W T O P L A Y", 0);
   printTo(((WINDOW_WIDTH - 13) / 2), 41,
      "= = = = = = = = =", 0);
   /* Menue ausgeben */
   printTo(
      (WINDOW_WIDTH - 13) / 2,
      43, cMenu[0], 0
      );
   printTo(
      ((WINDOW_WIDTH - 13) / 2) - 5,
      43, highLight, 0
      );
   /* Cursor verstecken */
   gotoxy(WINDOW_WIDTH - 1, 0);
   do
	{
		iStatus = control();
	} while(iStatus!=6);
}
Beispiel #26
0
/* ============================================================================
* Funktion:        toplist
* Input:           -
* Output:          -
*
* Beschreibung:    Holt die Topliste aus der Datenbank und gibt sie aus.
* =============================================================================
*/
void toplist(ACCOUNT user)
{
   int num_fields = 0, iStatus = 0, iTemp = 1, iLength = 0, i = 0, m_Exit = 0;
   int x = 0, xpos=0, ypos=0, page=1, j[3];
   char *cMenu[SUDOKU_DIFFICULTIES] = {
                               "Easy",
                               "Medium",
                               "Hard",
                               "Exit"
                            };
   char userList[SUDOKU_DIFFICULTIES][100][3][100];
   char highLight[2], cQuery[300], cString[200], coods[20], number[10];
   MYSQL_ROW ROW;
   MYSQL_RES *topList[3] = {NULL, NULL, NULL};
   MYSQL *Connection = NULL;

   sprintf(highLight, "%c", 16);
   system("cls");

	createBlockView(WINDOW_WIDTH, 37);
	createBlockView(WINDOW_WIDTH, 10);

   printTo(((WINDOW_WIDTH-13)/2), 40, "T O P L I S T", 0);
   printTo(((WINDOW_WIDTH-13)/2), 41, "= = = = = = =", 0);
   for (i = 0; i < SUDOKU_DIFFICULTIES; i++)
   {
      printTo(((WINDOW_WIDTH-13)/2), 43+ i, cMenu[i], 0);
   }
   printTo(((WINDOW_WIDTH-13)/2)-5, 43, highLight, 0 );

   Connection = MySQLConnect();
   x=0;
   for(i=0; i<SUDOKU_DIFFICULTIES; i++)
   {
      x=0;
      sprintf(cQuery,
         "SELECT a.username, p.points, p.time FROM accounts a JOIN points p ON (a.id = p.userid) WHERE difficulty = %i ORDER BY p.points DESC, p.time ASC LIMIT 10",
          i+1 );
      topList[i] = QueryBuilder(Connection, cQuery);
      if(topList[i])
      {
         while (ROW = mysql_fetch_row(topList[i]))
         {
            strcpy(userList[i][x][0], ROW[0]);
            strcpy(userList[i][x][1], ROW[1]);
            strcpy(userList[i][x][2], ROW[2]);
            x++;
         }
      }
      j[i] = x;
      mysql_free_result(topList[i]);
   }
   MySQLClose(Connection);
	
   renderToplist(WINDOW_WIDTH);
   createTableHead(WINDOW_WIDTH);
   
	if(j[iTemp-1] > 10 )
   {
      iLength = (page*10);
   }
   else
   {
      iLength = j[iTemp-1];
   }
	
   for(i=0; i<iLength;i++)
   {
      _itoa(i+1,number,10);
		createTableRow(number, userList[iTemp-1][i][0], userList[iTemp-1][i][1],
                     userList[iTemp-1][i][2], (i*2)+5+2, WINDOW_WIDTH);
   }
   closingRow((i*2)+6, WINDOW_WIDTH);
   gotoxy(WINDOW_WIDTH - 1, 0);
   do
   {
      do
      {
         iStatus = control();
         printTo(((WINDOW_WIDTH-13)/2)-5, 42+ iTemp, " ", 0);

         if (iStatus == 2)
         {
            if (iTemp > 1)
            {
               iTemp--;
            }
         }
         else if (iStatus == 3)
         {
            if (iTemp < SUDOKU_DIFFICULTIES && iTemp > 0)
            {
               iTemp++;
            }
         }
         xpos = ((WINDOW_WIDTH - 13) / 2) - 5;
         ypos = ((WINDOW_HEIGHT / 3) * 2) + iTemp;
         sprintf(coods,"");
         printTo(((WINDOW_WIDTH-13)/2)-5, 42+ iTemp, highLight, 0);
         gotoxy(WINDOW_WIDTH - 1, 0);
      } while (iStatus != 6);

      switch (iTemp)
      {
         case 1:
         case 2:
         case 3:
            renderToplist(WINDOW_WIDTH);
            if(j[iTemp-1]>10)
            {
               iLength = (page*10);
            }
            else
            {
               iLength = j[iTemp-1];
            }

            createTableHead(WINDOW_WIDTH);

            for(i=0; i<iLength; i++)
            {
               _itoa(i+1,number,10);
					createTableRow(number, userList[iTemp-1][i][0], userList[iTemp-1][i][1],
									userList[iTemp-1][i][2], (i*2)+5+2, WINDOW_WIDTH);
            }
            closingRow((i*2)+6, WINDOW_WIDTH);
            gotoxy(WINDOW_WIDTH - 1, 0);
         break;
         case 4:
            m_Exit = 1;
         break;
      }
   } while (!m_Exit);
}
/**
 * Prints a ReadableInstant, using the Chronology *supplied by the instant.
 *
 * @param out  the destination to format to, not NULL
 * @param instant  instant to format, NULL means now
 */
void DateTimeFormatter::printTo(stringstream &out, ReadableInstant *instant) {
    int64_t millis = DateTimeUtils::getInstantMillis(instant);
    Chronology *chrono = DateTimeUtils::getInstantChronology(instant);
    printTo(out, millis, chrono);
}
 std::ostream &printTo(std::ostream &os) const {
   StreamPrintAdapter adapter(os);
   printTo(adapter);
   return os;
 }