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();
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
switch (colorString) {
case "W":
perm.getColor().setWhite(true);
break;
case "B":
perm.getColor().setBlack(true);
break;
case "U":
perm.getColor().setBlue(true);
break;
case "G":
perm.getColor().setGreen(true);
break;
case "R":
perm.getColor().setRed(true);
break;
setObjectColor(perm, colorString);
}
// Stack
for (MageObject object : game.getStack()) {
if (object instanceof Spell) {
setObjectColor(object, colorString);
}
}
// 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()) {
Player player = game.getPlayer(playerId);
if (player != null) {
// Hand
for (Card card : player.getHand().getCards(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;
}
setObjectColor(card, colorString);
}
// Library
for (Card card : player.getLibrary().getCards(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;
}
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;
// Graveyard
for (Card card : player.getGraveyard().getCards(game)) {
setObjectColor(card, colorString);
}
}
}
@ -245,6 +174,26 @@ class PaintersServantEffect extends ContinuousEffectImpl {
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
public PaintersServantEffect copy() {
return new PaintersServantEffect(this);