mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
Fixed Urborg's functionality, also fixed Scarwood Hag not removing forestwalk properly (#4088)
This commit is contained in:
parent
71336a916d
commit
1453fa46a7
2 changed files with 58 additions and 5 deletions
|
|
@ -31,15 +31,22 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.continuous.LoseAbilityOrAnotherAbilityTargetEffect;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.LoseAbilityTargetEffect;
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.abilities.keyword.SwampwalkAbility;
|
||||
import mage.abilities.mana.BlackManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
|
@ -49,13 +56,14 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
public class Urborg extends CardImpl {
|
||||
|
||||
public Urborg(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
|
||||
// {tap}: Add {B} to your mana pool.
|
||||
this.addAbility(new BlackManaAbility());
|
||||
|
||||
// {tap}: Target creature loses first strike or swampwalk until end of turn.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LoseAbilityOrAnotherAbilityTargetEffect(FirstStrikeAbility.getInstance(), new SwampwalkAbility()), new TapSourceCost());
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new UrborgEffect(), new TapSourceCost());
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
@ -70,4 +78,38 @@ public class Urborg extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class UrborgEffect extends OneShotEffect {
|
||||
|
||||
UrborgEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Target creature loses first strike or swampwalk until end of turn.";
|
||||
}
|
||||
|
||||
UrborgEffect(final UrborgEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UrborgEffect copy() {
|
||||
return new UrborgEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
Ability ability;
|
||||
if (player.chooseUse(Outcome.UnboostCreature, "Which ability should be lost?", null, "First Strike", "Swampwalk", source, game)) {
|
||||
ability = FirstStrikeAbility.getInstance();
|
||||
} else {
|
||||
ability = new SwampwalkAbility();
|
||||
}
|
||||
ContinuousEffect effect = new LoseAbilityTargetEffect(ability, Duration.EndOfTurn);
|
||||
// effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.Iterator;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
|
|
@ -69,9 +71,18 @@ public class LoseAbilityTargetEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
if (ability instanceof MageSingleton) {
|
||||
while (permanent.getAbilities().contains(ability)) {
|
||||
permanent.getAbilities().remove(ability);
|
||||
}
|
||||
} else {
|
||||
for (Iterator<Ability> iter = permanent.getAbilities().iterator(); iter.hasNext();) {
|
||||
Ability ab = iter.next();
|
||||
if (ab.getClass().equals(ability.getClass())) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue