mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Fix #9441
This commit is contained in:
parent
2cef7dd597
commit
e0ade383f2
13 changed files with 77 additions and 202 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.dynamicvalue;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -36,6 +35,9 @@ public class MultipliedValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (value.toString().equals("1")) {
|
||||
return Integer.toString(multiplier);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (multiplier == 2) {
|
||||
sb.append("twice ");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -7,30 +6,32 @@ import mage.abilities.effects.Effect;
|
|||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Markedagain
|
||||
* @author awjackson
|
||||
*/
|
||||
public enum BlockedCreatureCount implements DynamicValue {
|
||||
ALL("each creature blocking it", false),
|
||||
BEYOND_FIRST("each creature blocking it beyond the first", true);
|
||||
public enum BlockingCreatureCount implements DynamicValue {
|
||||
SOURCE("creature blocking it"),
|
||||
TARGET("creature blocking it"),
|
||||
BEYOND_FIRST("creature blocking it beyond the first");
|
||||
|
||||
private final String message;
|
||||
private final boolean beyondTheFirst;
|
||||
|
||||
BlockedCreatureCount(String message, boolean beyondTheFirst) {
|
||||
BlockingCreatureCount(String message) {
|
||||
this.message = message;
|
||||
this.beyondTheFirst = beyondTheFirst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
UUID attackerId = (this == TARGET ? effect.getTargetPointer().getFirst(game, sourceAbility) : sourceAbility.getSourceId());
|
||||
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
|
||||
if (!combatGroup.getAttackers().contains(sourceAbility.getSourceId())) {
|
||||
if (!combatGroup.getAttackers().contains(attackerId)) {
|
||||
continue;
|
||||
}
|
||||
int blockers = combatGroup.getBlockers().size();
|
||||
if (beyondTheFirst) {
|
||||
blockers = blockers > 0 ? blockers - 1 : 0;
|
||||
if (this == BEYOND_FIRST) {
|
||||
blockers = Math.max(blockers - 1, 0);
|
||||
}
|
||||
return blockers;
|
||||
}
|
||||
|
|
@ -38,7 +39,7 @@ public enum BlockedCreatureCount implements DynamicValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockedCreatureCount copy() {
|
||||
public BlockingCreatureCount copy() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -49,6 +50,6 @@ public enum BlockedCreatureCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
|
@ -3,11 +3,10 @@ package mage.abilities.keyword;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BecomesBlockedSourceTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.dynamicvalue.MultipliedValue;
|
||||
import mage.abilities.dynamicvalue.common.BlockingCreatureCount;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -27,7 +26,7 @@ public class RampageAbility extends BecomesBlockedSourceTriggeredAbility {
|
|||
+ (shortRuleText ? ""
|
||||
: " <i>(Whenever this creature becomes blocked, it gets +"
|
||||
+ amount + "/+" + amount + " until end of turn for each creature blocking it beyond the first.)</i>");
|
||||
RampageValue rv = new RampageValue(amount);
|
||||
DynamicValue rv = (amount == 1 ? BlockingCreatureCount.BEYOND_FIRST : new MultipliedValue(BlockingCreatureCount.BEYOND_FIRST, amount));
|
||||
this.addEffect(new BoostSourceEffect(rv, rv, Duration.EndOfTurn, true));
|
||||
}
|
||||
|
||||
|
|
@ -46,38 +45,3 @@ public class RampageAbility extends BecomesBlockedSourceTriggeredAbility {
|
|||
return rule;
|
||||
}
|
||||
}
|
||||
|
||||
class RampageValue implements DynamicValue {
|
||||
|
||||
private final int amount;
|
||||
|
||||
public RampageValue(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public RampageValue(final RampageValue value) {
|
||||
this.amount = value.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RampageValue copy() {
|
||||
return new RampageValue(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
|
||||
if (combatGroup.getAttackers().contains(sourceAbility.getSourceId())) {
|
||||
int blockers = combatGroup.getBlockers().size();
|
||||
return blockers > 1 ? (blockers - 1) * amount : 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "rampage " + amount + "(Whenever this creature becomes blocked, it gets +"
|
||||
+ amount + "/+" + amount + " until end of turn for each creature blocking it beyond the first.)";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue