mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Fixed copy
This commit is contained in:
parent
9eb8dd6ce5
commit
35f705e07b
2 changed files with 36 additions and 52 deletions
|
|
@ -1,44 +1,26 @@
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.common.continuous.SourceEffect;
|
import mage.abilities.effects.common.continuous.SourceEffect;
|
||||||
import mage.abilities.keyword.DeathtouchAbility;
|
import mage.abilities.keyword.*;
|
||||||
import mage.abilities.keyword.DelveAbility;
|
|
||||||
import mage.abilities.keyword.DoubleStrikeAbility;
|
|
||||||
import mage.abilities.keyword.FirstStrikeAbility;
|
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
|
||||||
import mage.abilities.keyword.HasteAbility;
|
|
||||||
import mage.abilities.keyword.HexproofAbility;
|
|
||||||
import mage.abilities.keyword.IndestructibleAbility;
|
|
||||||
import mage.abilities.keyword.LifelinkAbility;
|
|
||||||
import mage.abilities.keyword.ReachAbility;
|
|
||||||
import mage.abilities.keyword.TrampleAbility;
|
|
||||||
import mage.abilities.keyword.VigilanceAbility;
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Layer;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubLayer;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class Soulflayer extends CardImpl {
|
public final class Soulflayer extends CardImpl {
|
||||||
|
|
@ -82,7 +64,9 @@ class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||||
super(effect);
|
super(effect);
|
||||||
if (effect.abilitiesToAdd != null) {
|
if (effect.abilitiesToAdd != null) {
|
||||||
this.abilitiesToAdd = new HashSet<>();
|
this.abilitiesToAdd = new HashSet<>();
|
||||||
this.abilitiesToAdd.addAll(effect.abilitiesToAdd);
|
for (Ability a : effect.abilitiesToAdd) {
|
||||||
|
this.abilitiesToAdd.add(a.copy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.objectReference = effect.objectReference;
|
this.objectReference = effect.objectReference;
|
||||||
}
|
}
|
||||||
|
|
@ -96,6 +80,7 @@ class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
// one time abilities collect
|
||||||
if (objectReference == null || !objectReference.refersTo(permanent, game)) {
|
if (objectReference == null || !objectReference.refersTo(permanent, game)) {
|
||||||
abilitiesToAdd = new HashSet<>();
|
abilitiesToAdd = new HashSet<>();
|
||||||
this.objectReference = new MageObjectReference(permanent, game);
|
this.objectReference = new MageObjectReference(permanent, game);
|
||||||
|
|
@ -144,6 +129,8 @@ class SoulflayerEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all time abilities apply
|
||||||
for (Ability ability : abilitiesToAdd) {
|
for (Ability ability : abilitiesToAdd) {
|
||||||
permanent.addAbility(ability, source.getSourceId(), game);
|
permanent.addAbility(ability, source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.abilities.abilityword;
|
package mage.abilities.abilityword;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -21,28 +19,27 @@ import mage.players.Player;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class KinshipAbility extends TriggeredAbilityImpl {
|
public class KinshipAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
public KinshipAbility(Effect kinshipEffect) {
|
public KinshipAbility(Effect kinshipEffect) {
|
||||||
super(Zone.BATTLEFIELD, new KinshipBaseEffect(kinshipEffect), true);
|
super(Zone.BATTLEFIELD, new KinshipBaseEffect(kinshipEffect), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KinshipAbility(final KinshipAbility ability) {
|
public KinshipAbility(final KinshipAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addKinshipEffect(Effect kinshipEffect) {
|
public void addKinshipEffect(Effect kinshipEffect) {
|
||||||
for (Effect effect: this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
if (effect instanceof KinshipBaseEffect) {
|
if (effect instanceof KinshipBaseEffect) {
|
||||||
((KinshipBaseEffect) effect).addEffect(kinshipEffect);
|
((KinshipBaseEffect) effect).addEffect(kinshipEffect);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KinshipAbility copy() {
|
public KinshipAbility copy() {
|
||||||
return new KinshipAbility(this);
|
return new KinshipAbility(this);
|
||||||
|
|
@ -62,33 +59,33 @@ public class KinshipAbility extends TriggeredAbilityImpl {
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return new StringBuilder("<i>Kinship</i> — At the beginning of your upkeep, ").append(super.getRule()).toString();
|
return new StringBuilder("<i>Kinship</i> — At the beginning of your upkeep, ").append(super.getRule()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class KinshipBaseEffect extends OneShotEffect {
|
class KinshipBaseEffect extends OneShotEffect {
|
||||||
|
|
||||||
private final Effects kinshipEffects = new Effects();
|
private final Effects kinshipEffects = new Effects();
|
||||||
|
|
||||||
public KinshipBaseEffect(Effect kinshipEffect) {
|
public KinshipBaseEffect(Effect kinshipEffect) {
|
||||||
super(kinshipEffect.getOutcome());
|
super(kinshipEffect.getOutcome());
|
||||||
this.kinshipEffects.add(kinshipEffect);
|
this.kinshipEffects.add(kinshipEffect);
|
||||||
this.staticText = "you may look at the top card of your library. If it shares a creature type with {this}, you may reveal it. If you do, ";
|
this.staticText = "you may look at the top card of your library. If it shares a creature type with {this}, you may reveal it. If you do, ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public KinshipBaseEffect(final KinshipBaseEffect effect) {
|
public KinshipBaseEffect(final KinshipBaseEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.kinshipEffects.addAll(effect.kinshipEffects);
|
this.kinshipEffects.addAll(effect.kinshipEffects.copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEffect(Effect kinshipEffect) {
|
public void addEffect(Effect kinshipEffect) {
|
||||||
this.kinshipEffects.add(kinshipEffect);
|
this.kinshipEffects.add(kinshipEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KinshipBaseEffect copy() {
|
public KinshipBaseEffect copy() {
|
||||||
return new KinshipBaseEffect(this);
|
return new KinshipBaseEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
|
@ -100,22 +97,22 @@ class KinshipBaseEffect extends OneShotEffect {
|
||||||
Cards cards = new CardsImpl(card);
|
Cards cards = new CardsImpl(card);
|
||||||
controller.lookAtCards(sourcePermanent.getName(), cards, game);
|
controller.lookAtCards(sourcePermanent.getName(), cards, game);
|
||||||
if (sourcePermanent.shareSubtypes(card, game)) {
|
if (sourcePermanent.shareSubtypes(card, game)) {
|
||||||
if (controller.chooseUse(outcome,new StringBuilder("Kinship - Reveal ").append(card.getLogName()).append('?').toString(), source, game)) {
|
if (controller.chooseUse(outcome, new StringBuilder("Kinship - Reveal ").append(card.getLogName()).append('?').toString(), source, game)) {
|
||||||
controller.revealCards(sourcePermanent.getName(), cards, game);
|
controller.revealCards(sourcePermanent.getName(), cards, game);
|
||||||
for (Effect effect: kinshipEffects) {
|
for (Effect effect : kinshipEffects) {
|
||||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||||
if (effect.getEffectType() == EffectType.ONESHOT) {
|
if (effect.getEffectType() == EffectType.ONESHOT) {
|
||||||
effect.apply(game, source);
|
effect.apply(game, source);
|
||||||
} else {
|
} else {
|
||||||
if (effect instanceof ContinuousEffect) {
|
if (effect instanceof ContinuousEffect) {
|
||||||
game.addEffect((ContinuousEffect)effect, source);
|
game.addEffect((ContinuousEffect) effect, source);
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("This kind of effect is not supported");
|
throw new UnsupportedOperationException("This kind of effect is not supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -125,7 +122,7 @@ class KinshipBaseEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
return new StringBuilder(super.getText(mode)).append(kinshipEffects.getText(mode)).toString();
|
return new StringBuilder(super.getText(mode)).append(kinshipEffects.getText(mode)).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue