Exemplo n.º 1
0
bool CAutoplayer::ExecuteSecondaryFormulasIfNecessary()
{
    if (!TimeToHandleSecondaryFormulas())
    {
        write_log(prefs.debug_autoplayer(), "[AutoPlayer] Not executing secondary formulas this heartbeat\n");
        return false;
    }
    if (!AnySecondaryFormulaTrue())
    {
        write_log(prefs.debug_autoplayer(), "[AutoPlayer] All secondary formulas false.\n");
        write_log(prefs.debug_autoplayer(), "[AutoPlayer] Nothing to do.\n");
        return false;
    }
    for (int i=k_autoplayer_function_prefold; i<=k_autoplayer_function_chat; i++)
    {

        // Prefold, close, rebuy and chat work require different treatment,
        // more than just clicking a simple region...
        if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_autoplayer_function_prefold))
        {
            // Prefold is technically more than a simple button-click,
            // because we need to create an autoplayer-trace afterwards.
            return DoPrefold();
        }
        if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_autoplayer_function_close))
        {
            // CloseWindow is "final".
            // We don't expect any further action after that
            // and can return immediatelly.
            return p_casino_interface->CloseWindow();
        }
        if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_autoplayer_function_rebuy))
        {
            // This requires an external script and some time.
            // No further actions here eihter, but immediate return.
            p_rebuymanagement->TryToRebuy();
            return true;
        }
        if (p_autoplayer_functions->GetAutoplayerFunctionValue(k_autoplayer_function_chat))
        {
            return DoChat();
        }
        // Otherwise: it is a simple button-click
        if (p_autoplayer_functions->GetAutoplayerFunctionValue(i))
        {
            if (p_casino_interface->ClickButton(i))
            {
                return true;
            }
        }
    }
    return false;
}
Exemplo n.º 2
0
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");
}