public PreventDamageByColorEffect(ObjectColor color, int amount) { super(Duration.WhileOnBattlefield, amount, false, false); this.color = color; this.staticText = "If a " + color.getDescription() + " source would deal damage to you, prevent " + amount + " of that damage"; }
@Override public String getText() { return objectColorCurrent.getDescription(); }
@Override public String toString() { if (!compareColor.isMulticolored()) { return compareColor.getDescription() + " is the most common color among all permanents or is tied for most common"; } else { return "it shares a color with the most common color among all permanents or a color tied for most common"; } } }
private void setText() { StringBuilder sb = new StringBuilder(); sb.append(attachmentType.verb()); sb.append(" creature is ").append(setColor.getDescription()); staticText = sb.toString(); } }
private void setText() { StringBuilder sb = new StringBuilder(); sb.append(attachmentType.verb()); sb.append(" creature is a ").append(addedColor.getDescription()).append(" in addition to its colors"); staticText = sb.toString(); } }
@Override public String getText(Mode mode) { if (staticText != null && !staticText.isEmpty()) { return staticText; } return "{this} becomes " + (setColor == null ? "the color of your choice" : setColor.getDescription()) + ' ' + duration.toString(); } }
public String getColorText() { String color = getColor().getDescription(); return color.substring(0, 1).toUpperCase(Locale.ENGLISH) + color.substring(1); }
public String filterNameAssembler(List<ObjectColor> unsortedColors) { //Order colors properly by WUBRG (skipping black of course) and construct string to be displayed for ability. List<ObjectColor> colors = new ArrayList<>(); if(unsortedColors.contains(ObjectColor.WHITE)){ colors.add(ObjectColor.WHITE); } if(unsortedColors.contains(ObjectColor.BLUE)){ colors.add(ObjectColor.BLUE); } if(unsortedColors.contains(ObjectColor.RED)){ colors.add(ObjectColor.RED); } if(unsortedColors.contains(ObjectColor.GREEN)){ colors.add(ObjectColor.GREEN); } if (colors.size() == 1) { return colors.get(0).getDescription(); } else if (colors.size() == 2) { return colors.get(0).getDescription() + " and from " + colors.get(1).getDescription(); } else if (colors.size() == 3) { return colors.get(0).getDescription() + ", from " + colors.get(1).getDescription() + " and from " + colors.get(2).getDescription(); } else if (colors.size() == 4) { return colors.get(0).getDescription() + ", from " + colors.get(1).getDescription() + ", from " + colors.get(2).getDescription() + " and from " + colors.get(3).getDescription(); } return ""; }
@Override public String getText(Mode mode) { if (staticText != null && !staticText.isEmpty()) { return staticText; } StringBuilder sb = new StringBuilder(); sb.append(filter.getMessage()); sb.append(" become "); if (setColor == null) { sb.append("the color of your choice"); } else { sb.append(setColor.getDescription()); } if (!duration.toString().equals("")) { sb.append(' ').append(duration.toString()); } return sb.toString(); } }
@Override public String getText(Mode mode) { if (staticText != null && !staticText.isEmpty()) { return staticText; } StringBuilder sb = new StringBuilder(); sb.append("Target ").append(mode.getTargets().get(0).getTargetName()); sb.append(" becomes "); if (setColor == null) { sb.append("the color of your choice"); } else { sb.append(setColor.getDescription()); } if (!duration.toString().equals("")) { sb.append(' ').append(duration.toString()); } return sb.toString(); } }
public static ProtectionAbility from(ObjectColor color1, ObjectColor color2) { FilterObject filter = new FilterObject(color1.getDescription() + " and from " + color2.getDescription()); filter.add(Predicates.or(new ColorPredicate(color1), new ColorPredicate(color2))); colors.add(color1); colors.add(color2); return new ProtectionAbility(filter); }
public static ProtectionAbility from(ObjectColor color) { FilterObject filter = new FilterObject(color.getDescription()); filter.add(new ColorPredicate(color)); colors.add(color); return new ProtectionAbility(filter); }
public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(source.getFirstTarget()); if(target != null) { for(ObjectColor color : target.getColor(game).getColors()) { FilterCard filter = new FilterCard(color.getDescription()); filter.add(new ColorPredicate(color)); game.addEffect(new GainAbilityControlledEffect(new ProtectionAbility(filter), Duration.EndOfTurn, new FilterControlledCreaturePermanent()), source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null) { ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color"); if (color != null && (protectionAbility == null || !color.equals(chosenColor))) { chosenColor = color; FilterObject protectionFilter = new FilterObject(chosenColor.getDescription()); protectionFilter.add(new ColorPredicate(chosenColor)); protectionAbility = new ProtectionAbility(protectionFilter); } if (protectionAbility != null) { permanent.addAbility(protectionAbility, source.getSourceId(), game); return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color"); if (color != null && (protectionAbility == null || !color.equals(chosenColor))) { chosenColor = color; FilterObject protectionFilter = new FilterObject(chosenColor.getDescription()); protectionFilter.add(new ColorPredicate(chosenColor)); protectionAbility = new ProtectionAbility(protectionFilter); } if (protectionAbility != null) { permanent.addAbility(protectionAbility, source.getSourceId(), game); return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null) { ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color"); if (color != null && (protectionAbility == null || !color.equals(chosenColor))) { chosenColor = color; FilterObject protectionFilter = new FilterObject(chosenColor.getDescription()); protectionFilter.add(new ColorPredicate(chosenColor)); protectionAbility = new ProtectionAbility(protectionFilter); } if (protectionAbility != null) { permanent.addAbility(protectionAbility, source.getSourceId(), game); return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null) { ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color"); if (color != null && (protectionAbility == null || !color.equals(chosenColor))) { chosenColor = color; FilterObject protectionFilter = new FilterObject(chosenColor.getDescription()); protectionFilter.add(new ColorPredicate(chosenColor)); protectionAbility = new ProtectionAbility(protectionFilter); } if (protectionAbility != null) { permanent.addAbility(protectionAbility, source.getSourceId(), game); return true; } } return false; } }
@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(filter, game)) { perm.addAbility(new ProtectionAbility(protectionFilter), source.getSourceId(), game); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); ChoiceColor choice = new ChoiceColor(); if (controller != null && controller.choose(outcome, choice, game) && choice.getColor() != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(choice.getColor().getDescription()+" creatures"); filter.add(new ColorPredicate(choice.getColor())); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { int amount = game.getBattlefield().countAll(filter , playerId, game); if (amount > 0) { Player player = game.getPlayer(playerId); if (player != null) { player.damage(amount, source.getSourceId(), game, false, true); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent attachement = game.getPermanent(source.getSourceId()); if (attachement != null && attachement.getAttachedTo() != null) { ObjectColor color = (ObjectColor) game.getState().getValue(attachement.getId() + "_color"); if (color != null && (protectionAbility == null || !color.equals(chosenColor))) { chosenColor = color; FilterObject protectionFilter = new FilterObject(chosenColor.getDescription()); protectionFilter.add(new ColorPredicate(chosenColor)); protectionAbility = new ProtectionAbility(protectionFilter); if (notRemoveItself) { protectionAbility.setAuraIdNotToBeRemoved(source.getSourceId()); } } if (protectionAbility != null) { Permanent attachedTo = game.getPermanent(attachement.getAttachedTo()); if (attachedTo != null) { attachedTo.addAbility(protectionAbility, source.getSourceId(), game); } return true; } } return false; } }