mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
Merge pull request #2630 from MTGfan/master
New AttachedPermanentToughnessValue and related updates plus misc
This commit is contained in:
commit
db831202da
8 changed files with 136 additions and 168 deletions
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* 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.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author anonymous
|
||||
*/
|
||||
public class AttackingCondition implements Condition {
|
||||
|
||||
private static final AttachedCondition fInstance = new AttachedCondition();
|
||||
|
||||
public static AttachedCondition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
return permanent != null && permanent.isAttacking();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author MTGfan
|
||||
*/
|
||||
public class AttachedPermanentToughnessValue implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
|
||||
return enchanted.getToughness().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachedPermanentToughnessValue copy(){
|
||||
return new AttachedPermanentToughnessValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "equal to";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "that creature's toughness";
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,8 @@ package mage.abilities.effects.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
|
@ -42,9 +44,14 @@ import mage.players.Player;
|
|||
*/
|
||||
public class DamageAttachedControllerEffect extends OneShotEffect {
|
||||
|
||||
protected int amount;
|
||||
protected DynamicValue amount;
|
||||
|
||||
public DamageAttachedControllerEffect(int amount) {
|
||||
super(Outcome.Damage);
|
||||
this.amount = new StaticValue(amount);
|
||||
}
|
||||
|
||||
public DamageAttachedControllerEffect(DynamicValue amount) {
|
||||
super(Outcome.Damage);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
|
@ -71,7 +78,7 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
|
|||
}
|
||||
Player player = game.getPlayer(enchanted.getControllerId());
|
||||
if(player != null) {
|
||||
player.damage(amount, source.getSourceId(), game, false, true);
|
||||
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -82,7 +89,9 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "{this} deals " + amount + " damage to that creature's controller";
|
||||
if ("equal to".equals(amount.toString())) {
|
||||
return "{this} deals damage " + amount + " that creatures toughness to that creature's controller";
|
||||
}
|
||||
return "{this} deals " + amount + " damage to that creature's controller";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue