Cleaned up Painter's Servant. Made it change the color of cards in Command and Graveyard zones.

This commit is contained in:
Duncan Townsend 2015-01-24 21:40:26 -05:00
parent e1ad6ed7d2
commit 6a48aacfc6
No known key found for this signature in database
GPG key ID: C00ECDF315F7A593

View file

@ -133,110 +133,39 @@ class PaintersServantEffect extends ContinuousEffectImpl {
} }
String colorString = color.toString(); String colorString = color.toString();
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) { for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
switch (colorString) { setObjectColor(perm, colorString);
case "W": }
perm.getColor().setWhite(true); // Stack
break; for (MageObject object : game.getStack()) {
case "B": if (object instanceof Spell) {
perm.getColor().setBlack(true); setObjectColor(object, colorString);
break;
case "U":
perm.getColor().setBlue(true);
break;
case "G":
perm.getColor().setGreen(true);
break;
case "R":
perm.getColor().setRed(true);
break;
} }
} }
// Exile
for (Card card : game.getExile().getAllCards(game)) {
setObjectColor(card, colorString);
}
// Command
for (CommandObject commandObject : game.getState().getCommand()) {
if (commandObject instanceof Commander) {
setObjectColor(commandObject, colorString);
}
}
for (UUID playerId : controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
// Hand // Hand
for (Card card : player.getHand().getCards(game)) { for (Card card : player.getHand().getCards(game)) {
switch (colorString) { setObjectColor(card, colorString);
case "W":
card.getColor().setWhite(true);
break;
case "B":
card.getColor().setBlack(true);
break;
case "U":
card.getColor().setBlue(true);
break;
case "G":
card.getColor().setGreen(true);
break;
case "R":
card.getColor().setRed(true);
break;
}
} }
// Library // Library
for (Card card : player.getLibrary().getCards(game)) { for (Card card : player.getLibrary().getCards(game)) {
switch (colorString) { setObjectColor(card, colorString);
case "W":
card.getColor().setWhite(true);
break;
case "B":
card.getColor().setBlack(true);
break;
case "U":
card.getColor().setBlue(true);
break;
case "G":
card.getColor().setGreen(true);
break;
case "R":
card.getColor().setRed(true);
break;
}
} }
// Graveyard
} for (Card card : player.getGraveyard().getCards(game)) {
setObjectColor(card, colorString);
// Stack
for (MageObject object : game.getStack()) {
if (object instanceof Spell) {
switch (colorString) {
case "W":
object.getColor().setWhite(true);
break;
case "B":
object.getColor().setBlack(true);
break;
case "U":
object.getColor().setBlue(true);
break;
case "G":
object.getColor().setGreen(true);
break;
case "R":
object.getColor().setRed(true);
break;
}
}
}
// Exile
for (Card card : game.getExile().getAllCards(game)) {
switch (colorString) {
case "W":
card.getColor().setWhite(true);
break;
case "B":
card.getColor().setBlack(true);
break;
case "U":
card.getColor().setBlue(true);
break;
case "G":
card.getColor().setGreen(true);
break;
case "R":
card.getColor().setRed(true);
break;
} }
} }
} }
@ -245,6 +174,26 @@ class PaintersServantEffect extends ContinuousEffectImpl {
return false; return false;
} }
protected static void setObjectColor(MageObject obj, String colorString) {
switch (colorString) {
case "W":
obj.getColor().setWhite(true);
break;
case "B":
obj.getColor().setBlack(true);
break;
case "U":
obj.getColor().setBlue(true);
break;
case "G":
obj.getColor().setGreen(true);
break;
case "R":
obj.getColor().setRed(true);
break;
}
}
@Override @Override
public PaintersServantEffect copy() { public PaintersServantEffect copy() {
return new PaintersServantEffect(this); return new PaintersServantEffect(this);