int main()
{
int tmp = 0;
    while(cin.peek()!=EOF)
    {
//cout << tmp++ << endl;
        clearCards(black);
        clearCards(white);
        getCards(black);
        getCards(white);
//displayCards(white);
//displayCards(black);
        switch(winner())
        {
            case 1:
                cout << "Black wins." << endl;
                break;
            case -1:
                cout << "White wins." << endl;
                break;
            case 0:
                cout << "Tie." << endl;
                break;
            default:
                cout << "bad value: " << winner() << endl;
        }
//cout << endl << endl << endl;
    while(cin.peek()=='\n')cin.get();
    }
    //system("PAUSE");
    return 0;
}
Exemple #2
0
void dynpm(GtkWidget *widget, gpointer data){
    char **cards = getCards((char*) DEFAULT_DRM_DIR);
    if (cards == NULL) {
        g_printerr("Card list is empty.\n");
        return;
    }

    int idx = 0;
    while (cards[idx] != NULL) {
        g_print("Found card: %s\n", cards[idx]);

        if (canModifyPM()) {
            g_print("Setting dynpm\n");
            setMethod(cards[idx], DYNPM);
            g_print("method = %d\n", getMethod(cards[idx]));
            if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
                g_print("profile = %d\n", getProfile(cards[idx]));
            }
        } else {
            g_print("Insufficient permission to modify PM method\n");
        }
        idx++;
    }
    freeCards(cards);
}
TTRCard *TTRPlayer::getCard(char c) {
    TTRCard **hand = getCards();
    for (int i=0; i<nColors+1; i++)
        if (hand[i]->getColor() == c)
            return hand[i];

    return NULL;
}
Exemple #4
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    init();

    buttons = getCards();
    colorCards();
    makeTimerProgressBar();
    makeSignalMapper();
    makeNameMapper();
}
Exemple #5
0
AlsaWork::AlsaWork()
: cardList_(std::vector<std::string>())
{
	getCards();
	int id = 0;
	std::for_each(cardList_.begin(), cardList_.end(), [&](const std::string &name){
		devices_.push_back(AlsaDevice::Ptr(new AlsaDevice(id, name)));
		++id;
	});
	setCurrentCard(0);
	setCurrentMixer(0);
}
Exemple #6
0
QList<int> ServerPlayer::forceToDiscard(int discard_num, bool include_equip){
    QList<int> to_discard;

    QString flags = "h";
    if(include_equip)
        flags.append("e");

    QList<const Card *> all_cards = getCards(flags);
    qShuffle(all_cards);

    int i;
    for(i=0; i<discard_num; i++)
        to_discard << all_cards.at(i)->getId();

    return to_discard;
}
Exemple #7
0
/**
 * 
 * @param widget
 * @param data
 */
static void
print_hello(GtkWidget *widget,
        gpointer data) {
    
    char **cards = getCards((char*) DEFAULT_DRM_DIR);
    if (cards == NULL) {
        g_printerr("Card list is empty.\n");
        return;
    }

    int idx = 0;
    while (cards[idx] != NULL) {
        g_print("Found card: %s\n", cards[idx]);

        g_print("method = %d\n", getMethod(cards[idx]));
        if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
            g_print("profile = %d\n", getProfile(cards[idx]));
        }

        if (canModifyPM()) {
            g_print("Setting dynpm\n");
            setMethod(cards[idx], DYNPM);
            g_print("method = %d\n", getMethod(cards[idx]));
            if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
                g_print("profile = %d\n", getProfile(cards[idx]));
            }

            g_print("Setting low profile\n");
            setMethod(cards[idx], PROFILE);
            setProfile(cards[idx], LOW);
            g_print("method = %d\n", getMethod(cards[idx]));
            if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
                g_print("profile = %d\n", getProfile(cards[idx]));
            }
        }

        g_print("Current temperature: %d\n", getTemperature(cards[idx]));

        idx++;
    }
    freeCards(cards);

}
Exemple #8
0
//====================================
// getHeads
//------------------------------------
int SaXManipulateCard::getHeads ( void ) {
	// .../
	//! returns the number of configurable VGA heads This value may
	//! differ from the getCards() return value because there are
	//! possibly more than one head available on one card
	// ----
	if (! mImport) {
		return -1;
	}
	int mBoards  = getCards();
	int mDevices = mImport -> getCount();
	//====================================
	// check for NoteBooks, assume *2
	//------------------------------------
	if ( isNoteBook() ) {
		return mBoards * 2;
	}
	//====================================
	// get sysp card name
	//------------------------------------
	SaXImportSysp* pCard = new SaXImportSysp (SYSP_CARD);
	pCard -> doImport();
	QString mCardName;
	QTextOStream (&mCardName) <<
		pCard->getItem("Vendor") << ":" << pCard->getItem("Device");
	//====================================
	// import CDB DB for profile names
	//------------------------------------
	SaXProcess* pCDB = new SaXProcess();
	pCDB -> start ( CDB_CARDS );
	QDict< QDict<QString> > CDBData = pCDB -> getTablePointerCDB();
	//====================================
	// check profile names
	//------------------------------------
	int headCount = 0;
	int realCount = 0;
	int currentCard = mCard;
	while (1) {
		if (realCount >= mDevices) {
			selectCard (currentCard);
			return headCount;
		}
		selectCard (realCount);
		if ( CDBData[mCardName] ) {
			QDict<QString> CDBTable = *CDBData[mCardName];
			if (CDBTable["Profile"]) {
				QString mProfile = *CDBTable["Profile"];
				if (mProfile == "NVidia_DualHead_DriverOptions") {
					headCount += 2;
					realCount += 1;
					continue;
				}
				if (mProfile == "NVidia_DualHead") {
					headCount += 2;
					realCount += 2;
					continue;
				}
				if (mProfile == "Radeon_DualHead_DriverOptions") {
					headCount += 2;
					realCount += 1;
					continue;
				}
				if (mProfile == "Radeon_DualHead") {
					headCount += 2;
					realCount += 2;
					continue;
				}
				if (mProfile == "FGLRX_DualHead_DriverOptions") {
					headCount += 2;
					realCount += 1;
					continue;
				}
				if (mProfile == "FGLRX_DualHead") {
					headCount += 2;
					realCount += 2;
					continue;
				}
				if (mProfile == "Matrox_G400") {
					headCount += 2;
					realCount += 2;
					continue;
				}
				if (mProfile == "Matrox_G450") {
					headCount += 2;
					realCount += 2;
					continue;
				}
				if (mProfile == "Matrox_G550") {
					headCount += 2;
					realCount += 2;
					continue;
				}
			}
		}
		realCount++;
		headCount++;
	}
	//====================================
	// return board count, last chance
	//------------------------------------
	return mBoards;
}
Exemple #9
0
void singlePlayer(GlobalState* globalData) {
    static int tempScore = 0;
    static int transition = 0;
    static int movedone = 0;
    // First time playing?
    // Read first time from SRAM
    if (globalData->firstTime == TRUE) {
        if (globalData->newKeyboard) {
            printKeyboard(globalData, "NAME?", 5);
        } else {
            processKeyboard(globalData, game.name, 5);
        }
    }
    if (globalData->doneKeyboard) {
        globalData->firstTime = FALSE;


        if (globalData->newGame) {
            globalData->newGame = 0;
            // Setup new game
            setupGame();
            tempScore = 0;
            transition = 0;
            game.turn = rand() % 2;
            printGame(globalData);
            getCards(); // Assume cards already read by interrupts on switches (?)
        }


        // Wait till someone presses D to continue
        if (globalData->keyPress == 0x0D) {
            transition = 1;
        }

        // Begin game with computer
        if (transition) {
            if (!game.gameOver) {
                // Situation depends on game.turn
                if (game.turn) {
                    if (game.moveSel == 0) {
                        pickMove(globalData);
                    }
                    if (game.moveSel == 1) {

                        tempScore = game.oppScore;
                        game.oppScore = attack(game.myMove, game.myMonster, game.oppScore);
                        if (game.oppScore == tempScore) {
                            prints(0, 10, RED, BLACK, "                    ", 1);
                            prints(0, 18, RED, BLACK, "                    ", 1);
                            prints(0, 26, RED, BLACK, "                    ", 1);
                            prints(0, 10, RED, BLACK, "Missed!", 1);
                        } else {
                            prints(0, 10, RED, BLACK, "                    ", 1);
                            prints(0, 18, RED, BLACK, "                    ", 1);
                            prints(0, 26, RED, BLACK, "                    ", 1);
                            prints(0, 10, RED, BLACK, "Your", 1);
                            printrs(30, 10, RED, BLACK, game.myMonster->monsterName, 1);
                            prints(84, 10, RED, BLACK, "used", 1);
                            printrs(0, 18, RED, BLACK, game.myMove->moveName, 1);
                            prints(0, 26, RED, BLACK, "-    ", 1);
                            integerprint(6, 26, RED, BLACK, tempScore - game.oppScore, 1);
                        }
                        game.moveSel = 0;
                        movedone = 1;
                    }
                } else {
                    // Computer randomly picks a monster and attack
                    game.oppMonster = &myMonsterList[rand() % 3 ];
                    game.oppMove = &game.oppMonster->movelist[rand() % 3];
                    tempScore = game.myScore;
                    game.myScore = attack(game.oppMove, game.oppMonster, game.myScore);
                    if (game.myScore == tempScore) {
                        prints(0, 10, RED, BLACK, "                    ", 1);
                        prints(0, 18, RED, BLACK, "                    ", 1);
                        prints(0, 26, RED, BLACK, "                    ", 1);
                        prints(0, 10, RED, BLACK, "Enmy Missed!", 1);
                    } else {
                        prints(0, 10, RED, BLACK, "                    ", 1);
                        prints(0, 18, RED, BLACK, "                    ", 1);
                        prints(0, 26, RED, BLACK, "                    ", 1);
                        prints(0, 10, RED, BLACK, "Enmy", 1);
                        printrs(30, 10, RED, BLACK, game.oppMonster->monsterName, 1);
                        prints(84, 10, RED, BLACK, "used", 1);
                        printrs(0, 18, RED, BLACK, game.oppMove->moveName, 1);
                        prints(0, 26, RED, BLACK, "-    ", 1);
                        integerprint(6, 26, RED, BLACK, tempScore - game.myScore, 1);
                    }
                    movedone = 1;
                }

                if (movedone == 1) {
                    prints(0, 40, YELLOW, BLACK, "Your Score: ", 1);
                    prints(0, 55, YELLOW, BLACK, "     ", 1);
                    integerprint(0, 55, YELLOW, BLACK, game.myScore, 1);
                    prints(0, 70, WHITE, BLACK, "Opponent Score: ", 1);
                    prints(0, 85, WHITE, BLACK, "     ", 1);
                    integerprint(0, 85, WHITE, BLACK, game.oppScore, 1);
                    // Check game status
                    game.gameOver = gameStatus();
                    game.turn = !game.turn;
                    transition = 0;
                    movedone = 0;
                }
                //                if (game.gameOver == 1) {
                //                    if (globalData->newGame == 0) {
                //                        printResults();
                //                    }
                //                }
            } else {
                if (globalData->newGame == 0) {
                    printResults();
                }
            }
        }
        // Display results once there is a lost
    }
}
Exemple #10
0
int main(int argc,
        char *argv[]) {
    GtkBuilder *builder;
    GObject *window;
    GObject *button;
    GObject *textView;
    GtkToggleButton *toggle;
    char **cardNames;
	int i;
	
    gtk_init(&argc, &argv);

    /* Construct a GtkBuilder instance and load our UI description */
    builder = gtk_builder_new();
    gtk_builder_add_from_file(builder, "pmgui.ui", NULL);

    /* Connect signal handlers to the constructed widgets. */
    window = gtk_builder_get_object(builder, "window");
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    GObject *cards = gtk_builder_get_object(builder, "cmb_cards");
    g_signal_connect(cards, "changed", G_CALLBACK(changeCard), NULL);
	
	//Add all cards to combo box
	cardNames = getCards((char*) DEFAULT_DRM_DIR);
	if (cardNames != NULL){
		while (*cardNames != NULL){
			g_print("Adding card %s\n", *cardNames);
			//XXX: Add some identifying information to the card names (model/brand/etc).
			//XXX: During detection, store a chipset manufacturer (AMD/Nv) somewhere.
			//XXX: Either store a list of names, a list of descriptions, list of manufacturers, etc..
			//     Or use a standardized delimiter to make parsing easy.
			gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( cards ), *cardNames );
			cardNames++;
		}
		freeCards(cardNames);
	}

    toggle = (GtkToggleButton*)gtk_builder_get_object(builder, "tgl_root");
    if (canModifyPM())
        gtk_toggle_button_set_active(toggle, TRUE);
    else
        gtk_toggle_button_set_active(toggle, FALSE);
	g_signal_connect(toggle, "toggled", G_CALLBACK(toggleLocked), NULL);

	//XXX: Change the dynpm/profile switch into a sliding toggle.
	//XXX: Move the profile selection to a visually distinct area from the dynpm/profile switch.
	button = gtk_builder_get_object(builder, "btn_dynpm");
    g_signal_connect(button, "clicked", G_CALLBACK(dynpm), NULL);

    button = gtk_builder_get_object(builder, "btn_default");
    g_signal_connect(button, "clicked", G_CALLBACK(changePMProfile), &pm_profiles[DEFAULT]);

    button = gtk_builder_get_object(builder, "btn_auto");
    g_signal_connect(button, "clicked", G_CALLBACK(changePMProfile), &pm_profiles[AUTO]);
    
    button = gtk_builder_get_object(builder, "btn_low");
    g_signal_connect(button, "clicked", G_CALLBACK(changePMProfile), &pm_profiles[LOW]);

    button = gtk_builder_get_object(builder, "btn_medium");
    g_signal_connect(button, "clicked", G_CALLBACK(changePMProfile), &pm_profiles[MEDIUM]);

    button = gtk_builder_get_object(builder, "btn_high");
    g_signal_connect(button, "clicked", G_CALLBACK(changePMProfile), &pm_profiles[HIGH]);

    button = gtk_builder_get_object(builder, "quit");
    g_signal_connect(button, "clicked", G_CALLBACK(gtk_main_quit), NULL);

    textView = gtk_builder_get_object(builder, "txt_temperature");
    g_signal_connect(textView, "move-cursor", G_CALLBACK(print_hello), NULL);
    
	//XXX: Set the current index/text for the combo box to the first card in the list.
	//XXX: use the changeCard callback
	
    gtk_main();

    return 0;
}