mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
fixed Neyith of the Dire Hunt not working with cards that cause creatures to become blocked
This commit is contained in:
parent
e69a021c71
commit
509bd39244
10 changed files with 199 additions and 238 deletions
|
|
@ -0,0 +1,90 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class BecomeBlockedTargetEffect extends OneShotEffect {
|
||||
|
||||
public BecomeBlockedTargetEffect() {
|
||||
super(Outcome.Benefit);
|
||||
}
|
||||
|
||||
private BecomeBlockedTargetEffect(final BecomeBlockedTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomeBlockedTargetEffect copy() {
|
||||
return new BecomeBlockedTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Set<MageObjectReference> morSet = new HashSet<>();
|
||||
for (UUID targetId : targetPointer.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
continue;
|
||||
}
|
||||
CombatGroup combatGroup = game.getCombat().findGroup(permanent.getId());
|
||||
if (combatGroup == null) {
|
||||
continue;
|
||||
}
|
||||
boolean alreadyBlocked = combatGroup.getBlocked();
|
||||
combatGroup.setBlocked(true); // non-banded creatures
|
||||
combatGroup.setBlocked(true, game); // this only works for banded creatures and needs to be checked out
|
||||
if (alreadyBlocked) {
|
||||
continue;
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(
|
||||
GameEvent.EventType.CREATURE_BLOCKED, permanent.getId(),
|
||||
source.getSourceId(), null
|
||||
));
|
||||
morSet.add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
String key = UUID.randomUUID().toString();
|
||||
game.getState().setValue("becameBlocked_" + key, morSet);
|
||||
game.fireEvent(GameEvent.getEvent(
|
||||
GameEvent.EventType.BATCH_BLOCK_NONCOMBAT,
|
||||
source.getSourceId(), source.getSourceId(),
|
||||
source.getControllerId(), key, 0)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Target target = mode.getTargets().get(0);
|
||||
if (target.getNumberOfTargets() == 1) {
|
||||
String targetName = target.getTargetName();
|
||||
sb.append("target ").append(targetName).append(" becomes blocked");
|
||||
return sb.toString();
|
||||
}
|
||||
if (target.getMaxNumberOfTargets() != target.getMinNumberOfTargets()) {
|
||||
sb.append("up to ");
|
||||
}
|
||||
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets()));
|
||||
sb.append(" target ").append(target.getTargetName()).append(" become blocked");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -235,6 +235,7 @@ public class GameEvent implements Serializable {
|
|||
*/
|
||||
DECLARE_BLOCKER, BLOCKER_DECLARED,
|
||||
CREATURE_BLOCKED,
|
||||
BATCH_BLOCK_NONCOMBAT,
|
||||
UNBLOCKED_ATTACKER,
|
||||
SEARCH_LIBRARY, LIBRARY_SEARCHED,
|
||||
SHUFFLE_LIBRARY, LIBRARY_SHUFFLED,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue