mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Repercussion - Some updates.
This commit is contained in:
parent
eba0cbbd34
commit
8acfbf0ab3
1 changed files with 15 additions and 15 deletions
|
@ -28,13 +28,10 @@
|
||||||
package mage.sets.urzasdestiny;
|
package mage.sets.urzasdestiny;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbility;
|
import mage.abilities.TriggeredAbility;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
|
|
||||||
import mage.abilities.effects.common.DamagePlayersEffect;
|
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
|
||||||
|
@ -45,8 +42,8 @@ import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -75,8 +72,7 @@ public class Repercussion extends CardImpl {
|
||||||
class RepercussionTriggeredAbility extends TriggeredAbilityImpl {
|
class RepercussionTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
static final String PLAYER_DAMAGE_AMOUNT_KEY = "playerDamage";
|
static final String PLAYER_DAMAGE_AMOUNT_KEY = "playerDamage";
|
||||||
|
static final String TRIGGERING_CREATURE_KEY = "triggeringCreature";
|
||||||
private int count;
|
|
||||||
|
|
||||||
public RepercussionTriggeredAbility(Effect effect) {
|
public RepercussionTriggeredAbility(Effect effect) {
|
||||||
super(Zone.BATTLEFIELD, effect);
|
super(Zone.BATTLEFIELD, effect);
|
||||||
|
@ -93,9 +89,10 @@ class RepercussionTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
MageObject eventSource = game.getObject(event.getSourceId());
|
for(Effect effect : getEffects()) {
|
||||||
this.getEffects().get(0).setValue(PLAYER_DAMAGE_AMOUNT_KEY, event.getAmount());
|
effect.setValue(PLAYER_DAMAGE_AMOUNT_KEY, event.getAmount());
|
||||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(game.getControllerId(eventSource.getId())));
|
effect.setValue(TRIGGERING_CREATURE_KEY, new MageObjectReference(event.getTargetId(), game));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,13 +120,16 @@ class RepercussionEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Integer playerDamage = (Integer)this.getValue(RepercussionTriggeredAbility.PLAYER_DAMAGE_AMOUNT_KEY);
|
Integer playerDamage = (Integer)this.getValue(RepercussionTriggeredAbility.PLAYER_DAMAGE_AMOUNT_KEY);
|
||||||
UUID targetId = this.targetPointer.getFirst(game, source);
|
MageObjectReference mor = (MageObjectReference)this.getValue(RepercussionTriggeredAbility.TRIGGERING_CREATURE_KEY);
|
||||||
if (playerDamage != null && targetId != null) {
|
if (playerDamage != null && mor != null) {
|
||||||
Player player = game.getPlayer(targetId);
|
Permanent creature = mor.getPermanentOrLKIBattlefield(game);
|
||||||
if (player != null) {
|
if (creature != null) {
|
||||||
|
Player player = game.getPlayer(creature.getControllerId());
|
||||||
|
if (player != null) {
|
||||||
player.damage(playerDamage, source.getSourceId(), game, false, true);
|
player.damage(playerDamage, source.getSourceId(), game, false, true);
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue