Allow limiting a colour in edh

This commit is contained in:
spjspj 2017-02-27 23:33:58 +11:00
parent a6e34c040b
commit 5365f9cac5
2 changed files with 42 additions and 2 deletions

View file

@ -32,6 +32,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.CanBeYourCommanderAbility;
import mage.abilities.costs.mana.ManaCost;
@ -213,6 +214,7 @@ public class Commander extends Constructed {
}
int edhPowerLevel = 0;
int commanderColors = 0;
int numberInfinitePieces = 0;
for (Card card : deck.getCards()) {
@ -647,9 +649,15 @@ public class Commander extends Constructed {
edhPowerLevel += thisMaxPower;
}
ObjectColor color = null;
for (Card commander : deck.getSideboard()) {
int thisMaxPower = 0;
String cn = commander.getName().toLowerCase();
if (color == null) {
color = commander.getColor(null);
} else {
color = color.union(commander.getColor(null));
}
// Least fun commanders
if (cn.equals("animar, soul of element")
@ -707,6 +715,13 @@ public class Commander extends Constructed {
if (edhPowerLevel > 100) {
edhPowerLevel = 100;
}
if (color != null) {
edhPowerLevel += (color.isWhite() ? 10000000 : 0);
edhPowerLevel += (color.isBlue() ? 1000000 : 0);
edhPowerLevel += (color.isBlack() ? 100000 : 0);
edhPowerLevel += (color.isRed() ? 10000 : 0);
edhPowerLevel += (color.isGreen() ? 1000 : 0);
}
return edhPowerLevel;
}
}

View file

@ -297,10 +297,35 @@ public class TableController {
int edhPowerLevel = table.getMatch().getOptions().getEdhPowerLevel();
if (edhPowerLevel > 0 && table.getValidator().getName().toLowerCase().equals("commander")) {
int deckEdhPowerLevel = table.getValidator().getEdhPowerLevel(deck);
if (deckEdhPowerLevel > edhPowerLevel) {
if (deckEdhPowerLevel % 100 > edhPowerLevel) {
String message = new StringBuilder("Your deck appears to be too powerful for this table.\n\nReduce the number of extra turn cards, infect, counters, fogs, reconsider your commander. ")
.append("\nThe table requirement has a maximum power level of ").append(edhPowerLevel).append(" whilst your deck has a calculated power level of ")
.append(deckEdhPowerLevel).toString();
.append(deckEdhPowerLevel % 100).toString();
user.showUserMessage("Join Table", message);
return false;
}
if (edhPowerLevel % 10 == 6 && deckEdhPowerLevel >= 10000000) {
String message = new StringBuilder("Your deck contains white. The creator of the table has requested no white cards on the table!").toString();
user.showUserMessage("Join Table", message);
return false;
}
if (edhPowerLevel % 10 == 4 && deckEdhPowerLevel % 10000000 >= 1000000) {
String message = new StringBuilder("Your deck contains blue. The creator of the table has requested no blue cards on the table!").toString();
user.showUserMessage("Join Table", message);
return false;
}
if (edhPowerLevel % 10 == 3 && deckEdhPowerLevel % 1000000 >= 100000) {
String message = new StringBuilder("Your deck contains black. The creator of the table has requested no black cards on the table!").toString();
user.showUserMessage("Join Table", message);
return false;
}
if (edhPowerLevel % 10 == 2 && deckEdhPowerLevel % 100000 >= 10000) {
String message = new StringBuilder("Your deck contains red. The creator of the table has requested no red cards on the table!").toString();
user.showUserMessage("Join Table", message);
return false;
}
if (edhPowerLevel % 10 == 1 && deckEdhPowerLevel % 10000 >= 1000) {
String message = new StringBuilder("Your deck contains green. The creator of the table has requested no green cards on the table!").toString();
user.showUserMessage("Join Table", message);
return false;
}