mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
fixed Kethis, the Hidden Hand giving abilities to cards not in the graveyard when its ability resolved (fixes #5950)
This commit is contained in:
parent
70787df5ea
commit
f8e5a65d85
1 changed files with 27 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
package mage.cards.k;
|
package mage.cards.k;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -75,24 +76,43 @@ class KethisTheHiddenHandEffect extends ContinuousEffectImpl {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Ability source, Game game) {
|
||||||
|
super.init(source, game);
|
||||||
|
if (!this.affectedObjectsSet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getGraveyard()
|
||||||
|
.stream()
|
||||||
|
.map(game::getCard)
|
||||||
|
.filter(Card::isLegendary)
|
||||||
|
.forEach(card -> affectedObjectList.add(new MageObjectReference(card, game)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (UUID cardId : controller.getGraveyard()) {
|
controller.getGraveyard()
|
||||||
Card card = game.getCard(cardId);
|
.getCards(game)
|
||||||
if (card == null || !card.isLegendary()) {
|
.stream()
|
||||||
continue;
|
.filter(card -> affectedObjectList
|
||||||
}
|
.stream()
|
||||||
|
.anyMatch(mor -> mor.refersTo(card, game))
|
||||||
|
).forEach(card -> {
|
||||||
Ability ability = new SimpleStaticAbility(
|
Ability ability = new SimpleStaticAbility(
|
||||||
Zone.GRAVEYARD, new KethisTheHiddenHandGraveyardEffect()
|
Zone.GRAVEYARD, new KethisTheHiddenHandGraveyardEffect()
|
||||||
);
|
);
|
||||||
ability.setSourceId(cardId);
|
ability.setSourceId(card.getId());
|
||||||
ability.setControllerId(card.getOwnerId());
|
ability.setControllerId(card.getOwnerId());
|
||||||
game.getState().addOtherAbility(card, ability);
|
game.getState().addOtherAbility(card, ability);
|
||||||
}
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue