Beispiel #1
0
void CAutoplayer::DoAutoplayer(void) 
{
	write_log(prefs.debug_autoplayer(), "[AutoPlayer] Starting Autoplayer cadence...\n");

	CheckBringKeyboard();

	p_scraper_access->GetNeccessaryTablemapObjects();
	/* [TODO] better log-file format !! 	
	write_log(prefs.debug_autoplayer(), "[AutoPlayer] Number of visible buttons: %d (%c%c%c%c%c)\n", 
		num_buttons_visible, 
		allin_option_available ? 'A' : '.',
		raise_button_available ? 'R' : '.',
		call_button_available  ? 'C' : '.',
		check_button_available ? 'K' : '.',
		fold_button_available  ? 'F' : '.');*/

	// Care about sitin, sitout, leave, etc.
	p_autoplayer_functions->CalcSecondaryFormulas();
	ExecuteSecondaryFormulasIfNecessary();
  
	// Care about I86 regions as well
	HandleInterfacebuttonsI86();

	if(p_symbol_engine_autoplayer->isfinalanswer())
	{
		p_autoplayer_functions->CalcPrimaryFormulas();
		ExecutePrimaryFormulas();
	}
	FinishActionSequenceIfNecessary();
	write_log(prefs.debug_autoplayer(), "[AutoPlayer] ...ending Autoplayer cadence.\n");
}
Beispiel #2
0
void CAutoplayer::DoAutoplayer(void)
{
    write_log(prefs.debug_autoplayer(), "[AutoPlayer] Starting Autoplayer cadence...\n");

    CheckBringKeyboard();

    p_scraper_access->GetNeccessaryTablemapObjects();
    /* [TODO] better log-file format !!
    write_log(prefs.debug_autoplayer(), "[AutoPlayer] Number of visible buttons: %d (%c%c%c%c%c)\n",
    	num_buttons_visible,
    	allin_option_available ? 'A' : '.',
    	raise_button_available ? 'R' : '.',
    	call_button_available  ? 'C' : '.',
    	check_button_available ? 'K' : '.',
    	fold_button_available  ? 'F' : '.');*/

    // Care about I86 regions first, because they are usually used
    // to handle popups which occlude the table (unstable input)
    if (!HandleInterfacebuttonsI86())
    {
        // Care about sitin, sitout, leave, etc.
        p_autoplayer_functions->CalcSecondaryFormulas();
        if (!ExecuteSecondaryFormulasIfNecessary())
        {
            write_log(prefs.debug_autoplayer(), "[AutoPlayer] No secondary formulas to be handled.\n");
            // Since OH 4.0.5 we support autoplaying immediatelly after connection
            // without the need to know the userchair to act on secondary formulas.
            // However: for primary formulas (f$alli, f$rais, etc.)
            // knowing the userchair (combination of cards and buttons) is a must.
            if (!p_symbol_engine_userchair->userchair_confirmed())
            {
                write_log(prefs.debug_autoplayer(), "[AutoPlayer] Skipping primary formulas because userchair unknown\n");
            }
            else
            {
                write_log(prefs.debug_autoplayer(), "[AutoPlayer] Going to evaluate primary formulas.\n");
                if(p_symbol_engine_autoplayer->isfinalanswer())
                {
                    p_autoplayer_functions->CalcPrimaryFormulas();
                    ExecutePrimaryFormulasIfNecessary();
                }
                else
                {
                    write_log(prefs.debug_autoplayer(), "[AutoPlayer] No final answer, therefore not executing autoplayer-logic.\n");
                }
            }
        }
    }
    FinishActionSequenceIfNecessary();
    write_log(prefs.debug_autoplayer(), "[AutoPlayer] ...ending Autoplayer cadence.\n");
}
void CAutoplayer::DoAutoplayer(void) {
	write_log(preferences.debug_autoplayer(), "[AutoPlayer] Starting Autoplayer cadence...\n");
  CheckBringKeyboard();
  p_scraper_access->GetNeccessaryTablemapObjects();
  write_log(preferences.debug_autoplayer(), "[AutoPlayer] Number of visible buttons: %d (%s)\n", 
		p_scraper_access->NumberOfVisibleButtons(),
		p_symbol_engine_autoplayer->GetFCKRAString());
		
	// Care about I86 regions first, because they are usually used 
	// to handle popups which occlude the table (unstable input)
	if (HandleInterfacebuttonsI86())	{
    write_log(preferences.debug_autoplayer(), "[AutoPlayer] Interface buttons (popups) handled\n");
    action_sequence_needs_to_be_finished = true;
	goto AutoPlayerCleanupAndFinalization;
  }
  // Care about sitin, sitout, leave, etc.
  if (TimeToHandleSecondaryFormulas())	{
	  p_autoplayer_functions->CalcSecondaryFormulas();	  
    if (ExecuteSecondaryFormulasIfNecessary())	{
      write_log(preferences.debug_autoplayer(), "[AutoPlayer] Secondary formulas executed\n");
      goto AutoPlayerCleanupAndFinalization;
    } else {
      write_log(preferences.debug_autoplayer(), "[AutoPlayer] No secondary formulas to be handled.\n");
    }
  } else {
    write_log(preferences.debug_autoplayer(), "[AutoPlayer] Not executing secondary formulas this heartbeat\n");
	}
  if (!p_symbol_engine_userchair->userchair_confirmed()) {
    // Since OH 4.0.5 we support autoplaying immediatelly after connection
		// without the need to know the userchair to act on secondary formulas.
		// However: for primary formulas (f$alli, f$rais, etc.)
		// knowing the userchair (combination of cards and buttons) is a must.
		write_log(preferences.debug_autoplayer(), "[AutoPlayer] Skipping primary formulas because userchair unknown\n");
		goto AutoPlayerCleanupAndFinalization;
  }
	write_log(preferences.debug_autoplayer(), "[AutoPlayer] Going to evaluate primary formulas.\n");
	if(p_symbol_engine_autoplayer->isfinalanswer())	{
		p_autoplayer_functions->CalcPrimaryFormulas();
		ExecutePrimaryFormulasIfNecessary();
	}	else {
		write_log(preferences.debug_autoplayer(), "[AutoPlayer] No final answer, therefore not executing autoplayer-logic.\n");
	}
  // Gotos are usually considered bad code.
  // Here it simplifies the control-flow.
  AutoPlayerCleanupAndFinalization:  
	FinishActionSequenceIfNecessary();
	write_log(preferences.debug_autoplayer(), "[AutoPlayer] ...ending Autoplayer cadence.\n");
}
CAutoplayer::~CAutoplayer(void) {
	FinishActionSequenceIfNecessary();
}
bool CAutoplayer::ExecuteSecondaryFormulasIfNecessary() {
	int executed_secondary_function = kUndefined;
	if (!AnySecondaryFormulaTrue())	{
		write_log(preferences.debug_autoplayer(), "[AutoPlayer] All secondary formulas false.\n");
		write_log(preferences.debug_autoplayer(), "[AutoPlayer] Nothing to do.\n");
		return false;
	}

	CMyMutex mutex;

	if (!mutex.IsLocked())
	{
		return false;
	}

	PrepareActionSequence();
	// Prefold, close, rebuy and chat work require different treatment,
	// more than just clicking a simple region...
	if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_standard_function_prefold)) {
		// Prefold is technically more than a simple button-click,
		// because we need to create an autoplayer-trace afterwards.
		if (DoPrefold()) {
			executed_secondary_function = k_standard_function_prefold;
		}
	}
	else if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_hopper_function_close))	{
		// CloseWindow is "final".
		// We don't expect any further action after that
		// and can return immediatelly.
		if (p_casino_interface->CloseWindow()) {
			executed_secondary_function = k_hopper_function_close;
		}
	}
	else if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_hopper_function_rebuy))	{
		// This requires an external script and some time.
		// No further actions here eihter, but immediate return.
		p_rebuymanagement->TryToRebuy();
		// No waz to check for success here
		executed_secondary_function = k_hopper_function_rebuy;
	}
	else if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_standard_function_chat)) 	{
			if (DoChat()) {
				executed_secondary_function = k_standard_function_chat;
			}
	}
	// Otherwise: handle the simple simple button-click
	// k_hopper_function_sitin,
	// k_hopper_function_sitout,
	// k_hopper_function_leave,
  // k_hopper_function_rematch,
	// k_hopper_function_autopost,
	else 
    for (int i=k_hopper_function_sitin; i<=k_hopper_function_autopost; ++i)	{
		if (p_autoplayer_functions->GetAutoplayerFunctionValue(i))	{
			if (p_casino_interface->ClickButton(i)) {
				executed_secondary_function = i;
				break;
			}
		}
	}
	if (executed_secondary_function != kUndefined) {
		FinishActionSequenceIfNecessary();
		p_autoplayer_trace->Print(ActionConstantNames(executed_secondary_function), false);
		return true;
	}
	action_sequence_needs_to_be_finished = false;
	return false;
}