mirror of
https://github.com/correl/mage.git
synced 2025-04-13 09:11:06 -09:00
removed unnecessary lastAddedToken method from TokenImpl, reworked Warren Weirding
This commit is contained in:
parent
676c3a8bb4
commit
a581d55160
7 changed files with 31 additions and 69 deletions
Mage.Sets/src/mage/cards
Mage/src/main/java/mage
abilities/effects/common
game
|
@ -69,7 +69,7 @@ class GripOfPhyresisEffect extends CreateTokenEffect {
|
||||||
|
|
||||||
if (controller != null && equipment != null) {
|
if (controller != null && equipment != null) {
|
||||||
if (super.apply(game, source)) {
|
if (super.apply(game, source)) {
|
||||||
Permanent germ = game.getPermanent(this.getLastAddedTokenId());
|
Permanent germ = game.getPermanent(this.getLastAddedTokenIds().stream().findFirst().orElse(null));
|
||||||
if (germ != null) {
|
if (germ != null) {
|
||||||
germ.addAttachment(equipment.getId(), source, game);
|
germ.addAttachment(equipment.getId(), source, game);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
|
|
||||||
package mage.cards.w;
|
package mage.cards.w;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.CreateTokenTargetEffect;
|
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||||
import mage.abilities.keyword.HasteAbility;
|
import mage.abilities.keyword.HasteAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -16,17 +10,18 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.GoblinRogueToken;
|
import mage.game.permanent.token.GoblinRogueToken;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.targetpointer.FixedTargets;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
@ -37,7 +32,6 @@ public final class WarrenWeirding extends CardImpl {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.TRIBAL, CardType.SORCERY}, "{1}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.TRIBAL, CardType.SORCERY}, "{1}{B}");
|
||||||
this.subtype.add(SubType.GOBLIN);
|
this.subtype.add(SubType.GOBLIN);
|
||||||
|
|
||||||
|
|
||||||
// Target player sacrifices a creature. If a Goblin is sacrificed this way, that player creates two 1/1 black Goblin Rogue creature tokens, and those tokens gain haste until end of turn.
|
// Target player sacrifices a creature. If a Goblin is sacrificed this way, that player creates two 1/1 black Goblin Rogue creature tokens, and those tokens gain haste until end of turn.
|
||||||
this.getSpellAbility().addEffect(new WarrenWeirdingEffect());
|
this.getSpellAbility().addEffect(new WarrenWeirdingEffect());
|
||||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||||
|
@ -63,7 +57,8 @@ class WarrenWeirdingEffect extends OneShotEffect {
|
||||||
|
|
||||||
WarrenWeirdingEffect() {
|
WarrenWeirdingEffect() {
|
||||||
super(Outcome.Sacrifice);
|
super(Outcome.Sacrifice);
|
||||||
staticText = "Target player sacrifices a creature. If a Goblin is sacrificed this way, that player creates two 1/1 black Goblin Rogue creature tokens, and those tokens gain haste until end of turn";
|
staticText = "Target player sacrifices a creature. If a Goblin is sacrificed this way, that player " +
|
||||||
|
"creates two 1/1 black Goblin Rogue creature tokens, and those tokens gain haste until end of turn";
|
||||||
}
|
}
|
||||||
|
|
||||||
WarrenWeirdingEffect(WarrenWeirdingEffect effect) {
|
WarrenWeirdingEffect(WarrenWeirdingEffect effect) {
|
||||||
|
@ -73,45 +68,30 @@ class WarrenWeirdingEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||||
if (player == null) {
|
if (player == null || game.getBattlefield().count(
|
||||||
|
StaticFilters.FILTER_CONTROLLED_CREATURE, player.getId(), source, game
|
||||||
|
) < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FilterControlledPermanent filter = new FilterControlledPermanent("creature");
|
TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_CREATURE);
|
||||||
filter.add(CardType.CREATURE.getPredicate());
|
target.setNotTarget(true);
|
||||||
filter.add(new ControllerIdPredicate(player.getId()));
|
player.choose(outcome, target, source, game);
|
||||||
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
|
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||||
|
if (permanent == null || !permanent.sacrifice(source, game)) {
|
||||||
//A spell or ability could have removed the only legal target this player
|
return false;
|
||||||
//had, if thats the case this ability should fizzle.
|
|
||||||
if (target.canChoose(player.getId(), source, game)) {
|
|
||||||
player.choose(Outcome.Sacrifice, target, source, game);
|
|
||||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
|
||||||
if (permanent != null) {
|
|
||||||
permanent.sacrifice(source, game);
|
|
||||||
if (filterGoblin.match(permanent, game)) {
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
Token token = new GoblinRogueToken();
|
|
||||||
Effect effect = new CreateTokenTargetEffect(token);
|
|
||||||
effect.setTargetPointer(new FixedTarget(player.getId()));
|
|
||||||
if (effect.apply(game, source)) {
|
|
||||||
Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
|
|
||||||
if (tokenPermanent != null) {
|
|
||||||
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
|
|
||||||
hasteEffect.setTargetPointer(new FixedTarget(tokenPermanent.getId()));
|
|
||||||
game.addEffect(hasteEffect, source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
if (permanent.hasSubtype(SubType.GOBLIN, game)) {
|
||||||
|
Token token = new GoblinRogueToken();
|
||||||
|
token.putOntoBattlefield(2, game, source, player.getId());
|
||||||
|
game.addEffect(new GainAbilityTargetEffect(
|
||||||
|
HasteAbility.getInstance(), Duration.EndOfTurn
|
||||||
|
).setTargetPointer(new FixedTargets(token, game)), source);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WarrenWeirdingEffect copy() {
|
public WarrenWeirdingEffect copy() {
|
||||||
return new WarrenWeirdingEffect(this);
|
return new WarrenWeirdingEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author weirddan455
|
* @author weirddan455
|
||||||
*/
|
*/
|
||||||
public class CreateTokenAttachSourceEffect extends CreateTokenEffect {
|
public class CreateTokenAttachSourceEffect extends CreateTokenEffect {
|
||||||
|
@ -28,7 +27,7 @@ public class CreateTokenAttachSourceEffect extends CreateTokenEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
super.apply(game, source);
|
super.apply(game, source);
|
||||||
Permanent token = game.getPermanent(this.getLastAddedTokenId());
|
Permanent token = game.getPermanent(this.getLastAddedTokenIds().stream().findFirst().orElse(null));
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
token.addAttachment(source.getSourceId(), source, game);
|
token.addAttachment(source.getSourceId(), source, game);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,11 +24,10 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public class CreateTokenEffect extends OneShotEffect {
|
public class CreateTokenEffect extends OneShotEffect {
|
||||||
|
|
||||||
private Token token;
|
private final Token token;
|
||||||
private DynamicValue amount;
|
private final DynamicValue amount;
|
||||||
private boolean tapped;
|
private final boolean tapped;
|
||||||
private boolean attacking;
|
private final boolean attacking;
|
||||||
private UUID lastAddedTokenId;
|
|
||||||
private List<UUID> lastAddedTokenIds = new ArrayList<>();
|
private List<UUID> lastAddedTokenIds = new ArrayList<>();
|
||||||
|
|
||||||
public CreateTokenEffect(Token token) {
|
public CreateTokenEffect(Token token) {
|
||||||
|
@ -62,7 +61,6 @@ public class CreateTokenEffect extends OneShotEffect {
|
||||||
this.token = effect.token.copy();
|
this.token = effect.token.copy();
|
||||||
this.tapped = effect.tapped;
|
this.tapped = effect.tapped;
|
||||||
this.attacking = effect.attacking;
|
this.attacking = effect.attacking;
|
||||||
this.lastAddedTokenId = effect.lastAddedTokenId;
|
|
||||||
this.lastAddedTokenIds.addAll(effect.lastAddedTokenIds);
|
this.lastAddedTokenIds.addAll(effect.lastAddedTokenIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,16 +73,11 @@ public class CreateTokenEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int value = amount.calculate(game, source, this);
|
int value = amount.calculate(game, source, this);
|
||||||
token.putOntoBattlefield(value, game, source, source.getControllerId(), tapped, attacking);
|
token.putOntoBattlefield(value, game, source, source.getControllerId(), tapped, attacking);
|
||||||
this.lastAddedTokenId = token.getLastAddedToken();
|
|
||||||
this.lastAddedTokenIds = token.getLastAddedTokenIds();
|
this.lastAddedTokenIds = token.getLastAddedTokenIds();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getLastAddedTokenId() {
|
|
||||||
return lastAddedTokenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UUID> getLastAddedTokenIds() {
|
public List<UUID> getLastAddedTokenIds() {
|
||||||
return lastAddedTokenIds;
|
return lastAddedTokenIds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ public interface Token extends MageObject {
|
||||||
|
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
UUID getLastAddedToken();
|
|
||||||
|
|
||||||
List<UUID> getLastAddedTokenIds();
|
List<UUID> getLastAddedTokenIds();
|
||||||
|
|
||||||
void addAbility(Ability ability);
|
void addAbility(Ability ability);
|
||||||
|
|
|
@ -30,7 +30,6 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
|
||||||
|
|
||||||
protected String description;
|
protected String description;
|
||||||
private final ArrayList<UUID> lastAddedTokenIds = new ArrayList<>();
|
private final ArrayList<UUID> lastAddedTokenIds = new ArrayList<>();
|
||||||
private UUID lastAddedTokenId;
|
|
||||||
private int tokenType;
|
private int tokenType;
|
||||||
private String originalCardNumber;
|
private String originalCardNumber;
|
||||||
private String originalExpansionSetCode;
|
private String originalExpansionSetCode;
|
||||||
|
@ -76,7 +75,6 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
|
||||||
super(token);
|
super(token);
|
||||||
this.description = token.description;
|
this.description = token.description;
|
||||||
this.tokenType = token.tokenType;
|
this.tokenType = token.tokenType;
|
||||||
this.lastAddedTokenId = token.lastAddedTokenId;
|
|
||||||
this.lastAddedTokenIds.addAll(token.lastAddedTokenIds);
|
this.lastAddedTokenIds.addAll(token.lastAddedTokenIds);
|
||||||
this.originalCardNumber = token.originalCardNumber;
|
this.originalCardNumber = token.originalCardNumber;
|
||||||
this.originalExpansionSetCode = token.originalExpansionSetCode;
|
this.originalExpansionSetCode = token.originalExpansionSetCode;
|
||||||
|
@ -113,11 +111,6 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getLastAddedToken() {
|
|
||||||
return lastAddedTokenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UUID> getLastAddedTokenIds() {
|
public List<UUID> getLastAddedTokenIds() {
|
||||||
return new ArrayList<>(lastAddedTokenIds);
|
return new ArrayList<>(lastAddedTokenIds);
|
||||||
|
@ -301,7 +294,6 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
|
||||||
// keep tokens ids
|
// keep tokens ids
|
||||||
if (token instanceof TokenImpl) {
|
if (token instanceof TokenImpl) {
|
||||||
((TokenImpl) token).lastAddedTokenIds.add(permanent.getId());
|
((TokenImpl) token).lastAddedTokenIds.add(permanent.getId());
|
||||||
((TokenImpl) token).lastAddedTokenId = permanent.getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// created token events
|
// created token events
|
||||||
|
|
|
@ -273,7 +273,7 @@ public class Spell extends StackObjectImpl implements Card {
|
||||||
CardUtil.copyTo(token).from(card, game, this);
|
CardUtil.copyTo(token).from(card, game, this);
|
||||||
// The token that a resolving copy of a spell becomes isn’t said to have been “created.” (2020-09-25)
|
// The token that a resolving copy of a spell becomes isn’t said to have been “created.” (2020-09-25)
|
||||||
if (token.putOntoBattlefield(1, game, ability, getControllerId(), false, false, null, false)) {
|
if (token.putOntoBattlefield(1, game, ability, getControllerId(), false, false, null, false)) {
|
||||||
permId = token.getLastAddedToken();
|
permId = token.getLastAddedTokenIds().stream().findFirst().orElse(null);
|
||||||
flag = true;
|
flag = true;
|
||||||
} else {
|
} else {
|
||||||
permId = null;
|
permId = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue