mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Implemented Gorm the Great
This commit is contained in:
parent
3fdfccce30
commit
8556285f0c
5 changed files with 80 additions and 1 deletions
|
|
@ -76,6 +76,10 @@ public abstract class RequirementEffect extends ContinuousEffectImpl {
|
|||
return null;
|
||||
}
|
||||
|
||||
public int getMinNumberOfBlockers() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Player related check The player returned or controlled planeswalker must
|
||||
* be attacked with at least one attacker
|
||||
|
|
|
|||
|
|
@ -35,18 +35,26 @@ import mage.game.permanent.Permanent;
|
|||
* @author LevelX2
|
||||
*/
|
||||
public class MustBeBlockedByAtLeastOneSourceEffect extends RequirementEffect {
|
||||
|
||||
private int minNumberOfBlockers;
|
||||
|
||||
public MustBeBlockedByAtLeastOneSourceEffect() {
|
||||
this(Duration.EndOfTurn);
|
||||
}
|
||||
|
||||
public MustBeBlockedByAtLeastOneSourceEffect(Duration duration) {
|
||||
this(duration, 1);
|
||||
}
|
||||
|
||||
public MustBeBlockedByAtLeastOneSourceEffect(Duration duration, int minNumberOfBlockers) {
|
||||
super(duration);
|
||||
this.minNumberOfBlockers = minNumberOfBlockers;
|
||||
staticText = "{this} must be blocked " + (duration == Duration.EndOfTurn ? "this turn " : "") + "if able";
|
||||
}
|
||||
|
||||
public MustBeBlockedByAtLeastOneSourceEffect(final MustBeBlockedByAtLeastOneSourceEffect effect) {
|
||||
super(effect);
|
||||
this.minNumberOfBlockers = effect.minNumberOfBlockers;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -69,6 +77,11 @@ public class MustBeBlockedByAtLeastOneSourceEffect extends RequirementEffect {
|
|||
return source.getSourceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinNumberOfBlockers() {
|
||||
return minNumberOfBlockers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MustBeBlockedByAtLeastOneSourceEffect copy() {
|
||||
return new MustBeBlockedByAtLeastOneSourceEffect(this);
|
||||
|
|
|
|||
|
|
@ -695,6 +695,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
//20101001 - 509.1c
|
||||
// map with attackers (UUID) that must be blocked by at least one blocker and a set of all creatures that can block it and don't block yet
|
||||
Map<UUID, Set<UUID>> mustBeBlockedByAtLeastOne = new HashMap<>();
|
||||
int minNumberOfBlockers = 0;
|
||||
|
||||
// check mustBlock requirements of creatures from opponents of attacking player
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES_CONTROLLED, player.getId(), game)) {
|
||||
|
|
@ -710,6 +711,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (Ability ability : entry.getValue()) {
|
||||
UUID toBeBlockedCreature = effect.mustBlockAttackerIfElseUnblocked(ability, game);
|
||||
if (toBeBlockedCreature != null) {
|
||||
minNumberOfBlockers = effect.getMinNumberOfBlockers();
|
||||
Set<UUID> potentialBlockers;
|
||||
if (mustBeBlockedByAtLeastOne.containsKey(toBeBlockedCreature)) {
|
||||
potentialBlockers = mustBeBlockedByAtLeastOne.get(toBeBlockedCreature);
|
||||
|
|
@ -804,6 +806,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (Ability ability : entry.getValue()) {
|
||||
UUID toBeBlockedCreature = effect.mustBlockAttackerIfElseUnblocked(ability, game);
|
||||
if (toBeBlockedCreature != null) {
|
||||
minNumberOfBlockers = effect.getMinNumberOfBlockers();
|
||||
Set<UUID> potentialBlockers;
|
||||
if (mustBeBlockedByAtLeastOne.containsKey(toBeBlockedCreature)) {
|
||||
potentialBlockers = mustBeBlockedByAtLeastOne.get(toBeBlockedCreature);
|
||||
|
|
@ -898,6 +901,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
requirementFulfilled &= (combatGroup.getBlockers().size() >= Math.min(minNumberOfBlockers, mustBeBlockedByAtLeastOne.get(toBeBlockedCreatureId).size()));
|
||||
if (!requirementFulfilled) {
|
||||
// creature is not blocked but has possible blockers
|
||||
if (controller.isHuman()) {
|
||||
|
|
@ -906,6 +910,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
// check if all possible blocker block other creatures they are forced to block
|
||||
// read through all possible blockers
|
||||
for (UUID possibleBlockerId : mustBeBlockedByAtLeastOne.get(toBeBlockedCreatureId)) {
|
||||
if (combatGroup.getBlockers().contains(possibleBlockerId)) {
|
||||
continue;
|
||||
}
|
||||
String blockRequiredMessage = isCreatureDoingARequiredBlock(
|
||||
possibleBlockerId, toBeBlockedCreatureId, mustBeBlockedByAtLeastOne, game);
|
||||
if (blockRequiredMessage != null) { // message means not required
|
||||
|
|
@ -931,7 +938,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
defender.declareBlocker(defender.getId(), possibleBlockerId, toBeBlockedCreatureId, game);
|
||||
}
|
||||
break;
|
||||
if (combatGroup.getBlockers().size() >= minNumberOfBlockers) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue