mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 05:09:16 -08:00
Added as thought effect to let creatures block tapped.
This commit is contained in:
parent
024a1fac9a
commit
4a28881f71
10 changed files with 194 additions and 52 deletions
|
|
@ -5,7 +5,7 @@ package mage.constants;
|
|||
* @author North
|
||||
*/
|
||||
public enum AsThoughEffectType {
|
||||
BLOCK,
|
||||
BLOCK_TAPPED,
|
||||
BE_BLOCKED,
|
||||
ATTACK,
|
||||
CAST,
|
||||
|
|
|
|||
|
|
@ -28,19 +28,15 @@
|
|||
|
||||
package mage.filter.common;
|
||||
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author North
|
||||
*/
|
||||
public class FilterCreatureForCombat extends FilterCreaturePermanent {
|
||||
public class FilterCreatureForCombat extends FilterCreatureForCombatBase {
|
||||
|
||||
public FilterCreatureForCombat() {
|
||||
this("");
|
||||
|
|
@ -48,10 +44,7 @@ public class FilterCreatureForCombat extends FilterCreaturePermanent {
|
|||
|
||||
public FilterCreatureForCombat(String name) {
|
||||
super(name);
|
||||
this.add(Predicates.not(new AttackingPredicate()));
|
||||
this.add(Predicates.not(new TappedPredicate()));
|
||||
this.add(new PhasedInPredicate());
|
||||
this.add(new CanBlockPredicate());
|
||||
}
|
||||
|
||||
public FilterCreatureForCombat(final FilterCreatureForCombat filter) {
|
||||
|
|
@ -63,29 +56,3 @@ public class FilterCreatureForCombat extends FilterCreaturePermanent {
|
|||
return new FilterCreatureForCombat(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhasedInPredicate implements Predicate<Permanent> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return input.isPhasedIn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PhasedIn";
|
||||
}
|
||||
}
|
||||
|
||||
class CanBlockPredicate implements Predicate<Permanent> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return input.getMaxBlocks() == 0 || input.getBlocking() < input.getMaxBlocks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CanBlock";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
91
Mage/src/mage/filter/common/FilterCreatureForCombatBase.java
Normal file
91
Mage/src/mage/filter/common/FilterCreatureForCombatBase.java
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.filter.common;
|
||||
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author North
|
||||
*/
|
||||
public class FilterCreatureForCombatBase extends FilterCreaturePermanent {
|
||||
|
||||
public FilterCreatureForCombatBase() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public FilterCreatureForCombatBase(String name) {
|
||||
super(name);
|
||||
this.add(Predicates.not(new AttackingPredicate()));
|
||||
this.add(new PhasedInPredicate());
|
||||
this.add(new CanBlockPredicate());
|
||||
}
|
||||
|
||||
public FilterCreatureForCombatBase(final FilterCreatureForCombatBase filter) {
|
||||
super(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterCreatureForCombatBase copy() {
|
||||
return new FilterCreatureForCombatBase(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhasedInPredicate implements Predicate<Permanent> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return input.isPhasedIn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PhasedIn";
|
||||
}
|
||||
}
|
||||
|
||||
class CanBlockPredicate implements Predicate<Permanent> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return input.getMaxBlocks() == 0 || input.getBlocking() < input.getMaxBlocks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CanBlock";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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.filter.common;
|
||||
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class FilterCreatureForCombatBlock extends FilterCreatureForCombatBase {
|
||||
|
||||
public FilterCreatureForCombatBlock() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public FilterCreatureForCombatBlock(String name) {
|
||||
super(name);
|
||||
this.add(new BlockTappedPredicate());
|
||||
}
|
||||
|
||||
public FilterCreatureForCombatBlock(final FilterCreatureForCombatBlock filter) {
|
||||
super(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterCreatureForCombatBlock copy() {
|
||||
return new FilterCreatureForCombatBlock(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BlockTappedPredicate implements Predicate<Permanent> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return !input.isTapped() || game.getState().getContinuousEffects().asThough(input.getId(), AsThoughEffectType.BLOCK_TAPPED, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "untapped or can block tapped";
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ import mage.abilities.keyword.CanAttackOnlyAloneAbility;
|
|||
import mage.abilities.keyword.CantAttackAloneAbility;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterCreatureForCombat;
|
||||
import mage.filter.common.FilterCreatureForCombatBlock;
|
||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -55,7 +55,7 @@ import mage.util.trace.TraceUtil;
|
|||
public class Combat implements Serializable, Copyable<Combat> {
|
||||
|
||||
private static FilterPlaneswalkerPermanent filterPlaneswalker = new FilterPlaneswalkerPermanent();
|
||||
private static FilterCreatureForCombat filterBlockers = new FilterCreatureForCombat();
|
||||
private static FilterCreatureForCombatBlock filterBlockers = new FilterCreatureForCombatBlock();
|
||||
|
||||
protected List<CombatGroup> groups = new ArrayList<CombatGroup>();
|
||||
protected Map<UUID, CombatGroup> blockingGroups = new HashMap<UUID, CombatGroup>();
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
|
||||
@Override
|
||||
public boolean canBlock(UUID attackerId, Game game) {
|
||||
if (tapped) {
|
||||
if (tapped && !game.getState().getContinuousEffects().asThough(this.getId(), AsThoughEffectType.BLOCK_TAPPED, game)) {
|
||||
return false;
|
||||
}
|
||||
Permanent attacker = game.getPermanent(attackerId);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ import mage.counters.CounterType;
|
|||
import mage.counters.Counters;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterCreatureForCombat;
|
||||
import mage.filter.common.FilterCreatureForCombatBlock;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
|
@ -1468,7 +1469,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
|
||||
@Override
|
||||
public List<Permanent> getAvailableBlockers(Game game) {
|
||||
FilterCreatureForCombat blockFilter = new FilterCreatureForCombat();
|
||||
FilterCreatureForCombatBlock blockFilter = new FilterCreatureForCombatBlock();
|
||||
List<Permanent> blockers = game.getBattlefield().getAllActivePermanents(blockFilter, playerId, game);
|
||||
return blockers;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue