mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 20:59:14 -08:00
Refactored copying permanents
This commit is contained in:
parent
ba375573ff
commit
0335d4d77e
6 changed files with 25 additions and 18 deletions
|
|
@ -92,16 +92,17 @@ class PhantasmalImageCopyEffect extends OneShotEffect<PhantasmalImageCopyEffect>
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if ( player != null ) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && sourcePermanent != null) {
|
||||
Target target = new TargetPermanent(new FilterCreaturePermanent());
|
||||
if (target.canChoose(source.getControllerId(), game)) {
|
||||
target.setRequired(true);
|
||||
target.setNotTarget(true);
|
||||
player.choose(Outcome.Copy, target, source.getSourceId(), game);
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
game.copyPermanent(permanent, source, new ApplyToPermanent() {
|
||||
Permanent copyFromPermanent = game.getPermanent(targetId);
|
||||
if (copyFromPermanent != null) {
|
||||
game.copyPermanent(copyFromPermanent, sourcePermanent, source, new ApplyToPermanent() {
|
||||
@Override
|
||||
public Boolean apply(Game game, Permanent permanent) {
|
||||
permanent.getSubtype().add("Illusion");
|
||||
|
|
|
|||
|
|
@ -97,13 +97,14 @@ class PhyrexianMetamorphEffect extends OneShotEffect<PhyrexianMetamorphEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && sourcePermanent != null) {
|
||||
Target target = new TargetPermanent(filter);
|
||||
if (target.canChoose(source.getControllerId(), game)) {
|
||||
player.choose(Outcome.Copy, target, source.getSourceId(), game);
|
||||
Permanent perm = game.getPermanent(target.getFirstTarget());
|
||||
if (perm != null) {
|
||||
game.copyPermanent(perm, source, new ApplyToPermanent() {
|
||||
Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
|
||||
if (copyFromPermanent != null) {
|
||||
game.copyPermanent(copyFromPermanent, sourcePermanent, source, new ApplyToPermanent() {
|
||||
@Override
|
||||
public Boolean apply(Game game, Permanent permanent) {
|
||||
if (!permanent.getCardType().contains(CardType.ARTIFACT)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue