mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
rewrite to immutable list builder
This commit is contained in:
parent
72c8c267a1
commit
bcf02e692c
1 changed files with 43 additions and 51 deletions
|
|
@ -1,53 +1,46 @@
|
||||||
|
|
||||||
package mage.client.deck.generator;
|
package mage.client.deck.generator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public enum DeckGeneratorCMC {
|
public enum DeckGeneratorCMC {
|
||||||
|
|
||||||
Low(
|
Low(ImmutableList.<CMC>builder()
|
||||||
new ArrayList<CMC>() {{
|
.add(new CMC(0, 2, 0.60f))
|
||||||
add(new CMC(0, 2, 0.60f));
|
.add(new CMC(3, 4, 0.30f))
|
||||||
add(new CMC(3, 4, 0.30f));
|
.add(new CMC(5, 6, 0.10f)).build(),
|
||||||
add(new CMC(5, 6, 0.10f));
|
ImmutableList.<CMC>builder()
|
||||||
}},
|
.add(new CMC(0, 2, 0.65f))
|
||||||
new ArrayList<CMC>() {{
|
.add(new CMC(3, 4, 0.30f))
|
||||||
add(new CMC(0, 2, 0.65f));
|
.add(new CMC(5, 5, 0.05f)).build()),
|
||||||
add(new CMC(3, 4, 0.30f));
|
Default(ImmutableList.<CMC>builder()
|
||||||
add(new CMC(5, 5, 0.05f));
|
.add(new CMC(0, 2, 0.20f))
|
||||||
}}),
|
.add(new CMC(3, 5, 0.50f))
|
||||||
Default(
|
.add(new CMC(6, 7, 0.25f))
|
||||||
new ArrayList<CMC>() {{
|
.add(new CMC(8, 100, 0.05f)).build(),
|
||||||
add(new CMC(0, 2, 0.20f));
|
ImmutableList.<CMC>builder()
|
||||||
add(new CMC(3, 5, 0.50f));
|
.add(new CMC(0, 2, 0.30f))
|
||||||
add(new CMC(6, 7, 0.25f));
|
.add(new CMC(3, 4, 0.45f))
|
||||||
add(new CMC(8, 100, 0.05f));
|
.add(new CMC(5, 6, 0.20f))
|
||||||
}},
|
.add(new CMC(7, 100, 0.05f)).build()),
|
||||||
new ArrayList<CMC>() {{
|
|
||||||
add(new CMC(0, 2, 0.30f));
|
|
||||||
add(new CMC(3, 4, 0.45f));
|
|
||||||
add(new CMC(5, 6, 0.20f));
|
|
||||||
add(new CMC(7, 100, 0.05f));
|
|
||||||
}}),
|
|
||||||
High(
|
|
||||||
new ArrayList<CMC>() {{
|
|
||||||
add(new CMC(0, 2, 0.05f));
|
|
||||||
add(new CMC(3, 5, 0.35f));
|
|
||||||
add(new CMC(6, 7, 0.40f));
|
|
||||||
add(new CMC(8, 100, 0.15f));
|
|
||||||
}},
|
|
||||||
new ArrayList<CMC>() {{
|
|
||||||
add(new CMC(0, 2, 0.10f));
|
|
||||||
add(new CMC(3, 4, 0.30f));
|
|
||||||
add(new CMC(5, 6, 0.45f));
|
|
||||||
add(new CMC(7, 100, 0.15f));
|
|
||||||
}});
|
|
||||||
|
|
||||||
private final ArrayList<CMC> poolCMCs60;
|
High(ImmutableList.<CMC>builder().
|
||||||
private final ArrayList<CMC> poolCMCs40;
|
add(new CMC(0, 2, 0.05f))
|
||||||
|
.add(new CMC(3, 5, 0.35f))
|
||||||
|
.add(new CMC(6, 7, 0.40f))
|
||||||
|
.add(new CMC(8, 100, 0.15f)).build(),
|
||||||
|
ImmutableList.<CMC>builder().
|
||||||
|
add(new CMC(0, 2, 0.10f))
|
||||||
|
.add(new CMC(3, 4, 0.30f))
|
||||||
|
.add(new CMC(5, 6, 0.45f))
|
||||||
|
.add(new CMC(7, 100, 0.15f)).build());
|
||||||
|
|
||||||
DeckGeneratorCMC(ArrayList<CMC> CMCs60, ArrayList<CMC> CMCs40) {
|
private final List<CMC> poolCMCs60;
|
||||||
|
private final List<CMC> poolCMCs40;
|
||||||
|
|
||||||
|
DeckGeneratorCMC(List<CMC> CMCs60, List<CMC> CMCs40) {
|
||||||
this.poolCMCs60 = CMCs60;
|
this.poolCMCs60 = CMCs60;
|
||||||
this.poolCMCs40 = CMCs40;
|
this.poolCMCs40 = CMCs40;
|
||||||
}
|
}
|
||||||
|
|
@ -60,8 +53,7 @@ public enum DeckGeneratorCMC {
|
||||||
return this.poolCMCs60;
|
return this.poolCMCs60;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CMC
|
static class CMC {
|
||||||
{
|
|
||||||
public final int min;
|
public final int min;
|
||||||
public final int max;
|
public final int max;
|
||||||
public final float percentage;
|
public final float percentage;
|
||||||
|
|
@ -69,12 +61,12 @@ public enum DeckGeneratorCMC {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a CMC range given a minimum and maximum, and the percentage of cards that are in this range.
|
* Constructs a CMC range given a minimum and maximum, and the percentage of cards that are in this range.
|
||||||
* @param min the minimum CMC a card in this range can be.
|
*
|
||||||
* @param max the maximum CMC a card in this range can be.
|
* @param min the minimum CMC a card in this range can be.
|
||||||
|
* @param max the maximum CMC a card in this range can be.
|
||||||
* @param percentage the percentage of cards in the range (min, max)
|
* @param percentage the percentage of cards in the range (min, max)
|
||||||
*/
|
*/
|
||||||
CMC(int min, int max, float percentage)
|
CMC(int min, int max, float percentage) {
|
||||||
{
|
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.percentage = percentage;
|
this.percentage = percentage;
|
||||||
|
|
@ -82,19 +74,19 @@ public enum DeckGeneratorCMC {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the amount of cards needed in this CMC range.
|
* Sets the amount of cards needed in this CMC range.
|
||||||
|
*
|
||||||
* @param amount the number of cards needed.
|
* @param amount the number of cards needed.
|
||||||
*/
|
*/
|
||||||
public void setAmount(int amount)
|
public void setAmount(int amount) {
|
||||||
{
|
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of cards needed in this CMC range.
|
* Gets the number of cards needed in this CMC range.
|
||||||
|
*
|
||||||
* @return the number of cards needed in this CMC range.
|
* @return the number of cards needed in this CMC range.
|
||||||
*/
|
*/
|
||||||
public int getAmount()
|
public int getAmount() {
|
||||||
{
|
|
||||||
return this.amount;
|
return this.amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue