mirror of
https://github.com/correl/mage.git
synced 2025-04-10 17:00:08 -09:00
Fixed Morph handling, fixed that face down cards stay face down after zone change.
This commit is contained in:
parent
c888957fa0
commit
f137f9c49c
9 changed files with 59 additions and 7 deletions
Mage.Common/src/mage/view
Mage.Sets/src/mage/sets/khansoftarkir
Mage/src/mage
abilities
cards
game
|
@ -119,7 +119,7 @@ public class PermanentView extends CardView {
|
||||||
if (permanentAbility instanceof TurnFaceUpAbility && !permanentAbility.getRuleVisible()) {
|
if (permanentAbility instanceof TurnFaceUpAbility && !permanentAbility.getRuleVisible()) {
|
||||||
this.rules.add(permanentAbility.getRule(true));
|
this.rules.add(permanentAbility.getRule(true));
|
||||||
}
|
}
|
||||||
if (permanentAbility instanceof TurnedFaceUpTriggeredAbility) {
|
if (permanentAbility.getWorksFaceDown()) {
|
||||||
this.rules.add(permanentAbility.getRule());
|
this.rules.add(permanentAbility.getRule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,9 @@ public class HoodedHydra extends CardImpl {
|
||||||
Effect effect = new AddCountersSourceEffect(CounterType.P1P1.createInstance(5));
|
Effect effect = new AddCountersSourceEffect(CounterType.P1P1.createInstance(5));
|
||||||
effect.setText("put five +1/+1 counters on it");
|
effect.setText("put five +1/+1 counters on it");
|
||||||
// TODO: Does not work because the ability is still removed from permanent while the effect checks if the ability still exosts.
|
// TODO: Does not work because the ability is still removed from permanent while the effect checks if the ability still exosts.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new AsTurnedFaceUpEffect(effect, false));
|
||||||
new AsTurnedFaceUpEffect(effect, false)));
|
ability.setWorksFaceDown(true);
|
||||||
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HoodedHydra(final HoodedHydra card) {
|
public HoodedHydra(final HoodedHydra card) {
|
||||||
|
|
|
@ -385,6 +385,24 @@ public interface Ability extends Controllable, Serializable {
|
||||||
*/
|
*/
|
||||||
void setRuleAtTheTop(boolean ruleAtTheTop);
|
void setRuleAtTheTop(boolean ruleAtTheTop);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this ability has to work also with face down object
|
||||||
|
* (set to not visible normally).
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean getWorksFaceDown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value for the worksFaceDown flag
|
||||||
|
*
|
||||||
|
* true = the ability works also if the object is face down
|
||||||
|
*
|
||||||
|
* @param worksFaceDown
|
||||||
|
*/
|
||||||
|
void setWorksFaceDown(boolean worksFaceDown);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this ability's rule is visible on the card tooltip
|
* Returns true if this ability's rule is visible on the card tooltip
|
||||||
*
|
*
|
||||||
|
@ -450,7 +468,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to deactivate cost modification logic of ability activation for some special handling
|
* Used to deactivate cost modification logic of ability activation for some special handling
|
||||||
* (e.g. FlashbackAbility gets cost modifiaction twice because of how it#s ahndled now)
|
* (e.g. FlashbackAbility gets cost modifiaction twice because of how it's handled now)
|
||||||
*
|
*
|
||||||
* @param active execute no cost modification
|
* @param active execute no cost modification
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -83,6 +83,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
protected boolean ruleAdditionalCostsVisible = true;
|
protected boolean ruleAdditionalCostsVisible = true;
|
||||||
protected boolean costModificationActive = true;
|
protected boolean costModificationActive = true;
|
||||||
protected boolean activated = false;
|
protected boolean activated = false;
|
||||||
|
protected boolean worksFaceDown = false;
|
||||||
|
|
||||||
public AbilityImpl(AbilityType abilityType, Zone zone) {
|
public AbilityImpl(AbilityType abilityType, Zone zone) {
|
||||||
this.id = UUID.randomUUID();
|
this.id = UUID.randomUUID();
|
||||||
|
@ -117,6 +118,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
this.ruleVisible = ability.ruleVisible;
|
this.ruleVisible = ability.ruleVisible;
|
||||||
this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
|
this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
|
||||||
this.costModificationActive = ability.costModificationActive;
|
this.costModificationActive = ability.costModificationActive;
|
||||||
|
this.worksFaceDown = ability.worksFaceDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -945,5 +947,17 @@ public abstract class AbilityImpl implements Ability {
|
||||||
this.costModificationActive = active;
|
this.costModificationActive = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getWorksFaceDown() {
|
||||||
|
return worksFaceDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWorksFaceDown(boolean worksFaceDown) {
|
||||||
|
this.worksFaceDown = worksFaceDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ public class TurnedFaceUpTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
public TurnedFaceUpTriggeredAbility(Effect effect) {
|
public TurnedFaceUpTriggeredAbility(Effect effect) {
|
||||||
super(Zone.BATTLEFIELD, effect);
|
super(Zone.BATTLEFIELD, effect);
|
||||||
|
// has to be set so the ability triggers if card is turn faced up
|
||||||
|
this.setWorksFaceDown(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TurnedFaceUpTriggeredAbility(final TurnedFaceUpTriggeredAbility ability) {
|
public TurnedFaceUpTriggeredAbility(final TurnedFaceUpTriggeredAbility ability) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ import mage.abilities.costs.CostsImpl;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.AsTurnedFaceUpEffect;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.common.continious.SourceEffect;
|
import mage.abilities.effects.common.continious.SourceEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -301,7 +302,7 @@ class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implements Sour
|
||||||
List<Ability> abilities = new ArrayList<>();
|
List<Ability> abilities = new ArrayList<>();
|
||||||
for (Ability ability : permanent.getAbilities()) {
|
for (Ability ability : permanent.getAbilities()) {
|
||||||
// TODO: Add flag "works also face down" to ability and use it to control ability removement instead of instanceof check
|
// TODO: Add flag "works also face down" to ability and use it to control ability removement instead of instanceof check
|
||||||
if (ability instanceof TurnedFaceUpTriggeredAbility) {
|
if (ability.getWorksFaceDown()) {
|
||||||
ability.setRuleVisible(false);
|
ability.setRuleVisible(false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -571,6 +571,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
if (!game.replaceEvent(event)) {
|
if (!game.replaceEvent(event)) {
|
||||||
setFaceDown(false);
|
setFaceDown(false);
|
||||||
game.getCard(objectId).setFaceDown(false); // Another instance?
|
game.getCard(objectId).setFaceDown(false); // Another instance?
|
||||||
|
for (Ability ability :abilities) { // abilities that were set to not visible face down must be set to visible again
|
||||||
|
if (ability.getWorksFaceDown() && !ability.getRuleVisible()) {
|
||||||
|
ability.setRuleVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TURNEDFACEUP, getId(), playerId));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TURNEDFACEUP, getId(), playerId));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -703,9 +708,9 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
countersEvent.setAppliedEffects(appliedEffects);
|
countersEvent.setAppliedEffects(appliedEffects);
|
||||||
if (!game.replaceEvent(countersEvent)) {
|
if (!game.replaceEvent(countersEvent)) {
|
||||||
int amount = countersEvent.getAmount();
|
int amount = countersEvent.getAmount();
|
||||||
Counter eventCounter = counter.copy();
|
|
||||||
eventCounter.remove(amount - 1);
|
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
|
Counter eventCounter = counter.copy();
|
||||||
|
eventCounter.remove(amount - 1);
|
||||||
GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, ownerId, counter.getName(), 1);
|
GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, ownerId, counter.getName(), 1);
|
||||||
event.setAppliedEffects(appliedEffects);
|
event.setAppliedEffects(appliedEffects);
|
||||||
if (!game.replaceEvent(event)) {
|
if (!game.replaceEvent(event)) {
|
||||||
|
|
|
@ -134,6 +134,7 @@ public class PermanentCard extends PermanentImpl {
|
||||||
if (controller != null && controller.removeFromBattlefield(this, game)) {
|
if (controller != null && controller.removeFromBattlefield(this, game)) {
|
||||||
if (isFaceDown()) {
|
if (isFaceDown()) {
|
||||||
setFaceDown(false);
|
setFaceDown(false);
|
||||||
|
game.getCard(this.getId()).setFaceDown(false); //TODO: Do this in a better way
|
||||||
}
|
}
|
||||||
ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone, appliedEffects);
|
ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone, appliedEffects);
|
||||||
if (!game.replaceEvent(event)) {
|
if (!game.replaceEvent(event)) {
|
||||||
|
|
|
@ -451,6 +451,16 @@ public class StackAbility implements StackObject, Ability {
|
||||||
public void setCostModificationActive(boolean active) {
|
public void setCostModificationActive(boolean active) {
|
||||||
throw new UnsupportedOperationException("Not supported. Only neede for flashbacked spells");
|
throw new UnsupportedOperationException("Not supported. Only neede for flashbacked spells");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getWorksFaceDown() {
|
||||||
|
return this.ability.getWorksFaceDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWorksFaceDown(boolean worksFaceDown) {
|
||||||
|
this.ability.setWorksFaceDown(worksFaceDown);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue