forked from External/mage
Update Thought Gorger and Toothy to use common effects/values.
This commit is contained in:
parent
2f2c7ee205
commit
1b3d2373eb
2 changed files with 10 additions and 77 deletions
|
|
@ -4,14 +4,15 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.CountersSourceCount;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -37,7 +38,10 @@ public final class ThoughtGorger extends CardImpl {
|
|||
this.addAbility(new EntersBattlefieldTriggeredAbility(new ThoughtGorgerEffectEnters()));
|
||||
|
||||
// When Thought Gorger leaves the battlefield, draw a card for each +1/+1 counter on it.
|
||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ThoughtGorgerEffectLeaves(), false));
|
||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(
|
||||
new DrawCardSourceControllerEffect(new CountersSourceCount(CounterType.P1P1))
|
||||
.setText("draw a card for each +1/+1 counter on it"), false
|
||||
));
|
||||
}
|
||||
|
||||
private ThoughtGorger(final ThoughtGorger card) {
|
||||
|
|
@ -83,33 +87,3 @@ class ThoughtGorgerEffectEnters extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class ThoughtGorgerEffectLeaves extends OneShotEffect {
|
||||
|
||||
ThoughtGorgerEffectLeaves() {
|
||||
super(Outcome.Neutral);
|
||||
this.staticText = "draw a card for each +1/+1 counter on it.";
|
||||
}
|
||||
|
||||
private ThoughtGorgerEffectLeaves(final ThoughtGorgerEffectLeaves effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThoughtGorgerEffectLeaves copy() {
|
||||
return new ThoughtGorgerEffectLeaves(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent thoughtGorgerLastState = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
int numberCounters = thoughtGorgerLastState.getCounters(game).getCount(CounterType.P1P1);
|
||||
if (player != null) {
|
||||
player.drawCards(numberCounters, source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ package mage.cards.t;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DrawCardControllerTriggeredAbility;
|
||||
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.dynamicvalue.common.CountersSourceCount;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.PartnerWithAbility;
|
||||
|
|
@ -15,10 +13,7 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -42,8 +37,9 @@ public final class ToothyImaginaryFriend extends CardImpl {
|
|||
|
||||
// When Toothy leaves the battlefield, draw a card for each +1/+1 counter on it.
|
||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(
|
||||
new DrawCardSourceControllerEffect(new ToothyImaginaryFriendCountersCount(CounterType.P1P1))
|
||||
.setText("draw a card for each +1/+1 counter on it"), false));
|
||||
new DrawCardSourceControllerEffect(new CountersSourceCount(CounterType.P1P1))
|
||||
.setText("draw a card for each +1/+1 counter on it"), false
|
||||
));
|
||||
}
|
||||
|
||||
private ToothyImaginaryFriend(final ToothyImaginaryFriend card) {
|
||||
|
|
@ -55,40 +51,3 @@ public final class ToothyImaginaryFriend extends CardImpl {
|
|||
return new ToothyImaginaryFriend(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ToothyImaginaryFriendCountersCount implements DynamicValue {
|
||||
|
||||
private final String counterName;
|
||||
|
||||
public ToothyImaginaryFriendCountersCount(CounterType counter) {
|
||||
this.counterName = counter.getName();
|
||||
}
|
||||
|
||||
private ToothyImaginaryFriendCountersCount(final ToothyImaginaryFriendCountersCount countersCount) {
|
||||
this.counterName = countersCount.counterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);
|
||||
if (permanent != null) {
|
||||
return permanent.getCounters(game).getCount(counterName);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToothyImaginaryFriendCountersCount copy() {
|
||||
return new ToothyImaginaryFriendCountersCount(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return counterName + " counter on {this}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue