mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
* Jhoira of the Ghitu and Epochrasite - Fixed the not working suspend handling.
This commit is contained in:
parent
e4d0c1045e
commit
43b0694ee3
8 changed files with 215 additions and 66 deletions
|
|
@ -846,9 +846,15 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (object != null && !object.getAbilities().contains(this)) {
|
||||
boolean found = false;
|
||||
// unfortunately we need to handle double faced cards separately and only this way
|
||||
if (object instanceof PermanentCard && ((PermanentCard)object).canTransform()) {
|
||||
PermanentCard permanent = (PermanentCard)object;
|
||||
found = permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
|
||||
if (object instanceof PermanentCard) {
|
||||
if (((PermanentCard)object).canTransform()) {
|
||||
PermanentCard permanent = (PermanentCard)object;
|
||||
found = permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
|
||||
}
|
||||
} else {
|
||||
// check if it's an ability that is temporary gained to a card
|
||||
Abilities<Ability> otherAbilities = game.getState().getAllOtherAbilities(this.getSourceId());
|
||||
found = otherAbilities != null && otherAbilities.contains(this);
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
// for effects like when leaves battlefield or destroyed use ShortLKI to check if permanent was in the correct zone before (e.g. Oblivion Ring or Karmic Justice)
|
||||
if (ability.isInUseableZone(game, null, event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT))) {
|
||||
if (!game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) {
|
||||
|
||||
MageObject object = null;
|
||||
if (!ability.getZone().equals(Zone.COMMAND) && !game.getState().getZone(ability.getSourceId()).equals(ability.getZone())) {
|
||||
object = game.getShortLivingLKI(ability.getSourceId(), ability.getZone());
|
||||
|
|
@ -83,15 +82,13 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
}
|
||||
|
||||
if (object != null) {
|
||||
if (checkAbilityStillExists(ability, event, object)) {
|
||||
if (object instanceof Permanent) {
|
||||
ability.setControllerId(((Permanent) object).getControllerId());
|
||||
}
|
||||
ability.setSourceObject(object);
|
||||
if (ability.checkTrigger(event, game)) {
|
||||
UUID controllerId = ability.getControllerId();
|
||||
ability.trigger(game, controllerId);
|
||||
}
|
||||
if (object instanceof Permanent) {
|
||||
ability.setControllerId(((Permanent) object).getControllerId());
|
||||
}
|
||||
ability.setSourceObject(object);
|
||||
if (ability.checkTrigger(event, game)) {
|
||||
UUID controllerId = ability.getControllerId();
|
||||
ability.trigger(game, controllerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,14 @@ public class SuspendedCondition implements Condition {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
for (Ability ability: game.getState().getAllOtherAbilities(source.getSourceId())) {
|
||||
if (ability instanceof SuspendAbility) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if (game.getState().getZone(card.getId()) == Zone.EXILED &&
|
||||
card.getCounters(game).getCount(CounterType.TIME) > 0) {
|
||||
|
|
|
|||
|
|
@ -176,15 +176,48 @@ public class SuspendAbility extends ActivatedAbilityImpl {
|
|||
.append(card.getCardType().contains(CardType.CREATURE)? " If you play it this way and it's a creature, it gains haste until you lose control of it.":"")
|
||||
.append(")</i>");
|
||||
}
|
||||
} else {
|
||||
gainedTemporary = true;
|
||||
if (card.getManaCost().isEmpty()) {
|
||||
setRuleAtTheTop(true);
|
||||
}
|
||||
card.addAbility(new SuspendBeginningOfUpkeepTriggeredAbility());
|
||||
card.addAbility(new SuspendPlayCardAbility(card.getCardType().contains(CardType.CREATURE)));
|
||||
}
|
||||
ruleText = sb.toString();
|
||||
if (card.getManaCost().isEmpty()) {
|
||||
setRuleAtTheTop(true);
|
||||
}
|
||||
card.addAbility(new SuspendBeginningOfUpkeepTriggeredAbility());
|
||||
card.addAbility(new SuspendPlayCardAbility(card.getCardType().contains(CardType.CREATURE)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds suspend to a card that does not have it regularly
|
||||
* e.g. Epochrasite or added by Jhoira of the Ghitu
|
||||
* @param card
|
||||
* @param source
|
||||
* @param game
|
||||
*/
|
||||
public static void addSuspendTemporaryToCard(Card card, Ability source, Game game) {
|
||||
SuspendAbility ability = new SuspendAbility(0, null, card, false);
|
||||
ability.setSourceId(card.getId());
|
||||
ability.setControllerId(card.getOwnerId());
|
||||
game.getState().addOtherAbility(card.getId(), ability);
|
||||
|
||||
SuspendBeginningOfUpkeepTriggeredAbility ability1 = new SuspendBeginningOfUpkeepTriggeredAbility();
|
||||
ability1.setSourceId(card.getId());
|
||||
ability1.setControllerId(card.getOwnerId());
|
||||
game.getState().addOtherAbility(card.getId(), ability1);
|
||||
game.getState().addAbility(ability1, source.getSourceId(), card);
|
||||
|
||||
SuspendPlayCardAbility ability2 = new SuspendPlayCardAbility(card.getCardType().contains(CardType.CREATURE));
|
||||
ability2.setSourceId(card.getId());
|
||||
ability2.setControllerId(card.getOwnerId());
|
||||
game.getState().addOtherAbility(card.getId(), ability2);
|
||||
game.getState().addAbility(ability2, source.getSourceId(), card);
|
||||
}
|
||||
|
||||
public static UUID getSuspendExileId(UUID controllerId, Game game) {
|
||||
UUID exileId = (UUID) game.getState().getValue("SuspendExileId" + controllerId.toString());
|
||||
if (exileId == null) {
|
||||
exileId = UUID.randomUUID();
|
||||
game.getState().setValue("SuspendExileId" + controllerId.toString(), exileId);
|
||||
}
|
||||
return exileId;
|
||||
}
|
||||
|
||||
public SuspendAbility(SuspendAbility ability) {
|
||||
|
|
@ -248,12 +281,8 @@ class SuspendExileEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
UUID exileId = (UUID) game.getState().getValue("SuspendExileId" + source.getControllerId().toString());
|
||||
if (exileId == null) {
|
||||
exileId = UUID.randomUUID();
|
||||
game.getState().setValue("SuspendExileId" + source.getControllerId().toString(), exileId);
|
||||
}
|
||||
if (card.moveToExile(exileId, new StringBuilder("Suspended cards of ").append(controller.getName()).toString() , source.getSourceId(), game)) {
|
||||
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
|
||||
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.HAND)) {
|
||||
if (suspend == Integer.MAX_VALUE) {
|
||||
suspend = source.getManaCostsToPay().getX();
|
||||
}
|
||||
|
|
@ -312,7 +341,7 @@ class SuspendPlayCardEffect extends OneShotEffect {
|
|||
|
||||
public SuspendPlayCardEffect(boolean isCreature) {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.staticText = "play it without paying its mana cost if able. If you can't, it remains removed from the game";
|
||||
this.staticText = "play it without paying its mana cost if able. If you can't, it remains removed from the game";
|
||||
}
|
||||
|
||||
public SuspendPlayCardEffect(final SuspendPlayCardEffect effect) {
|
||||
|
|
@ -380,7 +409,7 @@ class GainHasteEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (suspendController.equals(source.getControllerId())) {
|
||||
if (suspendController.equals(source.getControllerId())) {
|
||||
permanent.addAbility(HasteAbility.getInstance(), source.getSourceId(), game);
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -701,6 +701,16 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the ability to continuous or triggered abilities
|
||||
* @param ability
|
||||
* @param card
|
||||
*/
|
||||
public void addOtherAbility(Ability ability, Card card) {
|
||||
addOtherAbility(card.getId(), ability);
|
||||
addAbility(ability, card.getId(), card);
|
||||
}
|
||||
|
||||
private void resetOtherAbilities() {
|
||||
otherAbilities.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue