diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 178b626e4f2..d8883719919 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -411,10 +411,13 @@ public class ComputerPlayer> extends PlayerImpl i for (Permanent permanent: targets) { if (((TargetControlledPermanent)target).canTarget(playerId, permanent.getId(), source, game)) { target.addTarget(permanent.getId(), source, game); - return true; + if (target.getNumberOfTargets() <= target.getTargets().size() && (!outcome.isGood() || target.getMaxNumberOfTargets() <= target.getTargets().size())) { + return true; + } } } - return false; + return target.isChosen(); + } if (target instanceof TargetPermanent) { List targets; diff --git a/Mage/src/mage/abilities/common/DealsCombatDamageTriggeredAbility.java b/Mage/src/mage/abilities/common/DealsCombatDamageTriggeredAbility.java new file mode 100644 index 00000000000..45ceb826448 --- /dev/null +++ b/Mage/src/mage/abilities/common/DealsCombatDamageTriggeredAbility.java @@ -0,0 +1,89 @@ +/* + * 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.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.DamagedCreatureEvent; +import mage.game.events.GameEvent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX + */ +public class DealsCombatDamageTriggeredAbility extends TriggeredAbilityImpl { + + private boolean setTargetPointer; + + public DealsCombatDamageTriggeredAbility(Effect effect, boolean optional) { + this(effect, optional, false); + } + + public DealsCombatDamageTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) { + super(Zone.BATTLEFIELD, effect, optional); + this.setTargetPointer = setTargetPointer; + } + + public DealsCombatDamageTriggeredAbility(final DealsCombatDamageTriggeredAbility ability) { + super(ability); + this.setTargetPointer = ability.setTargetPointer; + } + + @Override + public DealsCombatDamageTriggeredAbility copy() { + return new DealsCombatDamageTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER || event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { + if (event.getSourceId().equals(this.sourceId) + && ((DamagedCreatureEvent) event).isCombatDamage()) { + if (setTargetPointer) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getTargetId())); + effect.setValue("damage", event.getAmount()); + } + } + return true; + } + + } + return false; + } + + @Override + public String getRule() { + return "Whenever {this} deals combat damage, " + super.getRule(); + } + +} diff --git a/Mage/src/mage/abilities/dynamicvalue/MultipliedValue.java b/Mage/src/mage/abilities/dynamicvalue/MultipliedValue.java new file mode 100644 index 00000000000..c9f4e80071d --- /dev/null +++ b/Mage/src/mage/abilities/dynamicvalue/MultipliedValue.java @@ -0,0 +1,78 @@ +/* + * 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.dynamicvalue; + +import mage.abilities.Ability; +import mage.game.Game; + +/** + * + * @author LevelX2 + */ + +public class MultipliedValue implements DynamicValue { + private DynamicValue value; + private int multplier; + + public MultipliedValue(DynamicValue value, int multiplier) { + this.value = value.copy(); + this.multplier = multiplier; + } + + MultipliedValue(final MultipliedValue dynamicValue) { + this.value = dynamicValue.value.copy(); + this.multplier = dynamicValue.multplier; + } + + @Override + public int calculate(Game game, Ability sourceAbility) { + return multplier * value.calculate(game, sourceAbility); + } + + @Override + public DynamicValue copy() { + return new MultipliedValue(this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (multplier == 2) { + sb.append("twice "); + } else { + sb.append(multplier).append(" * "); + } + return sb.append(value.toString()).toString(); + } + + @Override + public String getMessage() { + return value.getMessage(); + } +} diff --git a/Mage/src/mage/abilities/effects/common/DestroyAllEffect.java b/Mage/src/mage/abilities/effects/common/DestroyAllEffect.java index f260c120fe0..9f9815093f3 100644 --- a/Mage/src/mage/abilities/effects/common/DestroyAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/DestroyAllEffect.java @@ -47,10 +47,12 @@ public class DestroyAllEffect extends OneShotEffect { super(Outcome.DestroyPermanent); this.filter = filter; this.noRegen = noRegen; - if (noRegen) + if (noRegen) { staticText = "Destroy all " + filter.getMessage() + ". They can't be regenerated"; - else + } + else { staticText = "Destroy all " + filter.getMessage(); + } } public DestroyAllEffect(FilterPermanent filter) { diff --git a/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java b/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java index 6f29c0521b8..db018190465 100644 --- a/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java +++ b/Mage/src/mage/abilities/effects/common/DoIfCostPaid.java @@ -31,7 +31,7 @@ public class DoIfCostPaid extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getObject(source.getSourceId()); if (player != null && mageObject != null) { - String message = new StringBuilder("Pay ").append(cost.getText()).append(" and ").append(executingEffect.getText(source.getModes().getMode())).toString(); + String message = new StringBuilder(getCostText()).append(" and ").append(executingEffect.getText(source.getModes().getMode())).append("?").toString(); message = CardUtil.replaceSourceName(message, mageObject.getName()); if (player.chooseUse(executingEffect.getOutcome(), message, game)) { cost.clearPaid(); @@ -47,12 +47,16 @@ public class DoIfCostPaid extends OneShotEffect { @Override public String getText(Mode mode) { - StringBuilder sb = new StringBuilder("you may "); + return new StringBuilder("you may ").append(getCostText()).append(". If you do, ").append(executingEffect.getText(mode)).toString(); + } + + private String getCostText() { + StringBuilder sb = new StringBuilder(); String costText = cost.getText(); - if (costText.length() <7 || !costText.substring(0, 7).toLowerCase().equals("discard")) { + if (costText != null && !costText.toLowerCase().startsWith("discard") && !costText.toLowerCase().startsWith("sacrifice")) { sb.append("pay "); } - return sb.append(costText).append(". If you do, ").append(executingEffect.getText(mode)).toString(); + return sb.append(costText).toString(); } @Override diff --git a/Mage/src/mage/util/CardUtil.java b/Mage/src/mage/util/CardUtil.java index 1ca34d3f51f..69b4db97151 100644 --- a/Mage/src/mage/util/CardUtil.java +++ b/Mage/src/mage/util/CardUtil.java @@ -371,10 +371,9 @@ public class CardUtil { /** * Creates and saves a (card + zoneChangeCounter) specific exileId. * - * - * @param game - * @param source - source ability - * @return - the specific UUID + * @param game the current game + * @param source source ability + * @return the specific UUID */ public static UUID getCardExileZoneId(Game game, Ability source) { String key = getCardZoneString("SourceExileZone", source.getSourceId(), game); @@ -391,9 +390,9 @@ public class CardUtil { * This string can be used to save and get values that must be specific to a permanent instance. * So they won't match, if a permanent was e.g. exiled and came back immediately. * - * @param text - * @param cardId - * @param game + * @param text short value to describe the value + * @param cardId id of the card + * @param game the game * @return */ public static String getCardZoneString(String text, UUID cardId, Game game) {