mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
fixed Ugin, the Ineffable putting cards into hand incorrectly, also fixed implementation for when multiple tokens are created (Doubling Season, etc)
This commit is contained in:
parent
619096cbbd
commit
ec9d465432
1 changed files with 13 additions and 7 deletions
|
@ -29,6 +29,8 @@ import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static mage.constants.Outcome.Benefit;
|
import static mage.constants.Outcome.Benefit;
|
||||||
|
@ -108,8 +110,12 @@ class UginTheIneffableEffect extends OneShotEffect {
|
||||||
card.turnFaceDown(game, source.getControllerId());
|
card.turnFaceDown(game, source.getControllerId());
|
||||||
Token token = new UginTheIneffableToken();
|
Token token = new UginTheIneffableToken();
|
||||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||||
|
Set<MageObjectReference> tokenObjs = new HashSet<>();
|
||||||
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
tokenObjs.add(new MageObjectReference(tokenId, game));
|
||||||
|
}
|
||||||
game.addDelayedTriggeredAbility(new UginTheIneffableDelayedTriggeredAbility(
|
game.addDelayedTriggeredAbility(new UginTheIneffableDelayedTriggeredAbility(
|
||||||
new MageObjectReference(token.getLastAddedToken(), game), new MageObjectReference(card, game)
|
tokenObjs, new MageObjectReference(card, game)
|
||||||
), source);
|
), source);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -117,18 +123,18 @@ class UginTheIneffableEffect extends OneShotEffect {
|
||||||
|
|
||||||
class UginTheIneffableDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
class UginTheIneffableDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||||
|
|
||||||
private final MageObjectReference tokenRef;
|
private final Set<MageObjectReference> tokenRefs;
|
||||||
private final MageObjectReference cardRef;
|
private final MageObjectReference cardRef;
|
||||||
|
|
||||||
UginTheIneffableDelayedTriggeredAbility(MageObjectReference token, MageObjectReference card) {
|
UginTheIneffableDelayedTriggeredAbility(Set<MageObjectReference> tokens, MageObjectReference card) {
|
||||||
super(null, Duration.Custom, true);
|
super(null, Duration.Custom, true);
|
||||||
this.tokenRef = token;
|
this.tokenRefs = tokens;
|
||||||
this.cardRef = card;
|
this.cardRef = card;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UginTheIneffableDelayedTriggeredAbility(final UginTheIneffableDelayedTriggeredAbility ability) {
|
private UginTheIneffableDelayedTriggeredAbility(final UginTheIneffableDelayedTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.tokenRef = ability.tokenRef;
|
this.tokenRefs = ability.tokenRefs;
|
||||||
this.cardRef = ability.cardRef;
|
this.cardRef = ability.cardRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +146,8 @@ class UginTheIneffableDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
ZoneChangeEvent zEvent = ((ZoneChangeEvent) event);
|
ZoneChangeEvent zEvent = ((ZoneChangeEvent) event);
|
||||||
if (!(zEvent.getFromZone() == Zone.BATTLEFIELD)
|
if (zEvent.getToZone() == Zone.BATTLEFIELD
|
||||||
|| !tokenRef.refersTo(zEvent.getTarget(), game)) {
|
|| tokenRefs.stream().noneMatch(tokenRef -> tokenRef.refersTo(zEvent.getTarget(), game))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.getEffects().clear();
|
this.getEffects().clear();
|
||||||
|
|
Loading…
Reference in a new issue