Merge pull request #1052 from brodee/master

code review comments for chaos/random booster draft:
This commit is contained in:
LevelX2 2015-06-24 06:56:45 +02:00
commit ca9e52f99b
13 changed files with 106 additions and 84 deletions

View file

@ -32,20 +32,19 @@ import java.util.ArrayList;
import java.util.List;
import mage.cards.ExpansionSet;
import java.util.Collections;
import java.lang.RuntimeException;
/**
*
* @author BrodyLodmell_at_googlemail.com
*/
public class ChaosBoosterDraft extends BoosterDraft {
public class RandomBoosterDraft extends BoosterDraft {
List<ExpansionSet> allSets;
List<ExpansionSet> usedBoosters;
public ChaosBoosterDraft(DraftOptions options, List<ExpansionSet> sets) {
List<ExpansionSet> useBoosters;
public RandomBoosterDraft(DraftOptions options, List<ExpansionSet> sets) {
super(options, sets);
if (sets.isEmpty()){
throw new RuntimeException("At least one set must be selected for chaos booster draft");
throw new RuntimeException("At least one set must be selected for random booster draft");
}
allSets = new ArrayList<>(sets);
resetBoosters();
@ -81,16 +80,16 @@ public class ChaosBoosterDraft extends BoosterDraft {
}
private ExpansionSet getNextBooster() {
if (0 == usedBoosters.size()){
if (0 == useBoosters.size()){
resetBoosters();
}
ExpansionSet theBooster = usedBoosters.get(0);
usedBoosters.remove(theBooster);
ExpansionSet theBooster = useBoosters.get(0);
useBoosters.remove(theBooster);
return theBooster;
}
private void resetBoosters(){
usedBoosters = new ArrayList<>(allSets);
Collections.shuffle(usedBoosters);
useBoosters = new ArrayList<>(allSets);
Collections.shuffle(useBoosters);
}
}

View file

@ -44,7 +44,7 @@ public class LimitedOptions implements Serializable {
protected String draftCubeName;
protected DraftCube draftCube;
protected int numberBoosters;
protected boolean isChaos;
protected boolean isRandom;
public List<String> getSetCodes() {
return sets;
@ -82,10 +82,10 @@ public class LimitedOptions implements Serializable {
this.numberBoosters = numberBoosters;
}
public boolean getIsChaos(){
return isChaos;
public boolean getIsRandom(){
return isRandom;
}
public void setIsChaos(boolean isChaos){
this.isChaos = isChaos;
public void setIsRandom(boolean isRandom){
this.isRandom = isRandom;
}
}

View file

@ -44,7 +44,7 @@ public class TournamentType implements Serializable {
protected boolean draft; // or sealed
protected boolean limited; // or construced
protected boolean elimination; // or Swiss
protected boolean isChaos;
protected boolean isRandom;
protected TournamentType() {}
@ -85,8 +85,8 @@ public class TournamentType implements Serializable {
return cubeBooster;
}
public boolean isChaos(){
return this.isChaos;
public boolean isRandom(){
return this.isRandom;
}
}