* Updated enters battlefield replacement effects for new handling.

This commit is contained in:
LevelX2 2015-10-16 00:32:55 +02:00
parent d264dd83e1
commit 6dfbcab5ab
9 changed files with 201 additions and 119 deletions

View file

@ -27,6 +27,8 @@
*/
package mage.sets.riseoftheeldrazi;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -39,17 +41,17 @@ import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.FilterSpell;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.filter.predicate.other.TargetsPermanentPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
import mage.target.Target;
import mage.target.TargetSpell;
import mage.target.TargetObject;
import mage.target.Targets;
/**
*
@ -57,19 +59,14 @@ import mage.target.TargetSpell;
*/
public class NotOfThisWorld extends CardImpl {
private final static FilterSpell filter = new FilterSpell("spell that targets a permanent you control");
static {
filter.add(new TargetsPermanentPredicate(new FilterControlledPermanent()));
}
public NotOfThisWorld(UUID ownerId) {
super(ownerId, 8, "Not of This World", Rarity.UNCOMMON, new CardType[]{CardType.TRIBAL, CardType.INSTANT}, "{7}");
this.expansionSetCode = "ROE";
this.subtype.add("Eldrazi");
// Counter target spell or ability that targets a permanent you control.
this.getSpellAbility().addTarget(new TargetSpell(filter));
this.getSpellAbility().addTarget(
new TargetStackObjectTargetingControlledPermanent());
this.getSpellAbility().addEffect(new CounterTargetEffect());
// Not of This World costs {7} less to cast if it targets a spell or ability that targets a creature you control with power 7 or greater.
this.addAbility(new SimpleStaticAbility(Zone.STACK, new SpellCostReductionSourceEffect(7, NotOfThisWorldCondition.getInstance())));
@ -85,6 +82,92 @@ public class NotOfThisWorld extends CardImpl {
}
}
class TargetStackObjectTargetingControlledPermanent extends TargetObject {
public TargetStackObjectTargetingControlledPermanent() {
this.minNumberOfTargets = 1;
this.maxNumberOfTargets = 1;
this.zone = Zone.STACK;
this.targetName = "spell or ability that targets a permanent you control";
}
public TargetStackObjectTargetingControlledPermanent(final TargetStackObjectTargetingControlledPermanent target) {
super(target);
}
@Override
public Filter getFilter() {
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
StackObject stackObject = game.getStack().getStackObject(id);
if ((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) {
return true;
}
return false;
}
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
return canChoose(sourceControllerId, game);
}
@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
for (StackObject stackObject : game.getStack()) {
if ((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) {
Targets objectTargets = stackObject.getStackAbility().getTargets();
if (!objectTargets.isEmpty()) {
for (Target target : objectTargets) {
for (UUID targetId : target.getTargets()) {
Permanent targetedPermanent = game.getPermanentOrLKIBattlefield(targetId);
if (targetedPermanent != null && targetedPermanent.getControllerId().equals(sourceControllerId)) {
return true;
}
}
}
}
}
}
return false;
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId,
Game game) {
return possibleTargets(sourceControllerId, game);
}
@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();
for (StackObject stackObject : game.getStack()) {
if ((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) {
Targets objectTargets = stackObject.getStackAbility().getTargets();
if (!objectTargets.isEmpty()) {
for (Target target : objectTargets) {
for (UUID targetId : target.getTargets()) {
Permanent targetedPermanent = game.getPermanentOrLKIBattlefield(targetId);
if (targetedPermanent != null && targetedPermanent.getControllerId().equals(sourceControllerId)) {
possibleTargets.add(stackObject.getId());
}
}
}
}
}
}
return possibleTargets;
}
@Override
public TargetStackObjectTargetingControlledPermanent copy() {
return new TargetStackObjectTargetingControlledPermanent(this);
}
}
class NotOfThisWorldCondition implements Condition {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control with power 7 or greater");

View file

@ -1,16 +1,16 @@
/*
* 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
@ -20,18 +20,17 @@
* 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.Zone;
import mage.abilities.StaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.TapSourceEffect;
import mage.constants.Zone;
/**
*
@ -40,9 +39,9 @@ import mage.abilities.effects.common.TapSourceEffect;
public class EntersBattlefieldTappedAbility extends StaticAbility {
private String ruleText;
public EntersBattlefieldTappedAbility() {
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new TapSourceEffect(true)));
super(Zone.ALL, new EntersBattlefieldEffect(new TapSourceEffect(true)));
}
public EntersBattlefieldTappedAbility(String ruleText) {

View file

@ -59,6 +59,9 @@ public class EntersBattlefieldWithXCountersEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
}
if (permanent != null) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null

View file

@ -1,36 +1,36 @@
/*
* 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.
*/
* 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.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -39,6 +39,7 @@ import mage.game.permanent.Permanent;
* @author BetaSteward_at_googlemail.com
*/
public class TapSourceEffect extends OneShotEffect {
private boolean withoutTrigger;
public TapSourceEffect() {
@ -64,6 +65,9 @@ public class TapSourceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
}
if (permanent != null) {
if (withoutTrigger) {
permanent.setTapped(true);

View file

@ -1,16 +1,16 @@
/*
* 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
@ -20,7 +20,7 @@
* 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.
@ -30,6 +30,7 @@ package mage.abilities.effects.common.continuous;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Layer;
@ -88,12 +89,17 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl implements Sou
public GainAbilitySourceEffect copy() {
return new GainAbilitySourceEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
if (affectedObjectsSet) {
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (permanent != null) {
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()) + 1, game));
} else {
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
}
}
}

View file

@ -2,6 +2,7 @@ package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.counters.CounterType;
@ -12,10 +13,11 @@ import mage.util.CardUtil;
import mage.watchers.common.BloodthirstWatcher;
/**
*
*
* @author Loki
*/
public class BloodthirstAbility extends EntersBattlefieldAbility {
private int amount;
public BloodthirstAbility(int amount) {
@ -48,12 +50,13 @@ public class BloodthirstAbility extends EntersBattlefieldAbility {
}
class BloodthirstEffect extends OneShotEffect {
private final int amount;
BloodthirstEffect(int amount) {
super(Outcome.BoostCreature);
this.amount = amount;
staticText = new StringBuilder("this permanent comes into play with ").append(this.amount).append(" +1/+1 counters on it").toString();
staticText = new StringBuilder("this permanent comes into play with ").append(this.amount).append(" +1/+1 counters on it").toString();
}
BloodthirstEffect(final BloodthirstEffect effect) {
@ -67,9 +70,9 @@ class BloodthirstEffect extends OneShotEffect {
if (player != null) {
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId());
if (watcher != null && watcher.conditionMet()) {
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
p.addCounters(CounterType.P1P1.createInstance(amount), game);
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}
}
@ -83,4 +86,3 @@ class BloodthirstEffect extends OneShotEffect {
return new BloodthirstEffect(this);
}
}

View file

@ -3,6 +3,7 @@ package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.Card;
@ -18,25 +19,17 @@ import mage.game.permanent.Permanent;
* 702.31a Fading is a keyword that represents two abilities. Fading N means This permanent enters the battlefield with N fade counters on it and At the beginning of your upkeep, remove a fade counter from this permanent. If you cant, sacrifice the permanent.
*
*/
public class FadingAbility extends EntersBattlefieldAbility {
private String ruleText;
public FadingAbility(int fadeCounter, Card card) {
super(new AddCountersSourceEffect(CounterType.FADE.createInstance(fadeCounter)), "with");
Ability ability = new BeginningOfUpkeepTriggeredAbility(new FadingEffect(), TargetController.YOU, false);
ability.setRuleVisible(false);
addSubAbility(ability);
StringBuilder sb = new StringBuilder("Fading ");
sb.append(fadeCounter);
sb.append(" <i>(This permanent enters the battlefield with ")
.append(fadeCounter)
.append(" fade counters on it. ")
.append(" At the beginning of your upkeep, remove a fade counter from this permanent. If you cant, sacrifice the permanent.")
.append(")</i>");
ruleText = sb.toString();
ruleText = "Fading " + fadeCounter + " <i>(This permanent enters the battlefield with " + fadeCounter + " fade counters on it."
+ " At the beginning of your upkeep, remove a fade counter from this permanent. If you cant, sacrifice the permanent.</i>";
}
public FadingAbility(final FadingAbility ability) {
@ -54,7 +47,9 @@ public class FadingAbility extends EntersBattlefieldAbility {
return ruleText;
}
}
class FadingEffect extends OneShotEffect {
FadingEffect() {
super(Outcome.Sacrifice);
staticText = "remove a fade counter from this permanent. If you cant, sacrifice the permanent";
@ -64,18 +59,15 @@ class FadingEffect extends OneShotEffect {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
int amount = p.getCounters().getCount(CounterType.FADE);
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (permanent != null) {
int amount = permanent.getCounters().getCount(CounterType.FADE);
if (amount > 0) {
p.removeCounters(CounterType.FADE.createInstance(), game);
}
else
{
p.sacrifice(source.getSourceId(), game);
permanent.removeCounters(CounterType.FADE.createInstance(), game);
} else {
permanent.sacrifice(source.getSourceId(), game);
}
return true;
}
@ -86,4 +78,4 @@ class FadingEffect extends OneShotEffect {
public FadingEffect copy() {
return new FadingEffect(this);
}
}
}

View file

@ -25,13 +25,13 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.SunburstCount;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.CardType;
@ -46,25 +46,22 @@ import mage.players.Player;
*
* @author Plopman
*/
public class SunburstAbility extends EntersBattlefieldAbility {
public class SunburstAbility extends EntersBattlefieldAbility{
private final static String ruleCreature ="Sunburst <i>(This enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it.)</i>";
private final static String ruleNonCreature ="Sunburst <i>(This enters the battlefield with a charge counter on it for each color of mana spent to cast it.)</i>";
private final static String ruleCreature = "Sunburst <i>(This enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it.)</i>";
private final static String ruleNonCreature = "Sunburst <i>(This enters the battlefield with a charge counter on it for each color of mana spent to cast it.)</i>";
private boolean isCreature;
public SunburstAbility(Card card){
super(new SunburstEffect(),"");
public SunburstAbility(Card card) {
super(new SunburstEffect(), "");
isCreature = card.getCardType().contains(CardType.CREATURE);
}
public SunburstAbility(final SunburstAbility ability){
public SunburstAbility(final SunburstAbility ability) {
super(ability);
this.isCreature = ability.isCreature;
}
@Override
public EntersBattlefieldAbility copy() {
return new SunburstAbility(this);
@ -74,15 +71,13 @@ public class SunburstAbility extends EntersBattlefieldAbility{
public String getRule() {
return isCreature ? ruleCreature : ruleNonCreature;
}
}
class SunburstEffect extends OneShotEffect {
private static final DynamicValue amount = new SunburstCount();
public SunburstEffect() {
super(Outcome.Benefit);
staticText = "Sunburst";
@ -94,22 +89,21 @@ class SunburstEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (permanent != null) {
Counter counter;
if(permanent.getCardType().contains(CardType.CREATURE)){
counter = CounterType.P1P1.createInstance(amount.calculate(game, source, this));
}
else{
counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this));
if (permanent.getCardType().contains(CardType.CREATURE)) {
counter = CounterType.P1P1.createInstance(amount.calculate(game, source, this));
} else {
counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this));
}
if (counter != null) {
permanent.addCounters(counter, game);
if (!game.isSimulation()) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getLogName()+ " puts " + counter.getCount() + " " + counter.getName() + " counter on " + permanent.getName());
game.informPlayers(player.getLogName() + " puts " + counter.getCount() + " " + counter.getName() + " counter on " + permanent.getName());
}
}
}

View file

@ -25,12 +25,12 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.constants.Outcome;
@ -46,23 +46,20 @@ import mage.util.CardUtil;
*
* @author LevelX2
*/
public class TributeAbility extends EntersBattlefieldAbility{
public class TributeAbility extends EntersBattlefieldAbility {
private int tributeValue;
public TributeAbility(int tributeValue){
public TributeAbility(int tributeValue) {
super(new TributeEffect(tributeValue), false);
this.tributeValue = tributeValue;
}
public TributeAbility(final TributeAbility ability){
public TributeAbility(final TributeAbility ability) {
super(ability);
this.tributeValue = ability.tributeValue;
}
@Override
public EntersBattlefieldAbility copy() {
return new TributeAbility(this);
@ -81,7 +78,7 @@ public class TributeAbility extends EntersBattlefieldAbility{
class TributeEffect extends OneShotEffect {
private int tributeValue;
private final int tributeValue;
public TributeEffect(int tributeValue) {
super(Outcome.Detriment);
@ -101,7 +98,7 @@ class TributeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent sourcePermanent = (Permanent) getValue(EntersBattlefieldEffect.ENTERING_PERMANENT);
if (controller != null && sourcePermanent != null) {
UUID opponentId;
if (game.getOpponents(controller.getId()).size() == 1) {
@ -117,16 +114,18 @@ class TributeEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder("Pay tribute to ");
sb.append(sourcePermanent.getName());
sb.append(" (add ").append(CardUtil.numberToText(tributeValue)).append(" +1/+1 counter");
sb.append(tributeValue > 1 ? "s":"").append(" to it)?");
sb.append(tributeValue > 1 ? "s" : "").append(" to it)?");
if (opponent.chooseUse(outcome, sb.toString(), source, game)) {
if (!game.isSimulation())
if (!game.isSimulation()) {
game.informPlayers(opponent.getLogName() + " pays tribute to " + sourcePermanent.getLogName());
}
game.getState().setValue("tributeValue" + source.getSourceId(), "yes");
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(tributeValue), true).apply(game, source);
} else {
if (!game.isSimulation())
if (!game.isSimulation()) {
game.informPlayers(opponent.getLogName() + " does not pay tribute to " + sourcePermanent.getLogName());
game.getState().setValue("tributeValue"+ source.getSourceId(), "no");
}
game.getState().setValue("tributeValue" + source.getSourceId(), "no");
}
return true;
}