Ability refactor: face down;

This commit is contained in:
Oleg Agafonov 2020-05-28 23:02:20 +04:00
parent eea808d2d6
commit f3f1c29926
8 changed files with 137 additions and 47 deletions

View file

@ -1,8 +1,5 @@
package mage.cards.m;
import java.util.Objects;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Abilities;
import mage.abilities.Ability;
@ -20,8 +17,10 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author anonymous
*/
public final class MuragandaPetroglyphs extends CardImpl {
@ -54,6 +53,12 @@ public final class MuragandaPetroglyphs extends CardImpl {
class NoAbilityPredicate implements Predicate<MageObject> {
// Muraganda Petroglyphs gives a bonus only to creatures that have no rules text at all. This includes true vanilla
// creatures (such as Grizzly Bears), face-down creatures, many tokens, and creatures that have lost their abilities
// (due to Ovinize, for example). Any ability of any kind, whether or not the ability functions in the on the
// battlefield zone, including things like Cycling {2} means the creature doesnt get the bonus.
// (2007-05-01)
@Override
public boolean apply(MageObject input, Game game) {
boolean isFaceDown = false;
@ -65,8 +70,20 @@ class NoAbilityPredicate implements Predicate<MageObject> {
abilities = input.getAbilities();
}
if (isFaceDown) {
// Some Auras and Equipment grant abilities to creatures, meaning the affected creature would no longer
// get the +2/+2 bonus. For example, Flight grants flying to the enchanted creature. Other Auras and
// Equipment do not, meaning the affected creature would continue to get the +2/+2 bonus. For example,
// Dehydration states something now true about the enchanted creature, but doesnt give it any abilities.
// Auras and Equipment that grant abilities will use the words gains or has, and theyll list a keyword
// ability or an ability in quotation marks.
// (2007-05-01)
for (Ability ability : abilities) {
if (!ability.getSourceId().equals(input.getId()) && !ability.getClass().equals(JohanVigilanceAbility.class)) {
if (ability.getWorksFaceDown()) {
// inner face down abilities like turn up and becomes creature
continue;
}
if (!Objects.equals(ability.getClass(), SpellAbility.class) && !ability.getClass().equals(JohanVigilanceAbility.class)) {
return false;
}
}