mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
New AttachedPermanentToughnessValue, updated DamageAttachedControllerEffect to take DynamicValue (ex. to work with AttachedPermanentToughnessValue), and updated Creature Bond to use AttachedPermanentToughnessValue and DamageAttachedControllerEffect. Corrected Gaea's Liege, Kor Scythemaster, Soltari Lancer, and Spirit of the Night to use SourceAttackingCondition. Rmoved the AttackingCondition we creature for Gaea's Liege since it duplicated the already existing SourceAttackingCondition. For the other three using SourceAttackingCondition and the minor changes to the code for them should make their code more efficient.
This commit is contained in:
parent
cd6917be93
commit
36d6c006ca
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