use of mage.ObjectColor in project mage by magefree.
the class ProtectionChosenColorTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
Player player = game.getPlayer(targetCreature.getControllerId());
if (player != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (player.choose(Outcome.Neutral, colorChoice, game)) {
game.informPlayers(targetCreature.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(targetCreature.getId() + "_color", colorChoice.getColor());
ObjectColor protectColor = (ObjectColor) game.getState().getValue(targetCreature.getId() + "_color");
if (protectColor != null) {
ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
effect.setTargetPointer(new FixedTarget(targetCreature, game));
game.addEffect(effect, source);
}
return true;
}
}
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class RallyTheRighteousBoostEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
ObjectColor color = target.getColor(game);
target.untap(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (permanent.getColor(game).shares(color) && !permanent.getId().equals(target.getId())) {
permanent.untap(game);
}
}
return true;
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class WardSliverGainAbilityControlledEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (protectionFilter == null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
if (color != null) {
protectionFilter = new FilterPermanent(color.getDescription());
protectionFilter.add(new ColorPredicate(color));
}
}
}
if (protectionFilter != null) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_ALL_SLIVERS, game)) {
perm.addAbility(new ProtectionAbility(protectionFilter), source.getSourceId(), game);
}
return true;
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class WashOutEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Set<Card> cardsToReturn = new LinkedHashSet<>();
ChoiceColor choice = new ChoiceColor();
if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) {
ObjectColor color = choice.getColor();
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(color));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
cardsToReturn.add((Card) permanent);
}
return controller.moveCards(cardsToReturn, Zone.HAND, source, game);
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class VerifyCardDataTest method checkColors.
private void checkColors(Card card, MtgJsonCard ref) {
if (skipListHaveName(SKIP_LIST_COLOR, card.getExpansionSetCode(), card.getName())) {
return;
}
Set<String> expected = new HashSet<>();
if (ref.colors != null) {
expected.addAll(ref.colors);
}
if (card.isFlipCard()) {
expected.addAll(ref.colorIdentity);
}
ObjectColor color = card.getColor(null);
if (expected.size() != color.getColorCount() || (color.isBlack() && !expected.contains("B")) || (color.isBlue() && !expected.contains("U")) || (color.isGreen() && !expected.contains("G")) || (color.isRed() && !expected.contains("R")) || (color.isWhite() && !expected.contains("W"))) {
fail(card, "colors", color + " != " + expected);
}
}
Aggregations