Merge pull request #5193 from magefree/rystan-patch-2

Fumble effect not working per #5155 feedback
This commit is contained in:
LevelX2 2018-08-15 08:14:42 +02:00 committed by GitHub
commit 51a93a01a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,7 +66,7 @@ class FumbleEffect extends OneShotEffect {
@Override @Override
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.getTargets().getFirstTarget());
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player == null || permanent == null) { if (player == null || permanent == null) {
return false; return false;
@ -75,24 +75,30 @@ class FumbleEffect extends OneShotEffect {
for (UUID permId : permanent.getAttachments()) { for (UUID permId : permanent.getAttachments()) {
Permanent attachment = game.getPermanent(permId); Permanent attachment = game.getPermanent(permId);
if (attachment != null) { if (attachment != null) {
attachments.add(permanent); if (attachment.hasSubtype(SubType.AURA, game) || attachment.hasSubtype(SubType.EQUIPMENT, game)) {
attachments.add(attachment);
}
} }
} }
new ReturnToHandTargetEffect().apply(game, source); new ReturnToHandTargetEffect().apply(game, source);
Target target = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true);
Permanent newCreature = null; if (!attachments.isEmpty()) {
if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) { Target target = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true);
newCreature = game.getPermanent(target.getFirstTarget()); Permanent newCreature = null;
} if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
for (Permanent attachment : attachments) { newCreature = game.getPermanent(target.getFirstTarget());
if (!attachment.hasSubtype(SubType.AURA, game) && !attachment.hasSubtype(SubType.EQUIPMENT, game)) {
continue;
} }
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, player.getId()); for (Permanent attachment : attachments) {
effect.setTargetPointer(new FixedTarget(attachment, game)); if (!attachment.hasSubtype(SubType.AURA, game) && !attachment.hasSubtype(SubType.EQUIPMENT, game)) {
game.addEffect(effect, source); continue;
if (newCreature != null) { }
attachment.attachTo(newCreature.getId(), game); ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, player.getId());
effect.setTargetPointer(new FixedTarget(attachment, game));
game.addEffect(effect, source);
if (newCreature != null) {
attachment.attachTo(newCreature.getId(), game);
}
} }
} }
return true; return true;