Fixed rule text bug of ReturnToHandSourceEffect, improved BeginningOfUpkeepTriggeredAbility, samall change to Token.

This commit is contained in:
LevelX2 2012-12-28 17:31:09 +01:00
parent 6a46d05af1
commit f9242b6de3
3 changed files with 47 additions and 7 deletions

View file

@ -1,3 +1,31 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.common;
import mage.Constants;
@ -8,21 +36,33 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author Loki
*/
public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<BeginningOfUpkeepTriggeredAbility> {
private Constants.TargetController targetController;
private boolean setTargetPointer;
public BeginningOfUpkeepTriggeredAbility(Effect effect, Constants.TargetController targetController, boolean isOptional) {
this(Constants.Zone.BATTLEFIELD, effect, targetController, isOptional);
}
public BeginningOfUpkeepTriggeredAbility(Constants.Zone zone, Effect effect, Constants.TargetController targetController, boolean isOptional) {
this(zone, effect, targetController, isOptional, true);
}
public BeginningOfUpkeepTriggeredAbility(Constants.Zone zone, Effect effect, Constants.TargetController targetController, boolean isOptional, boolean setTargetPointer) {
super(zone, effect, isOptional);
this.targetController = targetController;
this.setTargetPointer = setTargetPointer;
}
public BeginningOfUpkeepTriggeredAbility(final BeginningOfUpkeepTriggeredAbility ability) {
super(ability);
this.targetController = ability.targetController;
this.setTargetPointer = ability.setTargetPointer;
}
@Override
@ -36,7 +76,7 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<Begi
switch (targetController) {
case YOU:
boolean yours = event.getPlayerId().equals(this.controllerId);
if (yours) {
if (yours && setTargetPointer) {
if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
@ -46,7 +86,7 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<Begi
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (getTargets().size() == 0) {
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
@ -55,7 +95,7 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<Begi
}
break;
case ANY:
if (getTargets().size() == 0) {
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
@ -66,7 +106,7 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<Begi
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (getTargets().size() == 0) {
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}

View file

@ -43,13 +43,13 @@ public class ReturnToHandSourceEffect extends OneShotEffect<ReturnToHandSourceEf
boolean fromBattlefieldOnly = false;
public ReturnToHandSourceEffect() {
super(Outcome.ReturnToHand);
staticText = "Return {this} to it's owner's hand";
this(false);
}
public ReturnToHandSourceEffect(boolean fromBattlefieldOnly) {
super(Outcome.ReturnToHand);
this.fromBattlefieldOnly = fromBattlefieldOnly;
staticText = "Return {this} to it's owner's hand";
}
public ReturnToHandSourceEffect(final ReturnToHandSourceEffect effect) {

View file

@ -115,7 +115,7 @@ public class Token extends MageObjectImpl<Token> {
for (int i = 0; i < amount; i++) {
PermanentToken permanent = new PermanentToken(this, controllerId, setCode, game);
game.getState().addCard(permanent);
game.getBattlefield().addPermanent(permanent);
game.addPermanent(permanent);
this.lastAddedTokenId = permanent.getId();
permanent.entersBattlefield(sourceId, game);
game.applyEffects();