mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
[VOW] Implemented Curse of Hospitality
This commit is contained in:
parent
38f0e83274
commit
5260d6d363
6 changed files with 185 additions and 12 deletions
|
|
@ -24,22 +24,25 @@ import java.util.UUID;
|
|||
public class CanPlayCardControllerEffect extends AsThoughEffectImpl {
|
||||
|
||||
private final MageObjectReference mor;
|
||||
private final UUID playerId;
|
||||
private final Condition condition;
|
||||
|
||||
public CanPlayCardControllerEffect(Game game, UUID cardId, int cardZCC, Duration duration) {
|
||||
this(game, cardId, cardZCC, duration, null);
|
||||
this(game, cardId, cardZCC, duration, null, null);
|
||||
}
|
||||
|
||||
public CanPlayCardControllerEffect(Game game, UUID cardId, int cardZCC, Duration duration, Condition condition) {
|
||||
public CanPlayCardControllerEffect(Game game, UUID cardId, int cardZCC, Duration duration, UUID playerId, Condition condition) {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, duration, Outcome.Benefit);
|
||||
this.staticText = "You may play those card";
|
||||
this.mor = new MageObjectReference(cardId, cardZCC, game);
|
||||
this.playerId = playerId;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public CanPlayCardControllerEffect(final CanPlayCardControllerEffect effect) {
|
||||
super(effect);
|
||||
this.mor = effect.mor;
|
||||
this.playerId = effect.playerId;
|
||||
this.condition = effect.condition;
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +68,7 @@ public class CanPlayCardControllerEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
UUID objectIdToCast = CardUtil.getMainCardId(game, sourceId); // affected to all card's parts
|
||||
return mor.refersTo(objectIdToCast, game) && source.isControlledBy(affectedControllerId);
|
||||
return mor.refersTo(objectIdToCast, game)
|
||||
&& (playerId == null ? source.isControlledBy(affectedControllerId) : playerId.equals(affectedControllerId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,27 +15,29 @@ import java.util.UUID;
|
|||
|
||||
/**
|
||||
* Spend mana as any color to cast targeted card. Will not affected after any card movements or blinks.
|
||||
*
|
||||
* Affects to all card's parts
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class YouMaySpendManaAsAnyColorToCastTargetEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
|
||||
|
||||
private final UUID playerId;
|
||||
private final Condition condition;
|
||||
|
||||
public YouMaySpendManaAsAnyColorToCastTargetEffect(Duration duration) {
|
||||
this(duration, null);
|
||||
this(duration, null, null);
|
||||
}
|
||||
|
||||
public YouMaySpendManaAsAnyColorToCastTargetEffect(Duration duration, Condition condition) {
|
||||
public YouMaySpendManaAsAnyColorToCastTargetEffect(Duration duration, UUID playerId, Condition condition) {
|
||||
super(AsThoughEffectType.SPEND_OTHER_MANA, duration, Outcome.Benefit);
|
||||
this.staticText = "You may spend mana as though it were mana of any color to cast it";
|
||||
this.playerId = playerId;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public YouMaySpendManaAsAnyColorToCastTargetEffect(final YouMaySpendManaAsAnyColorToCastTargetEffect effect) {
|
||||
super(effect);
|
||||
this.playerId = effect.playerId;
|
||||
this.condition = effect.condition;
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +60,7 @@ public class YouMaySpendManaAsAnyColorToCastTargetEffect extends AsThoughEffectI
|
|||
objectId = CardUtil.getMainCardId(game, objectId); // for split cards
|
||||
FixedTarget fixedTarget = ((FixedTarget) getTargetPointer());
|
||||
UUID targetId = CardUtil.getMainCardId(game, fixedTarget.getTarget()); // Affects to all card's parts (example: Hostage Taker exile mdf card)
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
return (playerId == null ? source.isControlledBy(affectedControllerId) : playerId.equals(affectedControllerId))
|
||||
&& Objects.equals(objectId, targetId)
|
||||
&& game.getState().getZoneChangeCounter(objectId) <= fixedTarget.getZoneChangeCounter() + 1
|
||||
&& (game.getState().getZone(objectId) == Zone.STACK || game.getState().getZone(objectId) == Zone.EXILED);
|
||||
|
|
|
|||
|
|
@ -1157,7 +1157,7 @@ public final class CardUtil {
|
|||
}
|
||||
|
||||
public static void makeCardPlayable(Game game, Ability source, Card card, Duration duration, boolean anyColor) {
|
||||
makeCardPlayable(game, source, card, duration, anyColor, null);
|
||||
makeCardPlayable(game, source, card, duration, anyColor, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1172,16 +1172,16 @@ public final class CardUtil {
|
|||
* @param anyColor
|
||||
* @param condition can be null
|
||||
*/
|
||||
public static void makeCardPlayable(Game game, Ability source, Card card, Duration duration, boolean anyColor, Condition condition) {
|
||||
public static void makeCardPlayable(Game game, Ability source, Card card, Duration duration, boolean anyColor, UUID playerId, Condition condition) {
|
||||
// Effect can be used for cards in zones and permanents on battlefield
|
||||
// PermanentCard's ZCC is static, but we need updated ZCC from the card (after moved to another zone)
|
||||
// So there is a workaround to get actual card's ZCC
|
||||
// Example: Hostage Taker
|
||||
UUID objectId = card.getMainCard().getId();
|
||||
int zcc = game.getState().getZoneChangeCounter(objectId);
|
||||
game.addEffect(new CanPlayCardControllerEffect(game, objectId, zcc, duration, condition), source);
|
||||
game.addEffect(new CanPlayCardControllerEffect(game, objectId, zcc, duration, playerId, condition), source);
|
||||
if (anyColor) {
|
||||
game.addEffect(new YouMaySpendManaAsAnyColorToCastTargetEffect(duration, condition).setTargetPointer(new FixedTarget(objectId, zcc)), source);
|
||||
game.addEffect(new YouMaySpendManaAsAnyColorToCastTargetEffect(duration, playerId, condition).setTargetPointer(new FixedTarget(objectId, zcc)), source);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue