Ugly fix for Mogg Assassin's targetting

This commit is contained in:
Zzooouhh 2017-11-07 00:19:41 +01:00 committed by GitHub
parent 53bde045d3
commit ffde9d0886
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,11 +40,16 @@ import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.predicate.ObjectPlayer;
import mage.game.Controllable;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectPlayer;
import mage.filter.predicate.ObjectPlayerPredicate;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetOpponent;
import mage.target.common.TargetOpponentsCreaturePermanent;
/**
@ -73,19 +78,29 @@ public class MoggAssassin extends CardImpl {
@Override
public void adjustTargets(Ability ability, Game game) {
if(ability.getOriginalId().equals(originalId)) {
if (ability.getOriginalId().equals(originalId)) {
Player controller = game.getPlayer(ability.getControllerId());
if(controller != null && ability.getTargets().get(0) != null) {
if (controller != null) {
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Permanent permanent = game.getPermanentOrLKIBattlefield(ability.getTargets().get(0).getFirstTarget());
if (permanent != null) {
opponentId = permanent.getControllerId();
ability.getTargets().clear();
Target target1 = new TargetOpponent(true);
if (controller.chooseTarget(Outcome.Neutral, target1, ability, game)) {
opponentId = target1.getFirstTarget();
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature controlled by the chosen opponent");
filter.add(new ChosenOpponentControlledPredicate(opponentId));
Target target2 = new TargetCreaturePermanent(filter);
Target target3 = new TargetCreaturePermanent();
ability.addTarget(target2);
ability.addTarget(target3);
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if(opponentId != null) {
if (opponentId != null) {
ability.getTargets().get(1).setTargetController(opponentId);
}
}
@ -104,6 +119,24 @@ public class MoggAssassin extends CardImpl {
}
class ChosenOpponentControlledPredicate implements ObjectPlayerPredicate<ObjectPlayer<Controllable>> {
private final UUID controller;
public ChosenOpponentControlledPredicate(UUID controller) {
this.controller = controller;
}
@Override
public boolean apply(ObjectPlayer<Controllable> input, Game game) {
Controllable object = input.getObject();
if (object.getControllerId().equals(controller)) {
return true;
}
return false;
}
}
class MoggAssassinEffect extends OneShotEffect {
public MoggAssassinEffect() {