Example #1
0
void Game::findDefeat()
{
    if(pl.getPosition().y >= m.size.y) // gracz spadł za mapę
        defeat("by downing");

    if(pl.getHP() <= 0.0f)
        defeat("your HP is 0!");
}
Example #2
0
int Play::Trick::getWinner(){

    std::vector<PlayerAndCard>::iterator actualWinner = cards.begin(); //iterator tu to rozwiązanie tymczasowe z braku lepszego na ten moment

    for(std::vector<PlayerAndCard>::iterator it = cards.begin()+1; it != cards.end(); it++)
        if( defeat( actualWinner->card, it->card ))
            actualWinner = it;

    return actualWinner->player;
}
Example #3
0
Field::Field(QWidget *parent) :
    QWidget{parent}
    , f_layout{new QGridLayout}
    , settings{new Settings}
    , cells_are_filled{false}
    , won{false}
    , date{QDate::currentDate()}
{
    setAttribute(Qt::WA_DeleteOnClose);
    getSettings();
    const int a = 32;
    parentWidget()->resize(a * cols, a * rows + 60);
    parentWidget()->setMinimumSize(a * cols / 1.4, a * rows / 1.4);
    f_layout->setMargin(0);
    f_layout->setSpacing(0);
    cells = QVector<QVector<Cell*>>(rows + 2, QVector<Cell*>(cols + 2));

    for(int row = 0; row < cells.size(); row++) {
        for(int col = 0; col < cells[row].size(); col++) {
            if(!row || !col || row == cells.size() - 1 || col == cells[row].size() - 1) {
                cells[row][col] = new Cell(row, col, false, this);
            } else {
                cells[row][col] = new Cell(row, col, true, this);
                connect(cells[row][col], SIGNAL(zeroBombNeighbours(QPoint)),
                        SLOT(openNeighbours(QPoint))
                       );
                connect(cells[row][col], SIGNAL(cellOpened()),
                        SLOT(testIfWin())
                       );
                connect(cells[row][col], SIGNAL(defeat()),
                        SLOT(defeatGame())
                       );
                connect(cells[row][col], SIGNAL(beforeOpened(int, int)),
                        SLOT(fillCells(int, int))
                       );
                f_layout->addWidget(cells[row][col], row - 1, col - 1);
            }

            QApplication::processEvents();
        }
    }

    qsrand(QTime::currentTime().msec());
    setLayout(f_layout.data());
}
Example #4
0
void MazePlugin::syscall(State *s, int status, int syscallNo, int valueOfa0) {
   Q_UNUSED(status);

   switch(syscallNo) {
      case S_MAZE_INIT:
         s->setRegister(v0, init_maze(s));
         break;
      case S_MAZE_DEFEAT:
         defeat();
         break;
      case S_MAZE_VICTORY:
         victory();
         break;
      case S_MAZE_IS_GOAL:
         s->setRegister(v0, is_goal(s, valueOfa0));
         break;
      case S_MAZE_NEIGHBOR:
         {
            int results[4];
            get_neighbors(s, valueOfa0, results);
            unsigned int addr = s->getRegister(a1);

            for(int i = 0; i < 4; ++i)
               s->setMemoryWord(addr + (i << 2), results[i]);
         }
         break;
      case S_MAZE_DRAW_ARROW:
         draw_arrow(s, status, valueOfa0, s->getRegister(a1));
         break;
      case S_MAZE_IS_SEARCHED:
         s->setRegister(v0, is_searched(s, valueOfa0));
         break;
      default:
         break;
   }
}