Example #1
0
void NetzwerkSpiel::on_loginRequest(string loginPlayerName, string ip)
{
    cout << "Incoming to on_loginRequest() VALUE: " << loginPlayerName << endl;
    starteSpiel(nameSpieler1,loginPlayerName,false,false);
    stopUdpServer();
    this->remoteSpieler = sp1;
    tcpClient->setIpAddress(ip);
    this->tcpClient->sendLoginReply(sp1);

    this->visitorSp1 = *sp1;
    this->visitorSp2 = *sp2;
    //hier starte spiel...
    StartGameSignal();
}
/*
===============================================================================
   Funktion:      zeigeSpielmenu()
   in:            cSpieltyp[]
   out:           -
   Beschreibung:  Jedes Spiel hat noch ein Untermenü. Von dort kann die Hilfe       
                  und die Statistik des jeweiligen Spiels aufgerufen werde, 
                  sowie die Schwierigkeitsstufe des Computers (bei 4-Gewinnt 
                  und Reversi) eingestellt werden. 
===============================================================================
*/
void zeigeSpielmenu(const char cSpieltyp[12])
{
   int iZeige = 1;
   char cEingabe;
   int iSpieltyp;

   if (cSpieltyp == "Reversi")
   {
      iSpieltyp = 3;
   }
   else if (cSpieltyp == "Checkers")
   {
      iSpieltyp = 2;
   }
   else if (cSpieltyp == "4Gewinnt")
   {
      iSpieltyp = 0;
   }
   else if (cSpieltyp == "Bridges")
   {
      iSpieltyp = 1;
   }

   while(iZeige)
   {
      system("cls");
      
      switch(iSpieltyp)
      {
         case 0:  printf("================================================");
                  printf("================================");
                  printf("    444        $$$$$$   $$$$$$$$$ $$     $$ $$ $");
				  printf("$$  $$ $$$  $$ $$$$$$$$         ");
                  printf("   444    44  $$       $$$       $$     $$ $$ $$");
				  printf("$$ $$ $$$$ $$    $$             ");
                  printf("  444444444  $$ $$$$  $$$$$$$$$ $$  $  $$ $$ $$ ");
				  printf("$$$$ $$ $$$$    $$              ");
                  printf("       444  $$    $$ $$$       $$ $$$ $$ $$ $$  ");
				  printf("$$$ $$  $$$    $$               ");
                  printf("      444    $$$$$$ $$$$$$$$$ $$$$$$$$$ $$ $$   ");
				  printf("$$ $$   $$    $$                ");
                  printf("================================================");
				  printf("================================");
         break;
         case 1:  printf("================================================");
				  printf("================================");
                  printf("              $$$$$$$  $$$$$$$  $$ $$$$$  $$$$$$");
				  printf("  $$$$$$ $$$$$$                 ");
                  printf("             $$    $$ $$    $$ $$ $$  $$ $$     ");
				  printf(" $$     $$                      ");
                  printf("            $$ $$$$  $$ $$$$$ $$ $$  $$ $$ $$$  ");
				  printf("$$$$$$ $$$$$$                   ");
                  printf("           $$   $$  $$  $$   $$ $$  $$ $$   $$ $");
				  printf("$         $$                    ");
                  printf("          $$$$$$$  $$   $$  $$ $$$$$    $$$$  $$");
				  printf("$$$$ $$$$$$                     ");
                  printf("================================================");
				  printf("================================");
         break;
         case 2:  printf("==================================================");
                  printf("==============================");
                  printf("         $$$$$$$   $$  $$  $$$$$$ $$$$$$   $$ $$$ ");
                  printf(" $$$$$$ $$$$$$$  $$$$$$       ");
                  printf("        $$    $$  $$  $$  $$     $$   $$  $$ $$   ");
                  printf("$$     $$    $$ $$            ");
                  printf("       $$        $$$$$$  $$$$$  $$       $$$$$   $");
                  printf("$$$   $$ $$$$  $$$$$$$        ");
                  printf("      $$    $$  $$  $$  $$     $$   $$  $$ $$   $$");
                  printf("  $$   $$       $$         ");
                  printf("         $$$$$$$  $$  $$  $$$$$$$ $$$$$$  $$   $$ $$$");
                  printf("$$$ $$    $$ $$$$$$$          ");
                  printf("==================================================");
                  printf("==============================");
         break;
         case 3:  printf("================================================");
			      printf("================================");
                  printf("              $$$$$$$  $$$$$ $$  $$ $$$$$ $$$$$$");
				  printf("  $$$$$   $$                    ");
                  printf("             $$    $$ $$    $$  $$ $$    $$   $$");
				  printf(" $$      $$                     ");
                  printf("            $$ $$$$  $$$$$ $$  $$ $$$$$ $$ $$$$ ");
				  printf("$$$$$$  $$                      ");      
                  printf("           $$   $$  $$    $$ $$$ $$    $$  $$   ");
				  printf("   $$  $$                       ");
                  printf("          $$    $$ $$$$$  $$$$$ $$$$$ $$   $$ $$");
				  printf("$$$$  $$                        ");
                  printf("================================================");
				  printf("================================");
                  printf("\n");
         break;
      }
      printf("\n\n");
      printf("\ta: Spiel starten\n");
      if (!strcmp(g_cSpieler2, "COMPUTER"))
         printf("\tb: Schwierigkeitsstufe des Computers einstellen\n");
      else
         printf("\n");
      printf("\tc: Statistik anzeigen\n");
      printf("\td: Hilfe anzeigen\n");
      printf("\te: Zurueck zum Hauptmenue\n");
      printf("\n");

      printf("\n\tIhre Eingabe: ");
      scanf("%c", &cEingabe);
      fflush(stdin);

      switch (cEingabe)
      {
         case 'a':
         case' A':
            starteSpiel(cSpieltyp);
            break;
         case 'b':
         case' B':
            waehleKI();
            break;
         case 'c':
         case' C':
            if (g_iVerbunden)
            {
               printf("%20s", g_cSpieler1);
               if (strcmp(g_cSpieler2, "COMPUTER"))
                  printf("%20s", g_cSpieler2);
               printf("\n");
               anzahlSpiele(iSpieltyp);
            }
            else
            {
               printf("\tKeine Datenbankverbindung vorhanden. ");
			   printf("Anzeige kann nicht statt finden\n");
               system("pause");
            }
            break;
         case 'd':
         case' D':
            zeigeHilfe(cSpieltyp);
            break;
         case 'e':
         case' E':
            iZeige = 0;
            break;
      }
   }
}