mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
updated protection ability rules generation
This commit is contained in:
parent
157de01445
commit
6ebfe78090
1 changed files with 13 additions and 2 deletions
|
@ -13,10 +13,12 @@ import mage.game.permanent.Permanent;
|
|||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -49,7 +51,7 @@ public class ProtectionAbility extends StaticAbility {
|
|||
}
|
||||
|
||||
public static ProtectionAbility from(ObjectColor color) {
|
||||
FilterObject filter = new FilterObject(color.getDescription());
|
||||
FilterObject filter = new FilterObject(getFilterText(color));
|
||||
filter.add(new ColorPredicate(color));
|
||||
colors.add(color);
|
||||
return new ProtectionAbility(filter);
|
||||
|
@ -70,7 +72,6 @@ public class ProtectionAbility extends StaticAbility {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
|
||||
return "protection from " + filter.getMessage() + (removeAuras ? "" : ". This effect doesn't remove auras.");
|
||||
}
|
||||
|
||||
|
@ -128,6 +129,16 @@ public class ProtectionAbility extends StaticAbility {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static final String getFilterText(ObjectColor color) {
|
||||
return CardUtil.concatWithAnd(
|
||||
color.getColors()
|
||||
.stream()
|
||||
.map(ObjectColor::getDescription)
|
||||
.map(s -> "from " + s)
|
||||
.collect(Collectors.toList())
|
||||
).replaceFirst("from ", "");
|
||||
}
|
||||
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue