[SWS] Fixed some problems.

This commit is contained in:
LevelX2 2016-10-02 22:50:34 +02:00
parent da685472d8
commit 6554102367
7 changed files with 36 additions and 66 deletions

View file

@ -47,18 +47,11 @@ public class BatheInBacta extends CardImpl {
super(ownerId, 129, "Bathe in Bacta", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{G}");
this.expansionSetCode = "SWS";
// You gain 6 life.
// You gain 6 life. If you lost life from a source other than combat damage this turn, you gain 9 life instead.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new GainLifeEffect(6),
new GainLifeEffect(6), new GainLifeEffect(9),
new InvertCondition(HateCondition.getInstance()),
"You gain 6 life"));
// If you lost life from a source other than combat damage this turn, you gain 9 life instead.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new GainLifeEffect(9),
HateCondition.getInstance(),
"If you lost life from a source other than combat damage this turn, you gain 9 life instead"));
"You gain 6 life. If you lost life from a source other than combat damage this turn, you gain 9 life instead"));
this.getSpellAbility().addWatcher(new LifeLossOtherFromCombatWatcher());
}

View file

@ -31,11 +31,11 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -59,7 +59,7 @@ public class MoistureFarm extends CardImpl {
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), new TapSourceCost()));
// {T}, Remove a storage counter from Moisture Farm: Add one mana of any color to your mana pool.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(1), new TapSourceCost());
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(1), new TapSourceCost());
ability.addCost(new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()));
this.addAbility(ability);
}

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.HateCondition;
import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -41,7 +42,6 @@ import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
/**
*
@ -57,10 +57,8 @@ public class Terentatek extends CardImpl {
this.toughness = new MageInt(3);
// Terentatek can't attack or block unless you control a Sith.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new Terentatek1RestrictionEffect()));
// <i>Hate</i> &mdash; If an opponent lost life from source other than combat damage this turn, Terentatek may attack as though you controlled a Sith.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new Terentatek2RestrictionEffect()), new LifeLossOtherFromCombatWatcher());
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new Terentatek1RestrictionEffect()));
}
@ -84,7 +82,8 @@ class Terentatek1RestrictionEffect extends RestrictionEffect {
public Terentatek1RestrictionEffect() {
super(Duration.WhileOnBattlefield);
staticText = "{this} can't attack or block unless you control a Sith";
staticText = "{this} can't attack or block unless you control a Sith."
+ "<br><br><i>Hate</i> &mdash; If an opponent lost life from source other than combat damage this turn, {this} may attack as though you controlled a Sith";
}
public Terentatek1RestrictionEffect(final Terentatek1RestrictionEffect effect) {
@ -98,53 +97,23 @@ class Terentatek1RestrictionEffect extends RestrictionEffect {
@Override
public boolean canAttack(Game game) {
return false;
Ability source = (Ability) getValue("source");
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0
|| HateCondition.getInstance().apply(game, source);
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0;
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getId().equals(source.getSourceId())) {
if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
return false;
}
setValue("source", source);
return true;
}
return false;
}
}
class Terentatek2RestrictionEffect extends RestrictionEffect {
public Terentatek2RestrictionEffect() {
super(Duration.WhileOnBattlefield);
staticText = "<i>Hate</i> &mdash; If an opponent lost life from source other than combat damage this turn, {this} may attack as though you controlled a Sith.";
}
public Terentatek2RestrictionEffect(final Terentatek2RestrictionEffect effect) {
super(effect);
}
@Override
public Terentatek2RestrictionEffect copy() {
return new Terentatek2RestrictionEffect(this);
}
@Override
public boolean canAttack(Game game) {
return true;
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getId().equals(source.getSourceId())) {
LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get("NonCombatDamageWatcher");
return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId());
}
return false;
}
}

View file

@ -55,7 +55,7 @@ public class HateCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get(LifeLossOtherFromCombatWatcher.class.getName());
return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId());
return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId(), game);
}
@Override

View file

@ -75,16 +75,14 @@ public class DiscardTargetCost extends CostImpl {
int amount = this.getTargets().get(0).getNumberOfTargets();
if (randomDiscard) {
this.cards.addAll(player.discard(amount, true, ability, game).getCards(game));
} else {
if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
for (UUID targetId : targets.get(0).getTargets()) {
Card card = player.getHand().get(targetId, game);
if (card == null) {
return false;
}
player.discard(card, ability, game);
this.cards.add(card);
} else if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
for (UUID targetId : targets.get(0).getTargets()) {
Card card = player.getHand().get(targetId, game);
if (card == null) {
return false;
}
player.discard(card, ability, game);
this.cards.add(card);
}
}
paid = cards.size() >= amount;

View file

@ -55,6 +55,10 @@ public class RepairAbility extends DiesTriggeredAbility {
return ruleText;
}
@Override
public RepairAbility copy() {
return new RepairAbility(this);
}
}
class RepairCastFromGraveyardEffect extends AsThoughEffectImpl {

View file

@ -33,6 +33,7 @@ import java.util.UUID;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.watchers.Watcher;
/*
@ -61,9 +62,14 @@ public class LifeLossOtherFromCombatWatcher extends Watcher {
}
}
public boolean opponentLostLifeOtherFromCombat(UUID playerId) {
return (!players.contains(playerId) && players.size() > 0)
|| (players.contains(playerId) && players.size() > 1);
public boolean opponentLostLifeOtherFromCombat(UUID playerId, Game game) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (players.stream().anyMatch((damagedPlayerId) -> (player.hasOpponent(damagedPlayerId, game)))) {
return true;
}
}
return false;
}
@Override