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); } }
void MainWindow::EndOfHand() { WriteMoneyFile(); UploadMoney(); if (money > 10) goto_State(Results); else goto_State(Bankrupt); }
static void build_right_epsilon_hints(Grammar *g) { int x, y, z; State *s, *ss; Elem *e; Rule *r; for (x = 0; x < g->states.n; x++) { s = g->states.v[x]; for (y = 0; y < s->items.n; y++) { e = s->items.v[y]; r = e->rule; if (e->kind != ELEM_END) { for (z = e->index; z < r->elems.n; z++) { if ((r->elems.v[z]->kind != ELEM_NTERM || !r->elems.v[z]->e.nterm->nullable)) goto Lnext; } ss = s; for (z = e->index; z < r->elems.n; z++) ss = goto_State(ss, r->elems.v[z]); if (ss && r->elems.n) vec_add(&s->right_epsilon_hints, new_Hint(r->elems.n - e->index - 1, ss, r)); else /* ignore for states_for_each_productions */; } Lnext:; } if (s->right_epsilon_hints.n > 1) qsort(s->right_epsilon_hints.v, s->right_epsilon_hints.n, sizeof(Hint*), hintcmp); } }
void MainWindow::WonJackpot(HandRank rank) { goto_State(WaitingForPayout); int jackpot_index = eRoyal - rank; saved_progressive_win = jackpots[jackpot_index] * bet / kMaxBet; jackpots[jackpot_index] -= saved_progressive_win; winners[jackpot_index] = m_username; WriteJackpotsAndWinners(); UploadJackpotsFile(); }
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); } }
// Initializer for main window MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_network(this), ui(new Ui::MainWindow) { m_gamestate = Login; loss_count =0; lastJackpotRank = eBust; //aka none for (int i=0; i<5; i++) { hand[i]=NOCARD; used[i]=NOCARD; } m_localFolder = QDir::tempPath(); ui->setupUi(this); ui->table_instructions->hide(); ui->tableName->setEnabled(false); ui->account->hide(); ui->action->hide(); ui->celebrate_pic->hide(); ui->tester->hide(); bet = 10; m_player = new QMediaPlayer(); m_player->setVolume(100); m_celebrate = None; //m_celebrate_start_y = ui->celebrate_pic->pos().y(); m_celebrate_offscreen_y = - ui->celebrate_pic->size().height(); m_anim_celebrate = new QPropertyAnimation(ui->celebrate_pic, "pos", this); m_anim_celebrate->setEasingCurve(QEasingCurve::OutBounce); m_anim_celebrate->setDuration(1500); m_anim_celebrate->setEndValue(ui->celebrate_pic->pos()); m_anim_celebrate->setStartValue(QPoint(ui->celebrate_pic->pos().x(), m_celebrate_offscreen_y)); m_anim_celebrate_fade = new QPropertyAnimation(ui->celebrate_pic, "pos", this); m_anim_celebrate_fade->setEasingCurve(QEasingCurve::InBounce); m_anim_celebrate_fade->setDuration(1000); m_anim_celebrate_fade->setEndValue(QPoint(this->width(), ui->celebrate_pic->pos().y())); m_anim_celebrate_fade->setStartValue(ui->celebrate_pic->pos()); for (int i=0; i<5; i++) { m_anim_deal_card[i] = new QPropertyAnimation(getButton(i), "pos", this); m_anim_deal_card[i]->setEasingCurve(QEasingCurve::OutQuad); m_anim_deal_card[i]->setDuration(400); QPoint pos = getButton(i)->pos(); m_anim_deal_card[i]->setEndValue(pos); m_anim_deal_card[i]->setStartValue(QPoint(this->width() /2 , - pos.ry())); } goto_State(Login); }
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); }