all ability can be granted by lord ability
parent
5ca8ea8353
commit
47a0776535
|
@ -819,11 +819,11 @@ public enum MagicAbility {
|
||||||
card.add(MagicStatic.genPTStatic(filter, power, toughness));
|
card.add(MagicStatic.genPTStatic(filter, power, toughness));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Set<MagicAbility> abilities = MagicAbility.getAbilities(tokens[1].split(", "));
|
final MagicAbilityList abilityList = MagicAbility.getAbilityList(tokens[1].split(", "));
|
||||||
if (other) {
|
if (other) {
|
||||||
card.add(MagicStatic.genABStaticOther(filter, abilities));
|
card.add(MagicStatic.genABStaticOther(filter, abilityList));
|
||||||
} else {
|
} else {
|
||||||
card.add(MagicStatic.genABStatic(filter, abilities));
|
card.add(MagicStatic.genABStatic(filter, abilityList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -891,26 +891,12 @@ public enum MagicAbility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<MagicAbility> getAbilities(final String[] names) {
|
|
||||||
Set<MagicAbility> flags = EnumSet.noneOf(MagicAbility.class);
|
|
||||||
for (final String name : names) {
|
|
||||||
final MagicAbility ability = getAbility(name);
|
|
||||||
flags.add(ability);
|
|
||||||
// given ability cannot have arguments
|
|
||||||
if (NO_IMPL.contains(ability) == false) {
|
|
||||||
throw new RuntimeException("Unable to convert " + name + " to a given ability");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MagicAbilityList getAbilityList(final String[] names) {
|
public static MagicAbilityList getAbilityList(final String[] names) {
|
||||||
final MagicAbilityList abList = new MagicAbilityList();
|
final MagicAbilityList abilityList = new MagicAbilityList();
|
||||||
for (final String name : names) {
|
for (final String name : names) {
|
||||||
final MagicAbility ability = getAbility(name);
|
getAbility(name).addAbility(abilityList, name);
|
||||||
ability.addAbility(abList, name);
|
|
||||||
}
|
}
|
||||||
return abList;
|
return abilityList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<MagicAbility> of(final MagicAbility first, MagicAbility... rest) {
|
public static Set<MagicAbility> of(final MagicAbility first, MagicAbility... rest) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ public abstract class MagicStatic extends MagicDummyModifier implements MagicCha
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MagicStatic genABStatic(final MagicTargetFilter<MagicPermanent> filter, final Set<MagicAbility> givenAbilityFlags) {
|
public static MagicStatic genABStatic(final MagicTargetFilter<MagicPermanent> filter, final MagicAbilityList abilityList) {
|
||||||
return new MagicStatic(
|
return new MagicStatic(
|
||||||
MagicLayer.Ability,
|
MagicLayer.Ability,
|
||||||
filter
|
filter
|
||||||
|
@ -144,12 +144,13 @@ public abstract class MagicStatic extends MagicDummyModifier implements MagicCha
|
||||||
final MagicPermanent source,
|
final MagicPermanent source,
|
||||||
final MagicPermanent permanent,
|
final MagicPermanent permanent,
|
||||||
final Set<MagicAbility> flags) {
|
final Set<MagicAbility> flags) {
|
||||||
flags.addAll(givenAbilityFlags);
|
flags.addAll(abilityList.getAbilities());
|
||||||
|
abilityList.addAbility(permanent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MagicStatic genABStaticOther(final MagicTargetFilter<MagicPermanent> filter, final Set<MagicAbility> givenAbilityFlags) {
|
public static MagicStatic genABStaticOther(final MagicTargetFilter<MagicPermanent> filter, final MagicAbilityList abilityList) {
|
||||||
return new MagicStatic(
|
return new MagicStatic(
|
||||||
MagicLayer.Ability,
|
MagicLayer.Ability,
|
||||||
filter
|
filter
|
||||||
|
@ -159,7 +160,8 @@ public abstract class MagicStatic extends MagicDummyModifier implements MagicCha
|
||||||
final MagicPermanent source,
|
final MagicPermanent source,
|
||||||
final MagicPermanent permanent,
|
final MagicPermanent permanent,
|
||||||
final Set<MagicAbility> flags) {
|
final Set<MagicAbility> flags) {
|
||||||
flags.addAll(givenAbilityFlags);
|
flags.addAll(abilityList.getAbilities());
|
||||||
|
abilityList.addAbility(permanent);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean condition(final MagicGame game,final MagicPermanent source,final MagicPermanent target) {
|
public boolean condition(final MagicGame game,final MagicPermanent source,final MagicPermanent target) {
|
||||||
|
@ -185,22 +187,6 @@ public abstract class MagicStatic extends MagicDummyModifier implements MagicCha
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MagicStatic genABStatic(final Set<MagicAbility> givenAbilityFlags) {
|
|
||||||
return new MagicStatic(MagicLayer.Ability) {
|
|
||||||
@Override
|
|
||||||
public void modAbilityFlags(
|
|
||||||
final MagicPermanent source,
|
|
||||||
final MagicPermanent permanent,
|
|
||||||
final Set<MagicAbility> flags) {
|
|
||||||
flags.addAll(givenAbilityFlags);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean accept(final MagicGame game,final MagicPermanent source,final MagicPermanent target) {
|
|
||||||
return MagicStatic.acceptLinked(game, source, target);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MagicStatic genTypeStatic(final int givenTypeFlags) {
|
public static MagicStatic genTypeStatic(final int givenTypeFlags) {
|
||||||
return new MagicStatic(MagicLayer.Type) {
|
return new MagicStatic(MagicLayer.Type) {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue