[WOE] Implement Imodane, the Pyrohammer (#10922)

* [WOE] Implement Imodane, the Pyrohammer

* unit test Imodane

* apply review

---------

Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
This commit is contained in:
Susucre 2023-08-24 02:39:45 +02:00 committed by GitHub
parent c0f03e98eb
commit 27bba74c9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 401 additions and 105 deletions

View file

@ -0,0 +1,35 @@
package mage.abilities.hint;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.game.Game;
/**
* @author Susucr
*/
public class ValuePositiveHint implements Hint {
private final String name;
private final DynamicValue value;
public ValuePositiveHint(String name, DynamicValue value) {
this.name = name;
this.value = value;
}
private ValuePositiveHint(final ValuePositiveHint hint) {
this.name = hint.name;
this.value = hint.value.copy();
}
@Override
public String getText(Game game, Ability ability) {
int amount = value.calculate(game, ability, null);
return amount <= 0 ? "" : name + ": " + amount;
}
@Override
public ValuePositiveHint copy() {
return new ValuePositiveHint(this);
}
}

View file

@ -0,0 +1,56 @@
package mage.filter.predicate.other;
import mage.filter.FilterPermanent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.target.Target;
import mage.util.TargetAddress;
import java.util.UUID;
/**
* @author TheElk801, Susucr
*/
public class HasOnlySingleTargetPermanentPredicate implements ObjectSourcePlayerPredicate<Spell> {
private final FilterPermanent filter;
public HasOnlySingleTargetPermanentPredicate(FilterPermanent filter) {
this.filter = filter.copy();
}
@Override
public boolean apply(ObjectSourcePlayer<Spell> input, Game game) {
Spell spell = input.getObject();
if (spell == null) {
return false;
}
UUID singleTarget = null;
for (TargetAddress addr : TargetAddress.walk(spell)) {
Target targetInstance = addr.getTarget(spell);
for (UUID targetId : targetInstance.getTargets()) {
if (singleTarget == null) {
singleTarget = targetId;
} else if (!singleTarget.equals(targetId)) {
// Ruling on Ivy, Gleeful Spellthief
// (2022-09-09) The second ability triggers whenever a player casts a spell that targets
// only one creature and no other object or player.
return false;
}
}
}
if (singleTarget == null) {
return false;
}
Permanent permanent = game.getPermanent(singleTarget);
return filter.match(permanent, input.getPlayerId(), input.getSource(), game);
}
@Override
public String toString() {
return "that targets only a single " + filter.getMessage();
}
}