void SetDifficulty() { FText InString; getline(std::cin, InString); try { int Level = std::stoi(InString); if (Level < 1 || Level > 5) { std::cout << "\nPlease be sure to enter a valid integer between 1 and 5: "; SetDifficulty(); } else { BCGame.SetDifficulty(Level); std::cout << std::endl << "Alright, we're working with a " << BCGame.GetHiddenWordLength() << " letter isogram. Let's play the game!\n\n"; } } catch (std::invalid_argument& e) { std::cout << "\nPlease be sure to enter a valid integer between 1 and 5: "; SetDifficulty(); } catch (std::out_of_range& e) { std::cout << "\nPlease be sure to enter a valid integer between 1 and 5: "; SetDifficulty(); } }
void Steps::TidyUpData() { // Don't set the StepsType to dance single if it's invalid. That just // causes unrecognized charts to end up where they don't belong. // Leave it as StepsType_Invalid so the Song can handle it specially. This // is a forwards compatibility feature, so that if a future version adds a // new style, editing a simfile with unrecognized Steps won't silently // delete them. -Kyz if( m_StepsType == StepsType_Invalid ) { LOG->Warn("Detected steps with unknown style '%s' in '%s'", m_StepsTypeStr.c_str(), m_pSong->m_sSongFileName.c_str()); } else if(m_StepsTypeStr == "") { m_StepsTypeStr= GAMEMAN->GetStepsTypeInfo(m_StepsType).szName; } if( GetDifficulty() == Difficulty_Invalid ) SetDifficulty( StringToDifficulty(GetDescription()) ); if( GetDifficulty() == Difficulty_Invalid ) { if( GetMeter() == 1 ) SetDifficulty( Difficulty_Beginner ); else if( GetMeter() <= 3 ) SetDifficulty( Difficulty_Easy ); else if( GetMeter() <= 6 ) SetDifficulty( Difficulty_Medium ); else SetDifficulty( Difficulty_Hard ); } if( GetMeter() < 1) // meter is invalid SetMeter( int(PredictMeter()) ); }
// Change Level void ChangeLevel() { if (frameCounter == 0) { OutputOfChangeLevel(); } if (frameCounter % (100 + difficulty * 50) == 0 && frameCounter != 0) { levelCount++; OutputOfChangeLevel(); AdjustDifficulty(); SetDifficulty(); if (rockSpawnInterval > 1 && levelCount % 2 == 0) { rockSpawnInterval--; } if (dwarfSpeed > 1 && levelCount % 10 == 0) { dwarfSpeed--; lastDwarfSpeed--; } } }
void Steps::TidyUpData() { if( m_StepsType == StepsType_Invalid ) m_StepsType = StepsType_dance_single; if( GetDifficulty() == Difficulty_Invalid ) SetDifficulty( StringToDifficulty(GetDescription()) ); if( GetDifficulty() == Difficulty_Invalid ) { if( GetMeter() == 1 ) SetDifficulty( Difficulty_Beginner ); else if( GetMeter() <= 3 ) SetDifficulty( Difficulty_Easy ); else if( GetMeter() <= 6 ) SetDifficulty( Difficulty_Medium ); else SetDifficulty( Difficulty_Hard ); } if( GetMeter() < 1) // meter is invalid SetMeter( int(PredictMeter()) ); }
int32 main() { do { PrintIntro(); SetDifficulty(); PlayGame(); } while (PlayAgain()); return 0; }
static void create() { spell::create(); SetSpell("greater fireball"); SetRules("", "LIV"); SetSpellType(SPELL_COMBAT); SetRequiredMagic(100); SetSkills(([ "conjuring" : 24, "magic attack" : 24 ])); SetMagicCost(49, 49); SetStaminaCost(10, 10); SetDifficulty(10); SetMorality(-20); SetAutoDamage(0); SetDamage(MAGIC|HEAT, ({ 60, 45 }) );
static void create() { spell::create(); SetSpell("fireball"); SetRules("", "LIV"); SetSpellType(SPELL_COMBAT); SetRequiredMagic(50); SetSkills(([ "conjuring" : 8, "magic attack" : 0 ])); SetMagicCost(30, 24); SetStaminaCost(20, 16); SetDifficulty(10); SetMorality(-20); SetAutoDamage(0); SetDamage(MAGIC|HEAT, ({ 20, 15 }) );
static void create() { spell::create(); SetSpell("healing"); SetRules("for LIV"); SetSpellType(SPELL_HEALING); SetRequiredMagic(300); SetSkills(([ "healing" : 1 ])); SetMagicCost( 20, 10); SetDifficulty(1); SetVerb("pray"); SetHelp("Syntax: <pray for healing for LIV>\n\n" "This minor healing spell provides some minimal " "aid to the wounded."); }
static void create() { spell::create(); SetSpell("buffer"); SetRules("", "LIV"); SetSpellType(SPELL_DEFENSE); SetRequiredMagic(50); SetSkills(([ "magic defense" : 1 ])); SetMagicCost(40, 40); SetDifficulty(50); SetMorality(10); SetHelp("Syntax: <cast buffer>\n" " <cast buffer on LIV>\n\n" "A magical defense spell that allows the caster to create " "a glowing shield around the LIVing object named.\n\n"); }
void Board::Init(Difficulty difficulty) { SetDifficulty(difficulty); node_->SetPosition(Vector3(0.0f, 0.0f, Max(width_, height_) * 2.8f)); needCheckLines_ = false; needSpawnBalls_ = false; gameOver_ = false; score_ = 0; record_ = 0; board_.Resize(height_); cells_.Resize(height_); for (int i = 0; i < height_; i++) { board_[i].Resize(width_); cells_[i].Resize(width_); for (int j = 0; j < width_; j++) { Node* cellNode = node_->CreateChild(); Cell* cell = cellNode->CreateComponent<Cell>(); Vector3 targetPos = IV2ToV3(IntVector2(j, i)); Vector3 startPos = Vector3(Random(-50.0f, 50.0f), Random(-50.0f, 50.0f), Random(-50.0f, 50.0f)); cell->Init(startPos, targetPos, IntVector2(j, i)); cells_[i][j] = cell; } } for (int i = 0; i < numAddBalls_; i++) SpawnBall(); if (difficulty_ <= D_NORMAL) { for (int i = 0; i < numAddBalls_; i++) CreateBall(true); } InitSelection(); LoadRecord(); }
FieldView::FieldView(int32 level) : BView(BRect(0,0,1,1),"fieldview",B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_ASYNCHRONOUS_CONTROLS), fField(NULL), fTracking(false), fFlagCount(0), fMainWin(NULL), fPauseMode(false), fWinPlayer(NULL), fLosePlayer(NULL), fClickPlayer(NULL) { SetDifficulty(level); SetDrawingMode(B_OP_ALPHA); app_info ai; be_app->GetAppInfo(&ai); BPath path(&ai.ref); path.GetParent(&path); path.Append("themes"); fThemePath = path.Path(); SetSoundRefs(); }
LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; HMENU hMenu; static BOARD board; switch( msg ) { case WM_CREATE: board.hInst = ((LPCREATESTRUCT) lParam)->hInstance; board.hWnd = hWnd; InitBoard( &board ); CreateBoard( &board ); return 0; case WM_PAINT: { HDC hMemDC; WINE_TRACE("WM_PAINT\n"); hdc = BeginPaint( hWnd, &ps ); hMemDC = CreateCompatibleDC( hdc ); DrawBoard( hdc, hMemDC, &ps, &board ); DeleteDC( hMemDC ); EndPaint( hWnd, &ps ); return 0; } case WM_MOVE: WINE_TRACE("WM_MOVE\n"); board.pos.x = (short)LOWORD(lParam); board.pos.y = (short)HIWORD(lParam); return 0; case WM_DESTROY: SaveBoard( &board ); DestroyBoard( &board ); PostQuitMessage( 0 ); return 0; case WM_TIMER: if( board.status == PLAYING ) { board.time++; RedrawWindow( hWnd, &board.timer_rect, 0, RDW_INVALIDATE | RDW_UPDATENOW ); } return 0; case WM_LBUTTONDOWN: WINE_TRACE("WM_LBUTTONDOWN\n"); if( wParam & MK_RBUTTON ) msg = WM_MBUTTONDOWN; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); SetCapture( hWnd ); return 0; case WM_LBUTTONUP: WINE_TRACE("WM_LBUTTONUP\n"); if( wParam & MK_RBUTTON ) msg = WM_MBUTTONUP; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); ReleaseCapture(); return 0; case WM_RBUTTONDOWN: WINE_TRACE("WM_RBUTTONDOWN\n"); if( wParam & MK_LBUTTON ) { board.press.x = 0; board.press.y = 0; msg = WM_MBUTTONDOWN; } TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_RBUTTONUP: WINE_TRACE("WM_RBUTTONUP\n"); if( wParam & MK_LBUTTON ) msg = WM_MBUTTONUP; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_MBUTTONDOWN: WINE_TRACE("WM_MBUTTONDOWN\n"); TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_MBUTTONUP: WINE_TRACE("WM_MBUTTONUP\n"); TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_MOUSEMOVE: { if( wParam & MK_MBUTTON ) { msg = WM_MBUTTONDOWN; } else if( wParam & MK_LBUTTON ) { msg = WM_LBUTTONDOWN; } else { return 0; } TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDM_NEW: CreateBoard( &board ); return 0; case IDM_MARKQ: hMenu = GetMenu( hWnd ); board.IsMarkQ = !board.IsMarkQ; if( board.IsMarkQ ) CheckMenuItem( hMenu, IDM_MARKQ, MF_CHECKED ); else CheckMenuItem( hMenu, IDM_MARKQ, MF_UNCHECKED ); return 0; case IDM_BEGINNER: SetDifficulty( &board, BEGINNER ); CreateBoard( &board ); return 0; case IDM_ADVANCED: SetDifficulty( &board, ADVANCED ); CreateBoard( &board ); return 0; case IDM_EXPERT: SetDifficulty( &board, EXPERT ); CreateBoard( &board ); return 0; case IDM_CUSTOM: SetDifficulty( &board, CUSTOM ); CreateBoard( &board ); return 0; case IDM_EXIT: SendMessage( hWnd, WM_CLOSE, 0, 0); return 0; case IDM_TIMES: DialogBoxParam( board.hInst, "DLG_TIMES", hWnd, TimesDlgProc, (LPARAM) &board); return 0; case IDM_ABOUT: { WCHAR appname[256], other[256]; LoadStringW( board.hInst, IDS_APPNAME, appname, sizeof(appname)/sizeof(WCHAR) ); LoadStringW( board.hInst, IDS_ABOUT, other, sizeof(other)/sizeof(WCHAR) ); ShellAboutW( hWnd, appname, other, LoadImageA( board.hInst, "WINEMINE", IMAGE_ICON, 48, 48, LR_SHARED )); return 0; } default: WINE_TRACE("Unknown WM_COMMAND command message received\n"); break; } } return( DefWindowProc( hWnd, msg, wParam, lParam )); }
jint Java_com_ysaito_shogi_BonanzaJNI_startGame( JNIEnv *env, jclass unused_bonanza_class, jint resume_instance_id, jobject initial_board, jint next_turn, // 0: black 1: white jint difficulty, jint total_think_time_secs, jint per_turn_think_time_secs, jobject result) { int instance_id = -1; pthread_mutex_lock(&g_lock); if (!g_initialized) { FillResult("Init", env, R_INITIALIZATION_ERROR, "Bonanza not yet initialized", NULL, 0, NULL, result); } else if (g_initialization_error != NULL) { FillResult("Init", env, R_INITIALIZATION_ERROR, g_initialization_error, NULL, 0, NULL, result); } else if (resume_instance_id != 0 && resume_instance_id == g_instance_id) { LOG_DEBUG("Resuming game %d", g_instance_id); instance_id = resume_instance_id; } else { instance_id = ++g_instance_id; LOG_DEBUG("Starting game: d=%d t=%d p=%d", difficulty, total_think_time_secs, per_turn_think_time_secs); jclass board_class = (*env)->GetObjectClass(env, initial_board); jfieldID fid = (*env)->GetFieldID(env, board_class, "mSquares", "[I"); jintArray jarray = (jintArray)((*env)->GetObjectField( env, initial_board, fid)); min_posi_t initial_pos = min_posi_no_handicap; initial_pos.turn_to_move = next_turn; jint tmp_array[nsquare]; (*env)->GetIntArrayRegion(env, jarray, 0, nsquare, tmp_array); for (int i = 0; i < nsquare; ++i) { initial_pos.asquare[i] = tmp_array[i]; } fid = (*env)->GetFieldID(env, board_class, "mCapturedBlack", "I"); initial_pos.hand_black = (*env)->GetIntField(env, initial_board, fid); fid = (*env)->GetFieldID(env, board_class, "mCapturedWhite", "I"); initial_pos.hand_white = (*env)->GetIntField(env, initial_board, fid); if (ini_game(&tree, &initial_pos, flag_history, NULL, NULL) < 0) { LOG_FATAL("Failed to initialize game: %s", str_error); } LOG_DEBUG("Initialized Bonanza successfully"); // Disable background thinking; we can't send a interrupt Bonanza // in the middle of thinking otherwise. // // TODO(saito) I must be missing something. Enable background // thinking. SetDifficulty(difficulty, total_think_time_secs, per_turn_think_time_secs); } FillResult("Init", env, R_OK, NULL, NULL, 0, &tree, result); pthread_mutex_unlock(&g_lock); return instance_id; }
void COptionsManager::ResetDefaults(const char* option) { if(!m_pPlayerProfileManager) return; const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return; XmlNodeRef root = GetISystem()->LoadXmlFile("libs/config/profiles/default/attributes.xml"); bool resetAll = (option==NULL); bool detectHardware = false; for (int i = 0; i < root->getChildCount(); ++i) { XmlNodeRef enumNameNode = root->getChild(i); const char *name = enumNameNode->getAttr("name"); const char *value = enumNameNode->getAttr("value"); if(name && value) { const char* attribCVar = ""; bool bWriteToCfg = false; const bool bIsOption = IsOption(name, attribCVar, bWriteToCfg); if(bIsOption) { if(!resetAll && strcmp(attribCVar,option)) continue; if(!strcmp(attribCVar, "sys_spec_Shadows")) { detectHardware = true; } if(!strcmp(attribCVar, "hud_colorLine")) { CryFixedStringT<32> color; color.Format("%d", g_pGameCVars->hud_colorLine); SetCrysisProfileColor(color.c_str()); } if(!strcmp(attribCVar,"pb_client")) { if(atoi(value)==0) { m_pbEnabled = false; gEnv->pConsole->ExecuteString("net_pb_cl_enable false"); } else { m_pbEnabled = true; gEnv->pConsole->ExecuteString("net_pb_cl_enable true"); } } else if(!strcmp(attribCVar, "g_difficultyLevel")) { SetDifficulty(value); } else { ICVar *pCVar = gEnv->pConsole->GetCVar(attribCVar); if(pCVar) { pCVar->Set(value); } } if(!resetAll) break; } } } if(detectHardware) AutoDetectHardware(""); }
void COptionsManager::InitProfileOptions(bool switchProfiles) { if(!m_pPlayerProfileManager) return; if(g_pGameCVars->g_useProfile==0) return; if(g_pGameCVars->g_startFirstTime==1) { ICVar *pCVar = gEnv->pConsole->GetCVar("g_startFirstTime"); if(pCVar && pCVar->GetIVal()==1) { pCVar->Set(0); m_firstStart = true; } switchProfiles=true; } const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return; IAttributeEnumeratorPtr attribEnum = pProfile->CreateAttributeEnumerator(); IAttributeEnumerator::SAttributeDescription attrib; m_profileOptions.clear(); while(attribEnum->Next(attrib)) { bool bWriteToCfg = false; const char* attribCVar = ""; const bool bIsOption = IsOption(attrib.name, attribCVar, bWriteToCfg); if (bIsOption) { SOptionEntry entry (attrib.name, bWriteToCfg); m_profileOptions[attribCVar] = entry; if(!bWriteToCfg || switchProfiles) { string value; if(!strcmp(attribCVar, "pb_client")) { GetProfileValue(attrib.name, value); if(atoi(value)==0) { m_pbEnabled = false; gEnv->pConsole->ExecuteString("net_pb_cl_enable false"); } else { m_pbEnabled = true; gEnv->pConsole->ExecuteString("net_pb_cl_enable true"); } continue; } else if(!strcmp(attribCVar, "fsaa_mode")) { GetProfileValue(attrib.name, value); SetAntiAliasingMode(value.c_str()); } else if(!strcmp(attribCVar, "g_difficultyLevel")) { GetProfileValue(attrib.name, value); SetDifficulty(value); } ICVar *pCVar = gEnv->pConsole->GetCVar(attribCVar); if(pCVar && GetProfileValue(attrib.name, value)) { if(stricmp(pCVar->GetString(), value.c_str())) { //CryLogAlways("Inited, loaded and changed: %s = %s (was %s)", attrib.name, value, pCVar->GetString()); pCVar->Set(value.c_str()); } else { //CryLogAlways("Inited, loaded, but not changed: %s = %s", attrib.name, value); } if(!stricmp(attrib.name,"Option.hud_colorLine")) { SetCrysisProfileColor(value.c_str()); } } } } } WriteGameCfg(); }