Exemple #1
0
int battle(int monsterspeed, int monsterattack, string enemyType)
{
    int battlerun = 1;
    //Battle Loop
    while (battlerun == 1)
    {
        madechoice = 0;
        while (madechoice == 0)
        {
            clearScreen();
	    //Main Battle Menu
            cout << menuBar;
            cout << "       " << enemyType << "Battle \n\n";
            displayEnemy(enemyType);
//	    healthMessage();
//	    magicMessage();
	    drunkMessage();
            cout << "Your attack is " << playersAttack << "\n";
            cout << "Your speed  is " << playersSpeed << "\n";
            cout << "Your AC is " << playersAC << "\n";
            cout << "           (1) Attack\n";
            cout << "           (2) Item Menu\n";
            cout << "           (3) Run Away\n\n";
            cout << menuBar;
            cin >> playerchoice;
            if (playerchoice == 2)
            {
                itemMenu();
            }
            else if (playerchoice == 3)
            {
                return 0;
            }
            else
            {
                madechoice = 1;
            }
        }
	//Checks if player's alive after player attack function
        bool stillAlive = playerAttack(playersSpeed, playersAttack, enemyType);
        if (stillAlive == false)
        {
            battlerun = 0;
            return 0;
        }
	//Checks if monster's alive after monster attack function
        stillAlive = monsterAttack(monsterspeed, monsterattack, enemyType);
        if (stillAlive == false)
        {
            battlerun = 0;
            return 1;
        }
    }
}
Exemple #2
0
ProjectsTree::ProjectsTree(TTCP *ttcp, QWidget *parent)
    : QMainWindow(parent)
{
    setupUi(this);
    setWindowFlags( windowFlags() & ~Qt::WindowMinimizeButtonHint );

    recentMenuClean = true;

    readSettings();

    recentMenu = new QMenu(this);
    alignmentGroup = new QActionGroup(this);

    recentMenu->setTitle(tr("projects"));
    recentMenu->setObjectName("project menu");
    recentMenu->setTearOffEnabled(true);

    TreeModel *model = new TreeModel(this);

    createActions();
    createViewActions();

    this->ttcp = ttcp;

#if defined TRAYPROJECT
    trayIcon = new QSystemTrayIcon();
    trayIconMenu = new QMenu();
    QIcon icon = QIcon(":/pics/active-icon-0.xpm");

    trayIconMenu->addAction(selectCurrentAction);
    trayIconMenu->addAction(timeEditAction);
    trayIconMenu->addAction(minimizeAction);
    trayIconMenu->addAction(maximizeAction);
    trayIconMenu->addAction(restoreAction);
    trayIconMenu->addAction(quitAction);

    trayIcon->setIcon(icon);
    trayIcon->setContextMenu(trayIconMenu);

    trayIcon->show();
#endif

    QStringList headers;
    headers << tr("Title") << tr("Description");

    view->setModel(model);
    view->resizeColumnToContents(0);
    QHeaderView *header = view->header();
    header->moveSection(0, 1);
    view->setColumnWidth(1, 100);
    view->hideColumn(2);
    header->setMovable(false);

    /*! \sa
     * MyTreeView::popMenu()
     * ProjectsTree::itemMenu()
     */
    connect(ttcp, SIGNAL(error(const QString &)), this, SLOT(p_error(const QString &)));
    connect(ttcp, SIGNAL(recentprojects(QList<int>&)), this, SLOT(updateRecentMenu(QList<int>&)));

    connect(view, SIGNAL(popMenu()), this, SLOT(itemMenu()));
    connect(view, SIGNAL(projPopMenu(int)), this, SLOT(projItemMenu(int)));

    connect(model, SIGNAL(get_time(int)), ttcp, SLOT(gettime(int)));
    connect(this, SIGNAL(changeProjectTo(int)), ttcp, SLOT(setProject(int)));

    connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    connect(view, SIGNAL(expanded(QModelIndex)),
            model, SLOT(expanded(QModelIndex)));

    connect(view, SIGNAL(collapsed(QModelIndex)),
            model, SLOT(collapsed(QModelIndex)));

    connect(ttcp, SIGNAL(disconnected()),
            view, SLOT(disable()));
    connect(ttcp, SIGNAL(connected()),
            view, SLOT(enable()));

    connect(ttcp, SIGNAL(add_entry(QString,int,int,QTime,QTime)),
            model, SLOT(add_entry(QString,int,int,QTime,QTime)));

    connect(ttcp, SIGNAL(current(int)),
            this, SLOT(setCurrent(int)));

    //! Unselect the view
    connect(ttcp, SIGNAL(current(int)),
            view, SLOT(clearSelection()));

    connect(ttcp, SIGNAL(current(int)),
            model, SLOT(set_current(int)));

    connect(ttcp, SIGNAL(settime(int, QTime, QTime)),
            model, SLOT(update_time(int, QTime, QTime)));

    connect(view->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));

#if defined TRAYPROJECT
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
	    this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
#endif

#if defined (Q_WS_X11)
    x11();
#endif

    updateActions();

    addNoteW = new Notes(ttcp, this);
    connect(ttcp, SIGNAL(accept_note(const QString &)), addNoteW, SLOT(notesDone(const QString &)));
    addTaskW = new AddProject(ttcp, this);
    connect(ttcp, SIGNAL(accept_project(const QString &)), addTaskW, SLOT(done(const QString &)));
    addAutoSelW = new AddAuto(ttcp, this);
    connect(ttcp, SIGNAL(accept_select(const QString &)), addAutoSelW, SLOT(autoDone(const QString &)));
    errorWin = new ErrorWindow(this);
    timeEditWin = new TimeEdit(ttcp, this);
    
    connect(timeEditAction, SIGNAL(triggered()), timeEditWin, SLOT(myShow()));
//    timeEditWin->myShow();
}