* Chain of Vapor - Fixed that wrong player was asked for target change of copied spell.

This commit is contained in:
LevelX2 2014-07-12 23:54:52 +02:00
parent e3dbe51255
commit 170920de6b

View file

@ -89,31 +89,34 @@ class ChainOfVaporEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Permanent permanent = game.getPermanent(source.getFirstTarget()); Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) { if (permanent != null) {
if(!permanent.moveToZone(Zone.HAND, source.getId(), game, false)){ if (!controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD)){
return false; return false;
} }
Player player = game.getPlayer(permanent.getControllerId()); Player player = game.getPlayer(permanent.getControllerId());
if(player.chooseUse(Outcome.ReturnToHand, "Sacrifice a land to copy this spell?", game)){ if (player.chooseUse(Outcome.ReturnToHand, "Sacrifice a land to copy this spell?", game)){
TargetControlledPermanent target = new TargetControlledPermanent(new FilterControlledLandPermanent()); TargetControlledPermanent target = new TargetControlledPermanent(new FilterControlledLandPermanent());
if(player.chooseTarget(Outcome.Sacrifice, target, source, game)){ if (player.chooseTarget(Outcome.Sacrifice, target, source, game)){
Permanent land = game.getPermanent(target.getFirstTarget()); Permanent land = game.getPermanent(target.getFirstTarget());
if(land != null){ if(land != null){
if(land.sacrifice(source.getId(), game)){ if(land.sacrifice(source.getId(), game)){
Spell spell = game.getStack().getSpell(source.getId()); Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) { if (spell != null) {
Spell copy = spell.copySpell(); Spell copy = spell.copySpell();
copy.setControllerId(player.getId()); copy.setControllerId(player.getId());
copy.setCopiedSpell(true); copy.setCopiedSpell(true);
game.getStack().push(copy); game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId()); copy.chooseNewTargets(game, player.getId());
String activateMessage = copy.getActivatedMessage(game); String activateMessage = copy.getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) { if (activateMessage.startsWith(" casts ")) {
activateMessage = activateMessage.substring(6); activateMessage = activateMessage.substring(6);
} }
game.informPlayers(player.getName() + " copies " + activateMessage);; game.informPlayers(player.getName() + " copies " + activateMessage);
return true; return true;
} }
return false; return false;