Search in sources :

Example 1 with MultiplayerAttackOption

use of mage.constants.MultiplayerAttackOption 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)

Aggregations

MatchTimeLimit (mage.constants.MatchTimeLimit)1 MultiplayerAttackOption (mage.constants.MultiplayerAttackOption)1 RangeOfInfluence (mage.constants.RangeOfInfluence)1 SkillLevel (mage.constants.SkillLevel)1 GameTypeView (mage.view.GameTypeView)1