[WOC] Implement Timber Paladin (#11025)

* updated condition to allow different comparisons and to allow filtering for auras

* implemented Timber Paladin

* fixed text
This commit is contained in:
Vivian Greenslade 2023-08-25 22:41:28 -02:30 committed by GitHub
parent 7a93681112
commit 6532ca9f66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 92 additions and 5 deletions

View file

@ -2,8 +2,11 @@
package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -14,13 +17,21 @@ import mage.game.permanent.Permanent;
public class EnchantedSourceCondition implements Condition {
private int numberOfEnchantments;
private ComparisonType comparisonType;
private boolean aurasOnly;
public EnchantedSourceCondition() {
this(1);
}
public EnchantedSourceCondition(int numberOfEnchantments) {
this(numberOfEnchantments, ComparisonType.OR_GREATER, false);
}
public EnchantedSourceCondition(int numberOfEnchantments, ComparisonType comparisonType, boolean aurasOnly) {
this.numberOfEnchantments = numberOfEnchantments;
this.comparisonType = comparisonType;
this.aurasOnly = aurasOnly;
}
@Override
@ -30,14 +41,12 @@ public class EnchantedSourceCondition implements Condition {
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached != null && attached.isEnchantment(game)) {
if (++numberOfFoundEnchantments >= numberOfEnchantments) {
return true;
}
if (attached != null && attached.isEnchantment(game) && (!aurasOnly || attached.hasSubtype(SubType.AURA, game))) {
numberOfFoundEnchantments += 1;
}
}
}
return (numberOfFoundEnchantments >= numberOfEnchantments);
return ComparisonType.compare(numberOfFoundEnchantments, comparisonType, numberOfEnchantments);
}
@Override