Example #1
0
bool GameSettings::newAward()
{
    if (!profileOptions)
        return false;

    for (int x = Options::BEGIN_AWARDS; x < Options::SET_UNLOCKS + setlist.size(); x++)
    {
        GameOptionAward * goa = dynamic_cast<GameOptionAward *> (profileOptions->get(x));
        if (!goa)
            continue;
        if (!goa->isViewed())
            return true;
    }
    return false;
}
Example #2
0
void GameSettings::checkProfile()
{
    if (!globalOptions)
        globalOptions = NEW GameOptions(GLOBAL_SETTINGS);

    //If it doesn't exist, load current profile.
    if (!profileOptions)
    {
        profileOptions = NEW GameOptions(profileFile(PLAYER_SETTINGS, "", false));
        //Backwards compatibility hack for unlocked modes.
        for (int x = Options::BEGIN_AWARDS; x < Options::LAST_NAMED; x++)
        {
            GameOptionAward * goa = dynamic_cast<GameOptionAward *> (globalOptions->get(x));
            if (goa)
            {
                GameOptionAward * dupe = dynamic_cast<GameOptionAward *> (profileOptions->get(x));
                if (dupe && goa->number && !dupe->number)
                    dupe->giveAward();
            }
        }
    }

    //Validation of collection, etc, only happens if the game is up.
    if (theGame == NULL || MTGCollection() == NULL)
        return;

    string pcFile = profileFile(PLAYER_COLLECTION, "", false);
    if (!pcFile.size() || !fileExists(pcFile.c_str()))
    {
        //If we had any default settings, we'd set them here.

        //Create proper directories
        createProfileFolders();
    }

    //Find the set for which we have the most variety
    int setId = -1;
    int maxcards = 0;
    int ok = 0;
    for (int i = 0; i < setlist.size(); i++)
    {
        int value = MTGCollection()->countBySet(i);
        if (value > maxcards)
        {
            maxcards = value;
            setId = i;
        }
        if (options[Options::optionSet(i)].number)
        {
            ok = 1;
            break;
        }
    }
    if (!ok && setId >= 0)
    {
        //Save this set as "unlocked"
        (*profileOptions)[Options::optionSet(setId)] = 1;
        profileOptions->save();

        //Give the player their first deck
        createUsersFirstDeck(setId);
    }
    getStyleMan()->determineActive(NULL, NULL);
}
Example #3
0
void GameStateShop::ButtonPressed(int controllerId, int controlId)
{
    int sel = bigSync.getOffset();
    switch (controllerId)
    {
    case -102: //Buying something...
        mStage = STAGE_SHOP_PURCHASE;
        if (menu)
            menu->Close();
        mBuying = controlId;
        return;
    case -145:
        if (controlId == -1)
        { //Nope, don't buy.
            if (sel < BOOSTER_SLOTS)
                cancelBooster(sel);
            else
                cancelCard(sel);
            menu->Close();
            mStage = STAGE_SHOP_SHOP;
            return;
        }
        if (sel > -1 && sel < SHOP_ITEMS)
        {
            if (controlId == -2)
                playerdata->credits += mPrices[sel]; //We stole it.
            if (sel < BOOSTER_SLOTS) //Clicked a booster.
                purchaseBooster(sel);
            else
                purchaseCard(sel);

            //Check if we just scored an award...
            if (myCollection && myCollection->totalPrice() > 10000)
            {
                GameOptionAward * goa = dynamic_cast<GameOptionAward *> (&options[Options::AWARD_COLLECTOR]);
                if (goa) goa->giveAward();
            }
        }
        mStage = STAGE_SHOP_SHOP;
        return;
    }
    //Basic Menu.
    switch (controlId)
    {
    case 12:
        if (taskList)
            taskList->save();
        mStage = STAGE_SHOP_SHOP;
        mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
        save();
        GameStateMenu::genNbCardsStr();
        break;
    case 14:
        mStage = STAGE_SHOP_TASKS;
        if (!taskList)
            taskList = NEW TaskList();
        taskList->Start();
        break;
    case 15:
        if (taskList)
            taskList->End();
        break;
    case 22:
        beginFilters();
        break;
    case -2:
        playerdata->credits += 1000;
    default:
        mStage = STAGE_SHOP_SHOP;
    }
    menu->Close();
}