mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Merge origin/master
This commit is contained in:
commit
692fe8046e
102 changed files with 895 additions and 750 deletions
|
|
@ -69,6 +69,10 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.Set;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -39,8 +40,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
|
|
@ -48,7 +47,7 @@ public class CastCardFromOutsideTheGameEffect extends OneShotEffect {
|
|||
|
||||
private static final String choiceText = "Cast a card from outside the game?";
|
||||
|
||||
private FilterCard filterCard;
|
||||
private final FilterCard filterCard;
|
||||
|
||||
public CastCardFromOutsideTheGameEffect(FilterCard filter, String ruleText) {
|
||||
super(Outcome.Benefit);
|
||||
|
|
@ -76,15 +75,17 @@ public class CastCardFromOutsideTheGameEffect extends OneShotEffect {
|
|||
while (player.chooseUse(Outcome.Benefit, choiceText, source, game)) {
|
||||
Cards cards = player.getSideboard();
|
||||
if (cards.isEmpty()) {
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayer(player, "You have no cards outside the game.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<Card> filtered = cards.getCards(filterCard, source.getSourceId(), source.getControllerId(), game);
|
||||
if (filtered.isEmpty()) {
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayer(player, "You have no " + filterCard.getMessage() + " outside the game.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +94,7 @@ public class CastCardFromOutsideTheGameEffect extends OneShotEffect {
|
|||
filteredCards.add(card.getId());
|
||||
}
|
||||
|
||||
TargetCard target = new TargetCard(Zone.PICK, filterCard);
|
||||
TargetCard target = new TargetCard(Zone.OUTSIDE, filterCard);
|
||||
if (player.choose(Outcome.Benefit, filteredCards, target, game)) {
|
||||
Card card = player.getSideboard().get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CanAttackOnlyAloneEffect extends RestrictionEffect {
|
||||
|
||||
public CanAttackOnlyAloneEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "{this} can only attack alone";
|
||||
}
|
||||
|
||||
public CanAttackOnlyAloneEffect(final CanAttackOnlyAloneEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CanAttackOnlyAloneEffect copy() {
|
||||
return new CanAttackOnlyAloneEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) {
|
||||
return numberOfAttackers == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return source.getSourceId().equals(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantAttackAloneEffect extends RestrictionEffect {
|
||||
|
||||
public CantAttackAloneEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "{this} can't attack alone";
|
||||
}
|
||||
|
||||
public CantAttackAloneEffect(final CantAttackAloneEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantAttackAloneEffect copy() {
|
||||
return new CantAttackAloneEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) {
|
||||
return numberOfAttackers > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return source.getSourceId().equals(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,11 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
public GainAbilityTargetEffect(Ability ability, Duration duration, String rule, boolean onCard) {
|
||||
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA,
|
||||
this(ability, duration, rule, onCard, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA);
|
||||
}
|
||||
|
||||
public GainAbilityTargetEffect(Ability ability, Duration duration, String rule, boolean onCard, Layer layer, SubLayer subLayer) {
|
||||
super(duration, layer, subLayer,
|
||||
ability.getEffects().size() > 0 ? ability.getEffects().get(0).getOutcome() : Outcome.AddAbility);
|
||||
this.ability = ability;
|
||||
staticText = rule;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff
|
|||
applied = Boolean.FALSE;
|
||||
}
|
||||
if (!applied && layer.equals(Layer.RulesEffects)) {
|
||||
if (!game.getActivePlayerId().equals(source.getControllerId()) && game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
if (!source.getControllerId().equals(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", true);
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
boolean untap = true;
|
||||
|
|
|
|||
|
|
@ -1,65 +1,52 @@
|
|||
/*
|
||||
* 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.keyword;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.combat.CanAttackOnlyAloneEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.StaticAbility;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CanAttackOnlyAloneAbility extends StaticAbility implements MageSingleton {
|
||||
public class CanAttackOnlyAloneAbility extends SimpleStaticAbility {
|
||||
|
||||
private static final CanAttackOnlyAloneAbility fINSTANCE = new CanAttackOnlyAloneAbility();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return fINSTANCE;
|
||||
public CanAttackOnlyAloneAbility() {
|
||||
super(Zone.BATTLEFIELD, new CanAttackOnlyAloneEffect());
|
||||
}
|
||||
|
||||
public static CanAttackOnlyAloneAbility getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private CanAttackOnlyAloneAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "{this} can only attack alone.";
|
||||
private CanAttackOnlyAloneAbility(CanAttackOnlyAloneAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CanAttackOnlyAloneAbility copy() {
|
||||
return fINSTANCE;
|
||||
return new CanAttackOnlyAloneAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,66 +1,52 @@
|
|||
/*
|
||||
* 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.keyword;
|
||||
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.combat.CantAttackAloneEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.StaticAbility;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_googlemail.com
|
||||
*/
|
||||
public class CantAttackAloneAbility extends StaticAbility implements MageSingleton {
|
||||
public class CantAttackAloneAbility extends SimpleStaticAbility {
|
||||
|
||||
private static final CantAttackAloneAbility fINSTANCE = new CantAttackAloneAbility();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return fINSTANCE;
|
||||
public CantAttackAloneAbility() {
|
||||
super(Zone.BATTLEFIELD, new CantAttackAloneEffect());
|
||||
}
|
||||
|
||||
public static CantAttackAloneAbility getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
private CantAttackAloneAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "{this} can't attack alone.";
|
||||
private CantAttackAloneAbility(CantAttackAloneAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantAttackAloneAbility copy() {
|
||||
return fINSTANCE;
|
||||
return new CantAttackAloneAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -546,8 +546,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
removed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case PICK: // Pick should no longer be used
|
||||
case BATTLEFIELD: // for sacrificing permanents or putting to library
|
||||
removed = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.cards.decks;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -40,8 +39,8 @@ public class DeckCardLists implements Serializable {
|
|||
|
||||
private String name;
|
||||
private String author;
|
||||
private List<DeckCardInfo> cards = new ArrayList<DeckCardInfo>();
|
||||
private List<DeckCardInfo> sideboard = new ArrayList<DeckCardInfo>();
|
||||
private List<DeckCardInfo> cards = new ArrayList<>();
|
||||
private List<DeckCardInfo> sideboard = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @return the cards
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package mage.constants;
|
|||
*/
|
||||
public enum Zone {
|
||||
|
||||
HAND, GRAVEYARD, LIBRARY, BATTLEFIELD, STACK, EXILED, ALL, OUTSIDE, PICK, COMMAND;
|
||||
HAND, GRAVEYARD, LIBRARY, BATTLEFIELD, STACK, EXILED, ALL, OUTSIDE, COMMAND;
|
||||
|
||||
public boolean match(Zone zone) {
|
||||
return (this == zone || this == ALL || zone == ALL);
|
||||
|
|
|
|||
|
|
@ -36,11 +36,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RequirementEffect;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.keyword.CanAttackOnlyAloneAbility;
|
||||
import mage.abilities.keyword.CantAttackAloneAbility;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
|
|
@ -58,12 +57,15 @@ import mage.target.common.TargetDefender;
|
|||
import mage.util.CardUtil;
|
||||
import mage.util.Copyable;
|
||||
import mage.util.trace.TraceUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Combat implements Serializable, Copyable<Combat> {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Combat.class);
|
||||
|
||||
private static FilterPlaneswalkerPermanent filterPlaneswalker = new FilterPlaneswalkerPermanent();
|
||||
private static FilterCreatureForCombatBlock filterBlockers = new FilterCreatureForCombatBlock();
|
||||
// There are effects that let creatures assigns combat damage equal to its toughness rather than its power
|
||||
|
|
@ -252,14 +254,18 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
Player player = game.getPlayer(attackerId);
|
||||
//20101001 - 508.1d
|
||||
game.getCombat().checkAttackRequirements(player, game);
|
||||
if (!game.getPlayer(game.getActivePlayerId()).getAvailableAttackers(game).isEmpty()) {
|
||||
player.selectAttackers(game, attackerId);
|
||||
}
|
||||
if (game.isPaused() || game.gameOver(null) || game.executingRollback()) {
|
||||
return;
|
||||
}
|
||||
// because of possible undo during declare attackers it's neccassary to call here the methods with "game.getCombat()." to get the valid combat object!!!
|
||||
game.getCombat().checkAttackRestrictions(player, game);
|
||||
boolean firstTime = true;
|
||||
do {
|
||||
if (!firstTime || !game.getPlayer(game.getActivePlayerId()).getAvailableAttackers(game).isEmpty()) {
|
||||
player.selectAttackers(game, attackerId);
|
||||
}
|
||||
firstTime = false;
|
||||
if (game.isPaused() || game.gameOver(null) || game.executingRollback()) {
|
||||
return;
|
||||
}
|
||||
// because of possible undo during declare attackers it's neccassary to call here the methods with "game.getCombat()." to get the current combat object!!!
|
||||
// I don't like it too - it has to be redesigned
|
||||
} while (!game.getCombat().checkAttackRestrictions(player, game));
|
||||
game.getCombat().resumeSelectAttackers(game);
|
||||
}
|
||||
}
|
||||
|
|
@ -337,50 +343,60 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
}
|
||||
|
||||
protected void checkAttackRestrictions(Player player, Game game) {
|
||||
int count = 0;
|
||||
for (CombatGroup group : groups) {
|
||||
count += group.getAttackers().size();
|
||||
}
|
||||
|
||||
if (count > 1) {
|
||||
List<UUID> tobeRemoved = new ArrayList<>();
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @param game
|
||||
* @return true if the attack with that set of creatures and attacked
|
||||
* players/planeswalkers is possible
|
||||
*/
|
||||
protected boolean checkAttackRestrictions(Player player, Game game) {
|
||||
boolean check = true;
|
||||
int numberOfChecks = 0;
|
||||
UUID attackerToRemove = null;
|
||||
Check:
|
||||
while (check) {
|
||||
check = false;
|
||||
numberOfChecks++;
|
||||
int numberAttackers = 0;
|
||||
for (CombatGroup group : groups) {
|
||||
for (UUID attackingCreatureId : group.getAttackers()) {
|
||||
Permanent attacker = game.getPermanent(attackingCreatureId);
|
||||
if (count > 1 && attacker != null && attacker.getAbilities().containsKey(CanAttackOnlyAloneAbility.getInstance().getId())) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(attacker.getLogName() + " can only attack alone. Removing it from combat.");
|
||||
numberAttackers += group.getAttackers().size();
|
||||
}
|
||||
Player attackingPlayer = game.getPlayer(attackerId);
|
||||
if (attackerToRemove != null) {
|
||||
removeAttacker(attackerToRemove, game);
|
||||
}
|
||||
for (UUID attackingCreatureId : this.getAttackers()) {
|
||||
Permanent attackingCreature = game.getPermanent(attackingCreatureId);
|
||||
for (Map.Entry<RestrictionEffect, HashSet<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) {
|
||||
RestrictionEffect effect = entry.getKey();
|
||||
for (Ability ability : entry.getValue()) {
|
||||
if (!effect.canAttackCheckAfter(numberAttackers, ability, game)) {
|
||||
MageObject sourceObject = ability.getSourceObject(game);
|
||||
if (attackingPlayer.isHuman()) {
|
||||
game.informPlayer(attackingPlayer, attackingCreature.getIdName() + " can't attack this way (" + (sourceObject == null ? "null" : sourceObject.getIdName()) + ")");
|
||||
return false;
|
||||
} else {
|
||||
// remove attacking creatures for AI that are not allowed to attack
|
||||
// can create possible not allowed attack scenarios, but not sure how to solve this
|
||||
for (CombatGroup combatGroup : this.getGroups()) {
|
||||
if (combatGroup.getAttackers().contains(attackingCreatureId)) {
|
||||
attackerToRemove = attackingCreatureId;
|
||||
}
|
||||
}
|
||||
check = true; // do the check again
|
||||
if (numberOfChecks > 50) {
|
||||
logger.error("Seems to be an AI declare attacker lock (reached 50 check iterations) " + (sourceObject == null ? "null" : sourceObject.getIdName()));
|
||||
return true; // break the check
|
||||
}
|
||||
continue Check;
|
||||
}
|
||||
}
|
||||
tobeRemoved.add(attackingCreatureId);
|
||||
count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (UUID attackingCreatureId : tobeRemoved) {
|
||||
this.removeAttacker(attackingCreatureId, game);
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
List<UUID> tobeRemoved = new ArrayList<>();
|
||||
for (CombatGroup group : groups) {
|
||||
for (UUID attackingCreatureId : group.getAttackers()) {
|
||||
Permanent attacker = game.getPermanent(attackingCreatureId);
|
||||
if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(attacker.getLogName() + " can't attack alone. Removing it from combat.");
|
||||
}
|
||||
tobeRemoved.add(attackingCreatureId);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (UUID attackingCreatureId : tobeRemoved) {
|
||||
this.removeAttacker(attackingCreatureId, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void selectBlockers(Game game) {
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
moveObjectToLibrary(objectId, source == null ? null : source.getSourceId(), game, false, false);
|
||||
}
|
||||
} else {
|
||||
TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library (last one chosen will be bottommost)"));
|
||||
TargetCard target = new TargetCard(Zone.ALL, new FilterCard("card to put on the bottom of your library (last one chosen will be bottommost)"));
|
||||
target.setRequired(true);
|
||||
while (isInGame() && cards.size() > 1) {
|
||||
this.choose(Outcome.Neutral, cards, target, game);
|
||||
|
|
@ -3344,11 +3344,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
StringBuilder sb = new StringBuilder(this.getLogName())
|
||||
.append(" puts ").append(withName ? card.getLogName() : "a card").append(" ");
|
||||
if (fromZone != null) {
|
||||
if (fromZone.equals(Zone.PICK)) {
|
||||
sb.append("a picked card ");
|
||||
} else {
|
||||
sb.append("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ");
|
||||
}
|
||||
sb.append("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ");
|
||||
}
|
||||
sb.append("to the ").append(toTop ? "top" : "bottom");
|
||||
if (card.getOwnerId().equals(getId())) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue