mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
C17 Added Portal Mage.
This commit is contained in:
parent
a50e44ad3f
commit
e909f5c801
12 changed files with 214 additions and 29 deletions
|
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamageEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -48,8 +48,6 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
|
||||
|
||||
private static FilterPlaneswalkerPermanent filter = new FilterPlaneswalkerPermanent();
|
||||
|
||||
public PlaneswalkerRedirectionEffect() {
|
||||
super(Duration.EndOfGame);
|
||||
}
|
||||
|
|
@ -76,11 +74,11 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
|
|||
Player target = game.getPlayer(event.getTargetId());
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (target != null && player != null) {
|
||||
int numPlaneswalkers = game.getBattlefield().countAll(filter, target.getId(), game);
|
||||
int numPlaneswalkers = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_PLANESWALKER, target.getId(), game);
|
||||
if (numPlaneswalkers > 0 && player.chooseUse(outcome, "Redirect damage to planeswalker?", source, game)) {
|
||||
redirectTarget = new TargetPermanent(filter);
|
||||
redirectTarget = new TargetPermanent(StaticFilters.FILTER_PERMANENT_PLANESWALKER);
|
||||
if (numPlaneswalkers == 1) {
|
||||
List<Permanent> planeswalker = game.getBattlefield().getAllActivePermanents(filter, target.getId(), game);
|
||||
List<Permanent> planeswalker = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, target.getId(), game);
|
||||
if (!planeswalker.isEmpty()) {
|
||||
redirectTarget.add(planeswalker.get(0).getId(), game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public final class StaticFilters {
|
|||
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURES = new FilterCreaturePermanent("creatures");
|
||||
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURE_GOBLINS = new FilterCreaturePermanent(SubType.GOBLIN, "Goblin creatures");
|
||||
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURE_SLIVERS = new FilterCreaturePermanent(SubType.SLIVER, "Sliver creatures");
|
||||
public static final FilterPlaneswalkerPermanent FILTER_PERMANENT_PLANESWALKER = new FilterPlaneswalkerPermanent();
|
||||
|
||||
public static final FilterPermanent FILTER_PERMANENT_NON_LAND = new FilterNonlandPermanent();
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import mage.filter.StaticFilters;
|
|||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterCreatureForCombatBlock;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
|
@ -60,7 +59,6 @@ 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
|
||||
private boolean useToughnessForDamage;
|
||||
|
|
@ -1026,6 +1024,13 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
|
||||
public void setDefenders(Game game) {
|
||||
for (UUID playerId : getAttackablePlayers(game)) {
|
||||
addDefender(playerId, game);
|
||||
}
|
||||
}
|
||||
|
||||
public List<UUID> getAttackablePlayers(Game game) {
|
||||
List<UUID> attackablePlayers = new ArrayList<>();
|
||||
Player attackingPlayer = game.getPlayer(attackingPlayerId);
|
||||
if (attackingPlayer != null) {
|
||||
PlayerList players;
|
||||
|
|
@ -1035,7 +1040,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
while (attackingPlayer.isInGame()) {
|
||||
Player opponent = players.getNext(game);
|
||||
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
|
||||
addDefender(opponent.getId(), game);
|
||||
attackablePlayers.add(opponent.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1045,18 +1050,19 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
while (attackingPlayer.isInGame()) {
|
||||
Player opponent = players.getPrevious(game);
|
||||
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
|
||||
addDefender(opponent.getId(), game);
|
||||
attackablePlayers.add(opponent.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MULTIPLE:
|
||||
for (UUID opponentId : game.getOpponents(attackingPlayerId)) {
|
||||
addDefender(opponentId, game);
|
||||
attackablePlayers.add(opponentId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return attackablePlayers;
|
||||
}
|
||||
|
||||
private void addDefender(UUID defenderId, Game game) {
|
||||
|
|
@ -1074,7 +1080,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
}
|
||||
defenders.add(defenderId);
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filterPlaneswalker, defenderId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, defenderId, game)) {
|
||||
defenders.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -655,4 +655,23 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
public CombatGroup copy() {
|
||||
return new CombatGroup(this);
|
||||
}
|
||||
|
||||
public boolean changeDefenderPostDeclaration(UUID newDefenderId, Game game) {
|
||||
Permanent permanent = game.getPermanent(newDefenderId);
|
||||
if (permanent != null) {
|
||||
defenderId = newDefenderId;
|
||||
defendingPlayerId = permanent.getControllerId();
|
||||
defenderIsPlaneswalker = true;
|
||||
return true;
|
||||
} else {
|
||||
Player defender = game.getPlayer(newDefenderId);
|
||||
if (defender != null) {
|
||||
defenderId = newDefenderId;
|
||||
defendingPlayerId = newDefenderId;
|
||||
defenderIsPlaneswalker = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ import mage.MageObject;
|
|||
import mage.abilities.Ability;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterPlaneswalkerOrPlayer;
|
||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -93,7 +93,7 @@ public class TargetDefender extends TargetImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
|
||||
if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
|
||||
&& filter.match(permanent, game)) {
|
||||
count++;
|
||||
|
|
@ -117,7 +117,7 @@ public class TargetDefender extends TargetImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
|
||||
if (filter.match(permanent, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
|
|
@ -140,7 +140,7 @@ public class TargetDefender extends TargetImpl {
|
|||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
|
||||
if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
|
||||
&& filter.match(permanent, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
|
|
@ -158,7 +158,7 @@ public class TargetDefender extends TargetImpl {
|
|||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
|
||||
if (filter.match(permanent, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue