Search in sources :

Example 1 with SkillLevel

use of mage.constants.SkillLevel in project mage by magefree.

the class NewTableDialog method onLoadSettings.

private void onLoadSettings(int version) {
    String versionStr = "";
    switch(version) {
        case -1:
            // default (empty)
            versionStr = "-1";
            break;
        case 1:
            versionStr = "1";
            break;
        case 2:
            versionStr = "2";
            break;
        default:
            versionStr = "";
            break;
    }
    txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, "Game"));
    txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, ""));
    String playerTypes = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES + versionStr, "Human");
    prefPlayerTypes.clear();
    for (String pType : playerTypes.split(",")) {
        prefPlayerTypes.add(PlayerType.getByDescription(pType));
    }
    this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS + versionStr, "2")));
    String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE + versionStr, "Two Player Duel");
    for (GameTypeView gtv : SessionHandler.getGameTypes()) {
        if (gtv.getName().equals(gameTypeName)) {
            cbGameType.setSelectedItem(gtv);
            break;
        }
    }
    int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT + versionStr, "1500"));
    for (MatchTimeLimit mtl : MatchTimeLimit.values()) {
        if (mtl.getTimeLimit() == timeLimit) {
            this.cbTimeLimit.setSelectedItem(mtl);
            break;
        }
    }
    cbDeckType.setSelectedItem(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE + versionStr, "Limited"));
    String deckFile = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, null);
    if (deckFile != null) {
        this.player1Panel.setDeckFile(deckFile);
    }
    this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, "2")));
    this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, "Yes").equals("Yes"));
    this.chkSpectatorsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, "Yes").equals("Yes"));
    this.chkPlaneChase.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, "No").equals("Yes"));
    this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, "No").equals("Yes"));
    this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
    this.cbMulligan.setSelectedItem(MulliganType.valueByName(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_MULLIGAN_TYPE + versionStr, MulliganType.GAME_DEFAULT.toString())));
    int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, "0"));
    for (RangeOfInfluence roi : RangeOfInfluence.values()) {
        if (roi.getRange() == range) {
            this.cbRange.setSelectedItem(roi);
            break;
        }
    }
    String attackOption = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, "Attack Multiple Players");
    for (MultiplayerAttackOption mao : MultiplayerAttackOption.values()) {
        if (mao.toString().equals(attackOption)) {
            this.cbAttackOption.setSelectedItem(mao);
            break;
        }
    }
    String skillLevelDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, "Casual");
    for (SkillLevel skillLevel : SkillLevel.values()) {
        if (skillLevel.toString().equals(skillLevelDefault)) {
            this.cbSkillLevel.setSelectedItem(skillLevel);
            break;
        }
    }
    this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, "100")));
    this.spnMinimumRating.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_MINIMUM_RATING + versionStr, "0")));
    this.spnEdhPowerLevel.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_EDH_POWER_LEVEL + versionStr, "0")));
}
Also used : SkillLevel(mage.constants.SkillLevel) RangeOfInfluence(mage.constants.RangeOfInfluence) MatchTimeLimit(mage.constants.MatchTimeLimit) GameTypeView(mage.view.GameTypeView) MultiplayerAttackOption(mage.constants.MultiplayerAttackOption)

Example 2 with SkillLevel

use of mage.constants.SkillLevel in project mage by magefree.

the class NewTournamentDialog method onLoadSettings.

private void onLoadSettings(int version) {
    String versionStr = prepareVersionStr(version, false);
    int numPlayers;
    txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME + versionStr, "Tournament"));
    txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PASSWORD + versionStr, ""));
    int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT + versionStr, "1500"));
    for (MatchTimeLimit mtl : MatchTimeLimit.values()) {
        if (mtl.getTimeLimit() == timeLimit) {
            this.cbTimeLimit.setSelectedItem(mtl);
            break;
        }
    }
    String skillLevelDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, "Casual");
    for (SkillLevel skillLevel : SkillLevel.values()) {
        if (skillLevel.toString().equals(skillLevelDefault)) {
            this.cbSkillLevel.setSelectedItem(skillLevel);
            break;
        }
    }
    int constructionTime = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME + versionStr, "600")) / 60;
    if (constructionTime < CONSTRUCTION_TIME_MIN || constructionTime > CONSTRUCTION_TIME_MAX) {
        constructionTime = CONSTRUCTION_TIME_MIN;
    }
    this.spnConstructTime.setValue(constructionTime);
    String tournamentTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE + versionStr, "Sealed Elimination");
    for (TournamentTypeView tournamentTypeView : SessionHandler.getTournamentTypes()) {
        if (tournamentTypeView.getName().equals(tournamentTypeName)) {
            cbTournamentType.setSelectedItem(tournamentTypeView);
            break;
        }
    }
    this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
    this.cbMulligan.setSelectedItem(MulliganType.valueByName(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_MULLIGUN_TYPE + versionStr, MulliganType.GAME_DEFAULT.toString())));
    this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS + versionStr, "2")));
    this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO + versionStr, "100")));
    this.spnMinimumRating.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_MINIMUM_RATING + versionStr, "0")));
    TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
    activatePanelElements(tournamentType);
    if (tournamentType.isLimited()) {
        if (tournamentType.isDraft()) {
            numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT + versionStr, "4"));
            prepareTourneyView(numPlayers);
            if (tournamentType.isRandom() || tournamentType.isRichMan()) {
                loadRandomPacks(version);
            } else {
                loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT + versionStr, ""));
            }
            String draftTiming = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING + versionStr, "REGULAR");
            for (TimingOption timingOption : DraftOptions.TimingOption.values()) {
                if (timingOption.toString().equals(draftTiming)) {
                    cbDraftTiming.setSelectedItem(draftTiming);
                    break;
                }
            }
        } else {
            numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED + versionStr, "2"));
            prepareTourneyView(numPlayers);
            loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED + versionStr, ""));
        }
    }
    this.cbAllowSpectators.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS + versionStr, "Yes").equals("Yes"));
    this.cbPlaneChase.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLANE_CHASE + versionStr, "No").equals("Yes"));
    this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS + versionStr, "Yes").equals("Yes"));
    this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED + versionStr, "No").equals("Yes"));
}
Also used : SkillLevel(mage.constants.SkillLevel) TournamentTypeView(mage.view.TournamentTypeView) MatchTimeLimit(mage.constants.MatchTimeLimit) TimingOption(mage.game.draft.DraftOptions.TimingOption)

Aggregations

MatchTimeLimit (mage.constants.MatchTimeLimit)2 SkillLevel (mage.constants.SkillLevel)2 MultiplayerAttackOption (mage.constants.MultiplayerAttackOption)1 RangeOfInfluence (mage.constants.RangeOfInfluence)1 TimingOption (mage.game.draft.DraftOptions.TimingOption)1 GameTypeView (mage.view.GameTypeView)1 TournamentTypeView (mage.view.TournamentTypeView)1