Example #1
0
void TitleMenu() {
  int program_quit = 0;
  char ch = '\0';
  while(!program_quit) {
    clear();
    attron(A_BOLD);
    attron(COLOR_PAIR(3));
    mvprintw(5, 25, "A S C I I     P A C K - M A N ");
    mvprintw(15, 25, "[P] PLAY GAME");
    mvprintw(16, 25, "[H] HELP");
    mvprintw(17, 25, "[Q] QUIT");
    mvprintw(13, 25, "Choose an option :");
    attroff(COLOR_PAIR(3));
    attroff(A_BOLD);

    ch = getch();
    switch(ch) {
      case 'p':
      case 'P':
        PrepareGame();
        PlayGame();
        ShowResult();
        break;
      case 'h':
      case 'H':
        ShowHelp();
        break;
      case 'q':
      case 'Q':
        program_quit = 1;
        break;
      default:
        break;
    }
  }
}
Example #2
0
void CTrivia::OnInputHook(DWORD dwIP, CString *pInput)
{

	if(pInput->CompareNoCase("/trivia start") == 0){

		if(m_bTrivia){

			WriteEchoText(dwIP, "Trivia game is already running!\n", RGB(0, 0, 255), RGB(230, 200, 0));
		}
		else{

			m_dwTriviaID = dwIP;
            WriteEchoText(dwIP, "Initializing Trivia game. Please stand by...!\n", RGB(0, 0, 255), RGB(230, 200, 0));
			PrepareGame();
		}
		pInput->Empty();
	}
	else if(pInput->CompareNoCase("/trivia stop") == 0){

		if(m_bTrivia){

			WriteEchoText(dwIP, "Stopping game. Please stand by...!\n", RGB(0, 0, 255), RGB(230, 200, 0));
			m_bTrivia = FALSE;
			m_dwTriviaID = 0;
			WaitForSingleObject(m_eTrivia.m_hObject, INFINITE);
			WriteEchoText(dwIP, "Game stopped.\n", RGB(0, 0, 255), RGB(230, 200, 0));
		}
		else{

			WriteEchoText(dwIP, "Trivia game is not running!\n", RGB(255,255,255), RGB(230, 200, 0));
		}
		pInput->Empty();
	}
	else if(pInput->Find("/addgamemaster ") == 0){

		CString strName = *pInput;
		strName.Replace("/addgamemaster ", "");

		SetAdmin(strName, TRUE);
		pInput->Empty();
		FloodSafeInput(dwIP, strName + " was added as a game master.");
	}
	else if(pInput->Find("/remgamemaster ") == 0){

		CString strName = *pInput;
		strName.Replace("/remgamemaster ", "");

		SetAdmin(strName, FALSE);
		pInput->Empty();
		FloodSafeInput(dwIP, strName + " is no longer a game master.");
	}
	else if(pInput->CompareNoCase("/config") == 0){

		ShellExecute(0, "open", m_strWd + "\\Trivia.ini", 0, 0, SW_MAXIMIZE);
		WriteEchoText(dwIP, "You have to restart the game for changes to take effect.\n", RGB(0,0,255), m_crBg);
		pInput->Empty();
	}
	else if(pInput->CompareNoCase("/trivia") == 0){

		WriteEchoText(dwIP, "Trivia Plugin for RoboMX (c) 2004 by Thees Schwab.\nAvailable commands:\n", RGB(0,0,255), m_crBg);
		WriteEchoText(dwIP, "/trivia start  -  Start a new trivia game in this channel\n", RGB(0,0,255), m_crBg);
		WriteEchoText(dwIP, "/trivia stop   -  Stop current trivia game\n", RGB(0,0,255), m_crBg);
		WriteEchoText(dwIP, "/addgamemaster <user> - Add <user> as a gamemaster\n", RGB(0,0,255), m_crBg);
		WriteEchoText(dwIP, "/addgamemaster <user> - Remove <user> from gamemasters\n", RGB(0,0,255), m_crBg);
		WriteEchoText(dwIP, "/config   - Open configuration file.\n", RGB(0,0,255), m_crBg);
		WriteEchoText(dwIP, "/trivia   - Display this message\n", RGB(0,0,255), m_crBg);
		WriteEchoText(dwIP, "Note: Game masters can use the SKIP, RESET and PAUSE commands.\n", RGB(0,0,255), m_crBg);
		pInput->Empty();
	}

	if(pInput->GetLength()){

		if(m_dwFloodTick - GetTickCount() < 3000){

			// if the last message has been input in the last 3 seconds 
			// raise the counter
			m_dwFloodCounter++;
		}
		else{

			// we are safe, reset the counter
			m_dwFloodCounter = 0;
		}

		if(m_dwFloodCounter > 3){

			// We need to wait for the next output or we will get kicked
			// After that we can reset the counter and input the message
			Sleep(4000);
			m_dwFloodCounter = 0;
		}

		m_dwFloodTick = GetTickCount();
	}
}