mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Added Standard Bearer, Coalition Flag and Coalition Honor Guard.
This commit is contained in:
parent
a766cafac6
commit
1674e00e70
8 changed files with 727 additions and 461 deletions
|
|
@ -47,7 +47,7 @@ public abstract class ContinuousRuleModifyingEffectImpl extends ContinuousEffect
|
|||
|
||||
// 613.10
|
||||
// Some continuous effects affect game rules rather than objects. For example, effects may modify
|
||||
// a players maximum hand size, or say that a creature must attack this turn if able. These effects
|
||||
// a player's maximum hand size, or say that a creature must attack this turn if able. These effects
|
||||
// are applied after all other continuous effects have been applied. Continuous effects that affect
|
||||
// the costs of spells or abilities are applied according to the order specified in rule 601.2e.
|
||||
// All other such effects are applied in timestamp order. See also the rules for timestamp order
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* 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.ruleModifying;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
|
||||
/**
|
||||
* 6/8/2016 If a spell or ability’s targets are changed, or if a copy of a spell
|
||||
* or ability is put onto the stack and has new targets chosen, it doesn’t have
|
||||
* to target a Flagbearer.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class TargetsHaveToTargetPermanentIfAbleEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public TargetsHaveToTargetPermanentIfAbleEffect(FilterPermanent filter) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||
this.filter = filter;
|
||||
staticText = "While choosing targets as part of casting a spell or activating an ability, your opponents must choose at least " + this.filter.getMessage() + " on the battlefield if able";
|
||||
|
||||
}
|
||||
|
||||
public TargetsHaveToTargetPermanentIfAbleEffect(final TargetsHaveToTargetPermanentIfAbleEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetsHaveToTargetPermanentIfAbleEffect copy() {
|
||||
return new TargetsHaveToTargetPermanentIfAbleEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.TARGETS_VALID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessage(Ability source, GameEvent event, Game game) {
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (mageObject != null) {
|
||||
return "You must choose at least " + this.filter.getMessage() + " on the battlefield as target if able (" + mageObject.getIdName() + ").";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null
|
||||
&& controller.isHuman() // TODO: This target handling does only work for non AI players so AI logic
|
||||
&& controller.hasOpponent(event.getPlayerId(), game)) {
|
||||
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
|
||||
if (stackObject.isCopy()) {
|
||||
return false;
|
||||
}
|
||||
Ability ability = (Ability) getValue("targetAbility");
|
||||
if (ability != null) {
|
||||
// Get all the allowed permanents on the battlefield in range of the abilities controller
|
||||
List<Permanent> allowedPermanents = game.getBattlefield().getActivePermanents(filter, event.getPlayerId(), event.getSourceId(), game);
|
||||
if (!allowedPermanents.isEmpty()) {
|
||||
boolean canTargetAllowedPermanent = false;
|
||||
for (UUID modeId : ability.getModes().getSelectedModes()) {
|
||||
ability.getModes().setActiveMode(modeId);
|
||||
for (Target target : ability.getTargets()) {
|
||||
// Check if already targeted
|
||||
for (Permanent allowedPermanent : allowedPermanents) {
|
||||
if (target.getTargets().contains(allowedPermanent.getId())) {
|
||||
return false;
|
||||
}
|
||||
if (target.canTarget(allowedPermanent.getId(), source, game)) {
|
||||
canTargetAllowedPermanent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return canTargetAllowedPermanent;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -171,6 +171,13 @@ public class GameEvent implements Serializable {
|
|||
MANA_PAYED,
|
||||
LOSES, LOST, WINS,
|
||||
TARGET, TARGETED,
|
||||
/* TARGETS_VALID
|
||||
targetId id of the spell or id of stack ability the targets were set to
|
||||
sourceId = targetId
|
||||
playerId controller of the spell or stack ability
|
||||
amount not used for this event
|
||||
*/
|
||||
TARGETS_VALID,
|
||||
/* COUNTER
|
||||
targetId id of the spell or id of stack ability
|
||||
sourceId sourceId of the ability countering the spell or stack ability
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -106,6 +107,11 @@ public class Targets extends ArrayList<Target> {
|
|||
if (!target.chooseTarget(outcome, targetController, source, game)) {
|
||||
return false;
|
||||
}
|
||||
// Check if there are some rules for targets are violated, if so reset the targets and start again
|
||||
if (this.getUnchosen().isEmpty()
|
||||
&& game.replaceEvent(new GameEvent(GameEvent.EventType.TARGETS_VALID, source.getSourceId(), source.getSourceId(), source.getControllerId()), source)) {
|
||||
this.clearChosen();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue