Exemple #1
0
void MainWindow::on_action_clicked()
{
    switch (m_gamestate) {
    case Bankrupt:
        money = 1000;
        UpdateAccount(0);
        goto_State(Start);
        ui->last_win->setText("Coming out of bankruptcy");
        break;
    case Start:
        UpdateAccount(- bet);
        goto_State(Pick);
        break;
    case Pick:
        if (!UserGoofed()) {
            ReplenishHand();
            goto_State(Refilling);
        }
        break;
    case Results:
        goto_State(Start);
        break;
    }
    if (QTime::currentTime() > m_refreshTime && QTime::currentTime() <= m_refresh_limit_Time) {
        OAuth2 auth(this, &m_network);
        auth.GetTokensFromRefreshToken(m_refreshToken);
    }
}
Exemple #2
0
void TDBAccountsPrivate::_q_on_AccountAdded(const TAccount &Account)
   {
      ASSERT(Accounts)
      qDebug() << "TDBAccountsPrivate::AddNodeToDB" << Account << "to be added";
      DbIo()->InsertKeyIntoTable(AccountsTableName, Account.UserName(), "UserName");
      UpdateAccount(Account);
   }
Exemple #3
0
void MainWindow::SetupMoney()
{
    hands_since_last_money_update = 0;
    if (m_money_file_id != "") {
        m_network.DownloadMoneyFile(m_money_file_id, GetMoneyFilename());
    }
    else {
        money = 1000; //no existing money file, start with default 1000
        UpdateAccount(0);
        goto_State(Start);
    }
}
MojErr ScheduleRetryCommand::CancelActivitiesDone()
{
	CommandTraceFunction();

	try {
		m_deleteActivitiesCommand->GetResult()->CheckException();

		UpdateAccount();
	} CATCH_AS_FAILURE

	return MojErrNone;
}
Exemple #5
0
	int OnApply()
	{
		const wchar_t* errorMsg = UpdateAccount();
		if(errorMsg != 0)
		{
			MessageBox(errorMsg, L"Unable to Update Account", MB_OK);

			return PSNRET_INVALID;
		}

		_password = Password;
		return PSNRET_NOERROR;
	}
Exemple #6
0
void MainWindow::ReadMoneyFile()
{
    QFile moneyFile(GetMoneyFilename());
    money = 1000;
    if (moneyFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&moneyFile);
        QString moneyline = in.readLine();
        QString hashline = in.readLine();
        moneyFile.close();
        if (GetHash(m_user_id, moneyline) == hashline)
            money = moneyline.toInt();
    }
    UpdateAccount(0);
    goto_State(Start);
}
MojErr ScheduleRetryCommand::CancelActivitiesDone()
{
	try {
		m_deleteActivitiesCommand->GetResult()->CheckException();

		UpdateAccount();
	} catch (const std::exception& e) {
		MojLogError(m_log, "Exception in cancel activities done: '%s'", e.what());
		Failure(e);
	} catch (...) {
		MojLogError(m_log, "Unknown exception in cancel activities done");
		Failure(MailException("Unknown exception in cancel activities done", __FILE__, __LINE__));
	}

	return MojErrNone;
}
Exemple #8
0
void MainWindow::ReportJackpotUpload(QString etag)
{
    int payout = lastJackpotWin + saved_progressive_win;
    m_jackpot_etag = etag;
    saved_progressive_win = 0;
    lastJackpotWin =0;
    // we upload the jackpots because of a win or enough losses
    if (payout > 0) {
        ui->result_msg->setText(QString("You won $%1").arg(payout));
        DoCelebrate(Large);
    }
    UpdateAccount(payout);
    jackpot_kitty = 0;
    lastJackpotRank = eBust;
    UpdateJackpots();
    EndOfHand();
}
Exemple #9
0
void MainWindow::Evaluate()
{
    QString deb = QString("%1 + ").arg(hand[0]) +QString("%1+").arg(hand[1])+QString("%1+").arg(hand[2]) + QString("%1+").arg(hand[3])+ QString("%1+").arg(hand[4]);
    //ui->debug->setText(deb);
    HandRank rank = EvaluateHand(hand);
    //rank = eTwoPair; //! uncomment to test wins. You cheater.
    if (rank > eBust)
        ui->last_win->setText(QString("last win was: ") + QString(RankToText(rank)));
    int payout = bet * BasePayout(rank);
    lastJackpotWin = 0;
    saved_progressive_win = 0;
    lastJackpotRank = eBust; //aka none
    if (rank >= eStraight) {
        lastJackpotWin = payout; // start with payout and add progressive
        lastJackpotRank = rank;
        WonJackpot(rank);
    }
    else {
        if (rank == ePair)
            DoCelebrate(Small);
        else if (rank > ePair){
            DoCelebrate(Medium);
        }
        if (payout > 0) {
            ui->result_msg->setText(QString("You won $%1").arg(payout));
        }
        else {
            loss_count++;
            jackpot_kitty += bet * 3 / 2;
            ui->result_msg->setText("So close! Try again.");
            if (loss_count > 5) {
                WriteJackpotsAndWinners();
                UploadJackpotsFile();
            }
            PlaySound("too bad.mp3");
        }
        UpdateAccount(payout);
    }
}
LRESULT	AccountEditorDialog::OnEdit(WORD, WORD, HWND, BOOL&)
{
	// Get the selected Account.
	int index = _userAccounts.GetSelectedIndex();
	if(index == -1)
		return 0;
	
	Account* account = reinterpret_cast<Account*>(_userAccounts.GetItemData(index));
	Assert(account != 0);
	if(account == 0)
		return 0;

	// Display the account properties.
	AccountEditorPage page(account, _passwords[account]);
	if(page.DoModal() == IDOK)
	{
		// Try to update. The property sheet is responsible for data validation.
		const wchar_t* errorMessage = UpdateAccount(account, page);
		if(errorMessage != 0)
		{
			MessageBox(errorMessage, L"Unable to Edit Account", MB_OK);

			return 0;
		}

		_passwords[page.ThisAccount] = String(page.General.Password);

		AccountUpdateEvent e;
		e.Account = account;
		e.Invoke();

		Refresh();
	}

	return 0;
}
Exemple #11
0
void AccountMgr::ReloadAccounts(bool silent)
{
	setBusy.Acquire();
	if(!silent) sLog.outString("[AccountMgr] Reloading Accounts...");

	// Load *all* accounts.
	QueryResult * result = sLogonSQL->Query("SELECT acct, login, password, gm, flags, banned, forceLanguage, muted FROM accounts");
	Field * field;
	string AccountName;
	set<string> account_list;
	Account * acct;

	if(result)
	{
		do 
		{
			field = result->Fetch();
			AccountName = field[1].GetString();

			// transform to uppercase
			HEARTHSTONE_TOUPPER(AccountName);

			//Use private __GetAccount, for locks
			acct = __GetAccount(AccountName);
			if(acct == 0)
			{
				// New account.
				AddAccount(field);
			}
			else
			{
				// Update the account with possible changed details.
				UpdateAccount(acct, field);
			}

			// add to our "known" list
			account_list.insert(AccountName);

		} while(result->NextRow());
		delete result;
	}

	// check for any purged/deleted accounts
#ifdef WIN32
	HM_NAMESPACE::hash_map<string, Account*>::iterator itr = AccountDatabase.begin();
	HM_NAMESPACE::hash_map<string, Account*>::iterator it2;
#else
	std::map<string, Account*>::iterator itr = AccountDatabase.begin();
	std::map<string, Account*>::iterator it2;
#endif

	for(; itr != AccountDatabase.end();)
	{
		it2 = itr;
		++itr;

		if(account_list.find(it2->first) == account_list.end())
		{
			delete it2->second;
			AccountDatabase.erase(it2);
		}
		else
		{
			it2->second->UsernamePtr = (std::string*)&it2->first;
		}
	}

	if(!silent) sLog.outString("[AccountMgr] Found %u accounts.", AccountDatabase.size());
	setBusy.Release();

	IPBanner::getSingleton().Reload();
}