forked from External/mage
implement Orcish Conscripts, rework can't block alone ability
This commit is contained in:
parent
d785193b97
commit
00ff663c40
24 changed files with 289 additions and 186 deletions
|
|
@ -0,0 +1,42 @@
|
|||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.common.FilterBlockingCreature;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantBlockAloneSourceEffect extends RestrictionEffect {
|
||||
|
||||
private static final FilterBlockingCreature filter = new FilterBlockingCreature("Blocking creatures");
|
||||
public CantBlockAloneSourceEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "{this} can't block alone";
|
||||
}
|
||||
|
||||
protected CantBlockAloneSourceEffect(final CantBlockAloneSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantBlockAloneSourceEffect copy() {
|
||||
return new CantBlockAloneSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockCheckAfter(Ability source, Game game, boolean canUseChooseDialogs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getId().equals(source.getSourceId())) {
|
||||
return game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).size() <= 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.combat.CantAttackAloneSourceEffect;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_googlemail.com
|
||||
*/
|
||||
public class CantAttackAloneAbility extends SimpleStaticAbility {
|
||||
|
||||
public CantAttackAloneAbility() {
|
||||
super(Zone.BATTLEFIELD, new CantAttackAloneSourceEffect());
|
||||
}
|
||||
|
||||
private CantAttackAloneAbility(CantAttackAloneAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantAttackAloneAbility copy() {
|
||||
return new CantAttackAloneAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.combat.CantAttackAloneSourceEffect;
|
||||
import mage.abilities.effects.common.combat.CantBlockAloneSourceEffect;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
* @author notgreat
|
||||
*/
|
||||
public class CantAttackOrBlockAloneAbility extends SimpleStaticAbility {
|
||||
|
||||
public CantAttackOrBlockAloneAbility() {
|
||||
super(Zone.BATTLEFIELD, new CantAttackAloneSourceEffect().setText("{this} can't attack or block alone"));
|
||||
this.addEffect(new CantBlockAloneSourceEffect().setText(""));
|
||||
}
|
||||
|
||||
private CantAttackOrBlockAloneAbility(CantAttackOrBlockAloneAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantAttackOrBlockAloneAbility copy() {
|
||||
return new CantAttackOrBlockAloneAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
|
||||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.StaticAbility;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_googlemail.com
|
||||
*/
|
||||
public class CantBlockAloneAbility extends StaticAbility implements MageSingleton {
|
||||
|
||||
private static final CantBlockAloneAbility instance = new CantBlockAloneAbility();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static CantBlockAloneAbility getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private CantBlockAloneAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "{this} can't block alone.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantBlockAloneAbility copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -679,29 +679,6 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
possibleBlockers.put(attacker.getId(), goodBlockers);
|
||||
}
|
||||
|
||||
// effects: can't block alone
|
||||
// too much blockers
|
||||
if (blockersCount == 1) {
|
||||
List<UUID> toBeRemoved = new ArrayList<>();
|
||||
for (UUID blockerId : getBlockers()) {
|
||||
Permanent blocker = game.getPermanent(blockerId);
|
||||
if (blocker != null && blocker.getAbilities().containsKey(CantBlockAloneAbility.getInstance().getId())) {
|
||||
blockWasLegal = false;
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(blocker.getLogName() + " can't block alone. Removing it from combat.");
|
||||
}
|
||||
toBeRemoved.add(blockerId);
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID blockerId : toBeRemoved) {
|
||||
game.getCombat().removeBlocker(blockerId, game);
|
||||
}
|
||||
if (blockers.isEmpty()) {
|
||||
this.blocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID uuid : attackers) {
|
||||
Permanent attacker = game.getPermanent(uuid);
|
||||
if (attacker != null && this.blocked) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.keyword.CantAttackAloneAbility;
|
||||
import mage.abilities.keyword.CantBlockAloneAbility;
|
||||
import mage.abilities.keyword.CantAttackOrBlockAloneAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
||||
|
|
@ -19,8 +18,7 @@ public final class BeastieToken extends TokenImpl {
|
|||
power = new MageInt(4);
|
||||
toughness = new MageInt(4);
|
||||
|
||||
this.addAbility(new CantAttackAloneAbility());
|
||||
this.addAbility(CantBlockAloneAbility.getInstance());
|
||||
this.addAbility(new CantAttackOrBlockAloneAbility());
|
||||
}
|
||||
|
||||
private BeastieToken(final BeastieToken token) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue