mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
* Duel Deck: Elspeth vs. Tezzeret - Added the missing cards. Added Zur the Enchanter.
This commit is contained in:
parent
ad2c062552
commit
b072ee9eaa
33 changed files with 1890 additions and 120 deletions
|
|
@ -156,7 +156,7 @@ public class AlternativeCostSourceAbility extends StaticAbility<AlternativeCostS
|
|||
sb.append(alternativeCost.getText(false));
|
||||
remarkText = alternativeCost.getReminderText();
|
||||
} else {
|
||||
sb.append(" and/or ").append(alternativeCost.getText(true));
|
||||
sb.append(" and ").append(alternativeCost.getText(true));
|
||||
}
|
||||
++numberCosts;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,6 @@ public class AttackingCreatureCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
return "X";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* 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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreatureOrPlayerAmount;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class PreventDamageTargetAmountEffect extends PreventionEffectImpl<PreventDamageTargetAmountEffect> {
|
||||
|
||||
private final int amount;
|
||||
private final Map<UUID, Integer> targetAmountMap = new HashMap<>();
|
||||
|
||||
public PreventDamageTargetAmountEffect(Duration duration, int amount) {
|
||||
super(duration);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public PreventDamageTargetAmountEffect(final PreventDamageTargetAmountEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreventDamageTargetAmountEffect copy() {
|
||||
return new PreventDamageTargetAmountEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
Target target = source.getTargets().get(0);
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (target instanceof TargetCreatureOrPlayerAmount && sourcePermanent != null) {
|
||||
TargetCreatureOrPlayerAmount multiTarget = (TargetCreatureOrPlayerAmount) target;
|
||||
for (UUID targetId: multiTarget.getTargets()) {
|
||||
Player player = null;
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
player = game.getPlayer(targetId);
|
||||
}
|
||||
targetAmountMap.put(targetId, multiTarget.getTargetAmount(targetId));
|
||||
StringBuilder sb = new StringBuilder(sourcePermanent.getName()).append(": Prevent the next ");
|
||||
sb.append(multiTarget.getTargetAmount(targetId)).append(" damage to ");
|
||||
if (player != null) {
|
||||
sb.append(player.getName());
|
||||
} else if (permanent != null) {
|
||||
sb.append(permanent.getName());
|
||||
}
|
||||
game.informPlayers(sb.toString());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
int targetAmount = targetAmountMap.get(event.getTargetId());
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
if (event.getAmount() >= targetAmount) {
|
||||
int damage = targetAmount;
|
||||
event.setAmount(event.getAmount() - targetAmount);
|
||||
targetAmountMap.remove(event.getTargetId());
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), damage));
|
||||
} else {
|
||||
int damage = event.getAmount();
|
||||
event.setAmount(0);
|
||||
targetAmountMap.put(event.getTargetId(), targetAmount -= damage);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), damage));
|
||||
}
|
||||
if (targetAmountMap.isEmpty()) {
|
||||
this.used = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!used && super.applies(event, source, game) && targetAmountMap.containsKey(event.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
// prevent the next 5 damage that would be dealt this turn to any number of target creatures and/or players, divided as you choose
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Prevent the next ").append(amount).append(" damage that would be dealt ");
|
||||
if (duration.equals(Duration.EndOfTurn)) {
|
||||
sb.append("this turn ");
|
||||
}
|
||||
sb.append("to any number of target creatures and/or players, divided as you choose");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
|
|
@ -36,6 +38,7 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -43,17 +46,23 @@ import mage.target.common.TargetControlledPermanent;
|
|||
*/
|
||||
public class ReturnToHandChosenControlledPermanentEffect extends OneShotEffect<ReturnToHandChosenControlledPermanentEffect> {
|
||||
|
||||
private FilterControlledPermanent filter;
|
||||
private final FilterControlledPermanent filter;
|
||||
private int number;
|
||||
|
||||
public ReturnToHandChosenControlledPermanentEffect(FilterControlledPermanent filter) {
|
||||
this(filter, 1);
|
||||
}
|
||||
public ReturnToHandChosenControlledPermanentEffect(FilterControlledPermanent filter, int number) {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.filter = filter;
|
||||
this.staticText = "return a " + filter.getMessage() + " to its owner's hand";
|
||||
this.number = number;
|
||||
this.staticText = getText();
|
||||
}
|
||||
|
||||
public ReturnToHandChosenControlledPermanentEffect(final ReturnToHandChosenControlledPermanentEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.number = effect.number;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -65,19 +74,30 @@ public class ReturnToHandChosenControlledPermanentEffect extends OneShotEffect<R
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(number, number, filter, true);
|
||||
target.setRequired(true);
|
||||
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
game.informPlayers(player.getName() + " returns " + permanent.getName() + " to his or her hand.");
|
||||
return permanent.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
for (UUID targetCreatureId : (List<UUID>)target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetCreatureId);
|
||||
if (permanent != null) {
|
||||
player.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private String getText() {
|
||||
StringBuilder sb = new StringBuilder("return ");
|
||||
sb.append(CardUtil.numberToText(number, "a"));
|
||||
sb.append(" ").append(filter.getMessage());
|
||||
if (number > 1) {
|
||||
sb.append(" to its owner's hand");
|
||||
} else {
|
||||
sb.append(" to their owner's hand");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,23 +4,30 @@ package mage.abilities.keyword;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.DiscardSourceCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
public class ReinforceAbility extends SimpleActivatedAbility {
|
||||
private int count;
|
||||
private DynamicValue count;
|
||||
private Cost cost;
|
||||
|
||||
public ReinforceAbility(int count, Cost cost) {
|
||||
super(Zone.HAND, new AddCountersTargetEffect(CounterType.P1P1.createInstance(count)), cost);
|
||||
this(new StaticValue(count), cost);
|
||||
}
|
||||
|
||||
public ReinforceAbility(DynamicValue count, Cost cost) {
|
||||
super(Zone.HAND, new AddCountersTargetEffect(CounterType.P1P1.createInstance(0), count), cost);
|
||||
this.addCost(new DiscardSourceCost());
|
||||
this.addTarget(new TargetCreaturePermanent());
|
||||
this.cost = cost.copy();
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
||||
public ReinforceAbility(final ReinforceAbility ability) {
|
||||
super(ability);
|
||||
this.cost = ability.cost.copy();
|
||||
|
|
@ -34,6 +41,11 @@ public class ReinforceAbility extends SimpleActivatedAbility {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Reinforce " + count + " - " + cost.getText();
|
||||
StringBuilder sb = new StringBuilder("Reinforce ");
|
||||
sb.append(count.toString()).append(" - ");
|
||||
sb.append(cost.getText());
|
||||
sb.append(" <i>(").append(cost.getText()).append("Discard this card: Put ");
|
||||
sb.append(count.toString()).append(" +1/+1 counters on target creature.");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public abstract class TargetAmount<T extends TargetAmount<T>> extends TargetImpl
|
|||
|
||||
@Override
|
||||
public List<T> getTargetOptions(Ability source, Game game) {
|
||||
List<T> options = new ArrayList<T>();
|
||||
List<T> options = new ArrayList<>();
|
||||
Set<UUID> possibleTargets = possibleTargets(source.getSourceId(), source.getControllerId(), game);
|
||||
|
||||
addTargets(this, possibleTargets, options, source, game);
|
||||
|
|
@ -146,7 +146,7 @@ public abstract class TargetAmount<T extends TargetAmount<T>> extends TargetImpl
|
|||
t.addTarget(targetId, n, source, game, true);
|
||||
if (t.remainingAmount > 0) {
|
||||
if (targets.size() > 1) {
|
||||
Set<UUID> newTargets = new HashSet<UUID>();
|
||||
Set<UUID> newTargets = new HashSet<>();
|
||||
for (UUID newTarget: targets) {
|
||||
if (!newTarget.equals(targetId)) {
|
||||
newTargets.add(newTarget);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
|
|
@ -182,7 +182,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue