mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Implement [M3C] Razorfield Ripper (#12389)
This commit is contained in:
parent
86f1894ce0
commit
1d8be572b5
4 changed files with 172 additions and 8 deletions
|
|
@ -0,0 +1,53 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CountersControllerCount implements DynamicValue {
|
||||
|
||||
private final CounterType counterType;
|
||||
|
||||
/**
|
||||
* Number of counters of the specified type on the Controller of the source
|
||||
*/
|
||||
public CountersControllerCount(CounterType counterType) {
|
||||
this.counterType = counterType;
|
||||
}
|
||||
|
||||
protected CountersControllerCount(final CountersControllerCount countersCount) {
|
||||
this.counterType = countersCount.counterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
UUID controllerId = sourceAbility.getControllerId();
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player == null) {
|
||||
return 0;
|
||||
}
|
||||
return counterType != null
|
||||
? player.getCountersCount(counterType)
|
||||
: 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountersControllerCount copy() {
|
||||
return new CountersControllerCount(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return (counterType != null ? counterType.toString() + ' ' : "") + "counter on {this}'s controller";
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package mage.abilities.keyword;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -17,14 +18,18 @@ import mage.target.common.TargetControlledCreaturePermanent;
|
|||
*/
|
||||
public class ReconfigureAbility extends ActivatedAbilityImpl {
|
||||
|
||||
private final String manaString;
|
||||
private final Cost cost;
|
||||
|
||||
public ReconfigureAbility(String manaString) {
|
||||
super(Zone.BATTLEFIELD, new AttachEffect(Outcome.BoostCreature), new ManaCostsImpl<>(manaString));
|
||||
this.manaString = manaString;
|
||||
this(new ManaCostsImpl<>(manaString));
|
||||
}
|
||||
|
||||
public ReconfigureAbility(Cost cost) {
|
||||
super(Zone.BATTLEFIELD, new AttachEffect(Outcome.BoostCreature), cost);
|
||||
this.cost = cost;
|
||||
this.timing = TimingRule.SORCERY;
|
||||
this.addTarget(new TargetControlledCreaturePermanent());
|
||||
this.addSubAbility(new ReconfigureUnattachAbility(manaString));
|
||||
this.addSubAbility(new ReconfigureUnattachAbility(cost));
|
||||
Ability ability = new SimpleStaticAbility(new ReconfigureTypeEffect());
|
||||
ability.setRuleVisible(false);
|
||||
this.addSubAbility(ability);
|
||||
|
|
@ -32,7 +37,7 @@ public class ReconfigureAbility extends ActivatedAbilityImpl {
|
|||
|
||||
private ReconfigureAbility(final ReconfigureAbility ability) {
|
||||
super(ability);
|
||||
this.manaString = ability.manaString;
|
||||
this.cost = ability.cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -42,7 +47,7 @@ public class ReconfigureAbility extends ActivatedAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Reconfigure " + manaString + " (" + manaString
|
||||
return "Reconfigure " + cost.getText() + " (" + cost.getText()
|
||||
+ ": Attach to target creature you control; " +
|
||||
"or unattach from a creature. Reconfigure only as a sorcery. " +
|
||||
"While attached, this isn't a creature.)";
|
||||
|
|
@ -51,8 +56,8 @@ public class ReconfigureAbility extends ActivatedAbilityImpl {
|
|||
|
||||
class ReconfigureUnattachAbility extends ActivatedAbilityImpl {
|
||||
|
||||
protected ReconfigureUnattachAbility(String manaString) {
|
||||
super(Zone.BATTLEFIELD, new ReconfigureUnattachEffect(), new ManaCostsImpl<>(manaString));
|
||||
protected ReconfigureUnattachAbility(Cost cost) {
|
||||
super(Zone.BATTLEFIELD, new ReconfigureUnattachEffect(), cost);
|
||||
this.condition = ReconfigureUnattachAbility::checkForCreature;
|
||||
this.timing = TimingRule.SORCERY;
|
||||
this.setRuleVisible(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue