mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* Hedonist's Trove - Fixed that all players could play the exiled cards.
This commit is contained in:
parent
8c9c4421cd
commit
57e378c1da
1 changed files with 33 additions and 30 deletions
|
@ -43,7 +43,6 @@ import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.game.ExileZone;
|
import mage.game.ExileZone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -63,14 +62,14 @@ public class HedonistsTrove extends CardImpl {
|
||||||
// When Hedonist's Trove enters the battlefield, exile all cards from target opponent's graveyard.
|
// When Hedonist's Trove enters the battlefield, exile all cards from target opponent's graveyard.
|
||||||
Ability ability = new EntersBattlefieldTriggeredAbility(new HedonistsTroveExileEffect());
|
Ability ability = new EntersBattlefieldTriggeredAbility(new HedonistsTroveExileEffect());
|
||||||
ability.addTarget(new TargetOpponent());
|
ability.addTarget(new TargetOpponent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// You may play land cards exiled by Hedonist's Trove.
|
// You may play land cards exiled by Hedonist's Trove.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HedonistsTrovePlayLandEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HedonistsTrovePlayLandEffect()));
|
||||||
|
|
||||||
// You may cast nonland cards exiled with Hedonist's Trove. You can't cast more than one spell this way each turn.
|
// You may cast nonland cards exiled with Hedonist's Trove. You can't cast more than one spell this way each turn.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HedonistsTroveCastNonlandCardsEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HedonistsTroveCastNonlandCardsEffect()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HedonistsTrove(final HedonistsTrove card) {
|
public HedonistsTrove(final HedonistsTrove card) {
|
||||||
|
@ -138,13 +137,15 @@ class HedonistsTrovePlayLandEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
Card card = game.getCard(objectId);
|
if (affectedControllerId.equals(source.getControllerId())) {
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
Card card = game.getCard(objectId);
|
||||||
if (card != null && card.getCardType().contains(CardType.LAND) && sourceObject != null) {
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
if (card != null && card.getCardType().contains(CardType.LAND) && sourceObject != null) {
|
||||||
if (exileId != null) {
|
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
||||||
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
|
if (exileId != null) {
|
||||||
return exileZone != null && exileZone.contains(objectId);
|
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
|
||||||
|
return exileZone != null && exileZone.contains(objectId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -155,7 +156,7 @@ class HedonistsTroveCastNonlandCardsEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
private int turnNumber;
|
private int turnNumber;
|
||||||
private UUID cardId;
|
private UUID cardId;
|
||||||
|
|
||||||
public HedonistsTroveCastNonlandCardsEffect() {
|
public HedonistsTroveCastNonlandCardsEffect() {
|
||||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.Benefit);
|
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||||
staticText = "You may cast nonland cards exiled with {this}. You can't cast more than one spell this way each turn";
|
staticText = "You may cast nonland cards exiled with {this}. You can't cast more than one spell this way each turn";
|
||||||
|
@ -179,24 +180,26 @@ class HedonistsTroveCastNonlandCardsEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
Card card = game.getCard(objectId);
|
if (affectedControllerId.equals(source.getControllerId())) {
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
Card card = game.getCard(objectId);
|
||||||
if (card != null && !card.getCardType().contains(CardType.LAND) && sourceObject != null) {
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
if (card != null && !card.getCardType().contains(CardType.LAND) && sourceObject != null) {
|
||||||
if (exileId != null) {
|
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
||||||
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
|
if (exileId != null) {
|
||||||
if (exileZone != null && exileZone.contains(objectId)) {
|
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
|
||||||
if (game.getTurnNum() == turnNumber) {
|
if (exileZone != null && exileZone.contains(objectId)) {
|
||||||
if (!exileZone.contains(cardId)) {
|
if (game.getTurnNum() == turnNumber) {
|
||||||
// last checked card this turn is no longer exiled, so you can't cast another with this effect
|
if (!exileZone.contains(cardId)) {
|
||||||
// TODO: Handle if card was cast/removed from exile with effect from another card.
|
// last checked card this turn is no longer exiled, so you can't cast another with this effect
|
||||||
// If so, this effect could prevent player from casting although he should be able to use it
|
// TODO: Handle if card was cast/removed from exile with effect from another card.
|
||||||
return false;
|
// If so, this effect could prevent player from casting although he should be able to use it
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
this.turnNumber = game.getTurnNum();
|
||||||
this.turnNumber = game.getTurnNum();
|
this.cardId = objectId;
|
||||||
this.cardId = objectId;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue