mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
* Added DealsDamageAttachedTriggeredAbility and used in some cards.
This commit is contained in:
parent
0847d3f820
commit
d3b41c076d
10 changed files with 214 additions and 246 deletions
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class DealsDamageAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public DealsDamageAttachedTriggeredAbility(Zone zone, Effect effect, boolean optional) {
|
||||
super(zone, effect, optional);
|
||||
}
|
||||
|
||||
public DealsDamageAttachedTriggeredAbility(final DealsDamageAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealsDamageAttachedTriggeredAbility copy() {
|
||||
return new DealsDamageAttachedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.DAMAGED_CREATURE)
|
||||
|| event.getType().equals(GameEvent.EventType.DAMAGED_PLAYER)
|
||||
|| event.getType().equals(GameEvent.EventType.DAMAGED_PLANESWALKER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchantment = game.getPermanent(this.getSourceId());
|
||||
if (enchantment == null || enchantment.getAttachedTo() == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (enchanted != null && event.getSourceId().equals(enchanted.getId())) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever enchanted creature deals damage, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import static javax.xml.bind.JAXBIntrospector.getValue;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.DamagedCreatureEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class NumericSetToEffectValues implements DynamicValue {
|
||||
|
||||
private final String message;
|
||||
private final String valueKey;
|
||||
|
||||
|
||||
public NumericSetToEffectValues(String message, String valueKey) {
|
||||
this.message = message;
|
||||
this.valueKey = valueKey;
|
||||
}
|
||||
|
||||
public NumericSetToEffectValues(final NumericSetToEffectValues dynamicValue) {
|
||||
super();
|
||||
this.message = dynamicValue.message;
|
||||
this.valueKey = dynamicValue.valueKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
Object object = effect.getValue(valueKey);
|
||||
if (object instanceof Integer) {
|
||||
return (Integer) object;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NumericSetToEffectValues copy() {
|
||||
return new NumericSetToEffectValues(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import mage.abilities.effects.Effect;
|
|||
import mage.game.Game;
|
||||
|
||||
public class SignInversionDynamicValue implements DynamicValue {
|
||||
private DynamicValue value;
|
||||
private final DynamicValue value;
|
||||
|
||||
public SignInversionDynamicValue(DynamicValue value) {
|
||||
this.value = value.copy();
|
||||
|
|
|
|||
|
|
@ -86,11 +86,13 @@ public class GainLifeEffect extends OneShotEffect {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
String message = life.getMessage();
|
||||
sb.append("you gain ");
|
||||
if (message.isEmpty() || !message.equals("1")) {
|
||||
if (message.startsWith("that")) {
|
||||
sb.append(message).append(" ");
|
||||
} else if (message.isEmpty() || !message.equals("1")) {
|
||||
sb.append(life).append(" ");
|
||||
}
|
||||
sb.append("life");
|
||||
if (message.length() > 0) {
|
||||
if (message.length() > 0 && !message.startsWith("that")) {
|
||||
sb.append(message.equals("1") ? " equal to the number of " : " for each ");
|
||||
sb.append(message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue