mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
[NEO] Implemented Reconfigure abliity
This commit is contained in:
parent
5945aaeda4
commit
495fc57540
5 changed files with 172 additions and 11 deletions
|
|
@ -1,7 +1,17 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -11,9 +21,14 @@ public class ReconfigureAbility extends ActivatedAbilityImpl {
|
|||
private final String manaString;
|
||||
|
||||
public ReconfigureAbility(String manaString) {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
super(Zone.BATTLEFIELD, new AttachEffect(Outcome.BoostCreature), new ManaCostsImpl<>(manaString));
|
||||
this.manaString = manaString;
|
||||
// TODO: Implement this
|
||||
this.timing = TimingRule.SORCERY;
|
||||
this.addTarget(new TargetControlledCreaturePermanent());
|
||||
this.addSubAbility(new ReconfigureUnattachAbility(manaString));
|
||||
Ability ability = new SimpleStaticAbility(new ReconfigureTypeEffect());
|
||||
ability.setRuleVisible(false);
|
||||
this.addSubAbility(ability);
|
||||
}
|
||||
|
||||
private ReconfigureAbility(final ReconfigureAbility ability) {
|
||||
|
|
@ -31,6 +46,75 @@ public class ReconfigureAbility extends ActivatedAbilityImpl {
|
|||
return "Reconfigure " + manaString + " (" + manaString
|
||||
+ ": Attach to target creature you control; " +
|
||||
"or unattach from a creature. Reconfigure only as a sorcery. " +
|
||||
"While attached, this isn’t a creature.)";
|
||||
"While attached, this isn't a creature.)";
|
||||
}
|
||||
}
|
||||
|
||||
class ReconfigureUnattachAbility extends ActivateAsSorceryActivatedAbility {
|
||||
|
||||
protected ReconfigureUnattachAbility(String manaString) {
|
||||
super(Zone.BATTLEFIELD, new ReconfigureUnattachEffect(), new ManaCostsImpl<>(manaString));
|
||||
this.setRuleVisible(true);
|
||||
}
|
||||
|
||||
private ReconfigureUnattachAbility(final ReconfigureUnattachAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReconfigureUnattachAbility copy() {
|
||||
return new ReconfigureUnattachAbility(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ReconfigureUnattachEffect extends OneShotEffect {
|
||||
|
||||
ReconfigureUnattachEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "unattach {this}";
|
||||
}
|
||||
|
||||
private ReconfigureUnattachEffect(final ReconfigureUnattachEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReconfigureUnattachEffect copy() {
|
||||
return new ReconfigureUnattachEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (permanent != null) {
|
||||
permanent.unattach(game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class ReconfigureTypeEffect extends ContinuousEffectImpl {
|
||||
|
||||
ReconfigureTypeEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
|
||||
}
|
||||
|
||||
private ReconfigureTypeEffect(final ReconfigureTypeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReconfigureTypeEffect copy() {
|
||||
return new ReconfigureTypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (permanent == null || game.getPermanent(permanent.getAttachedTo()) == null) {
|
||||
return false;
|
||||
}
|
||||
permanent.removeCardType(game, CardType.CREATURE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue