mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 14:32:06 -08:00
Fixed test, fixed some code warnings
This commit is contained in:
parent
5c30467c48
commit
e8ffe90d41
10 changed files with 21 additions and 20 deletions
|
|
@ -50,6 +50,8 @@ public final class FirstComeFirstServed extends CardImpl {
|
|||
|
||||
class FirstComeFirstServedPredicate implements Predicate<Permanent> {
|
||||
|
||||
private static final Pattern partNumberPattern = Pattern.compile("\\d+");
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
if (input instanceof PermanentCard) {
|
||||
|
|
@ -67,8 +69,11 @@ class FirstComeFirstServedPredicate implements Predicate<Permanent> {
|
|||
|
||||
public int parseCardNumber(Permanent input) {
|
||||
String str = input.getCardNumber();
|
||||
Matcher matcher = Pattern.compile("\\d+").matcher(str);
|
||||
matcher.find();
|
||||
Matcher matcher = partNumberPattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return Integer.parseInt(matcher.group());
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown card number format [" + input.getCardNumber() + "] for permanent " + input.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ class KotoseTheSilentSpiderWatcher extends Watcher {
|
|||
morMap.values()
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.map(set -> set.removeIf(mor -> !mor.zoneCounterIsCurrent(game)));
|
||||
.forEach(set -> set.removeIf(mor -> !mor.zoneCounterIsCurrent(game)));
|
||||
morMap.values().removeIf(Set::isEmpty);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ class MaddeningImpCreateDelayedTriggeredAbilityEffect extends OneShotEffect {
|
|||
}
|
||||
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility
|
||||
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new MaddeningImpDelayedDestroyEffect(activeCreatures), TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
|
||||
delayedAbility.getDuration();
|
||||
game.addDelayedTriggeredAbility(delayedAbility, source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class NashiMoonSagesScionWatcher extends Watcher {
|
|||
morMap.values()
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.map(set -> set.removeIf(mor -> !mor.zoneCounterIsCurrent(game)));
|
||||
.forEach(set -> set.removeIf(mor -> !mor.zoneCounterIsCurrent(game)));
|
||||
morMap.values().removeIf(Set::isEmpty);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ class NettlingImpDelayedDestroyEffect extends OneShotEffect {
|
|||
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
|
||||
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility
|
||||
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
|
||||
delayedAbility.getDuration();
|
||||
delayedAbility.getTargets().addAll(source.getTargets());
|
||||
game.addDelayedTriggeredAbility(delayedAbility, source);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ class NorrittDelayedDestroyEffect extends OneShotEffect {
|
|||
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
|
||||
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility
|
||||
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
|
||||
delayedAbility.getDuration();
|
||||
delayedAbility.getTargets().addAll(source.getTargets());
|
||||
game.addDelayedTriggeredAbility(delayedAbility, source);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class StanggEchoWarriorEffect extends OneShotEffect {
|
|||
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
|
||||
effect.setSavedPermanent(attachment);
|
||||
effect.apply(game, source);
|
||||
effect.getAddedPermanents().stream().map(t -> permanent.addAttachment(t.getId(), source, game));
|
||||
effect.getAddedPermanents().forEach(t -> permanent.addAttachment(t.getId(), source, game));
|
||||
toSacrifice.addAll(effect.getAddedPermanents());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import mage.cards.s.Storyweave;
|
|||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
|
@ -56,12 +57,12 @@ public class StoryweaveTest extends CardTestPlayerBase {
|
|||
|
||||
assertCounterCount(playerA, fang, CounterType.P1P1, 0);
|
||||
assertPermanentCount(playerA, "Centaur Token", 2);
|
||||
currentGame
|
||||
Assert.assertTrue(currentGame
|
||||
.getBattlefield()
|
||||
.getAllActivePermanents()
|
||||
.stream()
|
||||
.filter(permanent -> "Centaur Token".equals(permanent.getName()))
|
||||
.noneMatch(permanent -> permanent.getCounters(currentGame).getCount(CounterType.P1P1) != 2);
|
||||
.noneMatch(permanent -> permanent.getCounters(currentGame).getCount(CounterType.P1P1) != 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -80,11 +81,11 @@ public class StoryweaveTest extends CardTestPlayerBase {
|
|||
|
||||
assertCounterCount(playerA, fang, CounterType.P1P1, 2);
|
||||
assertPermanentCount(playerA, "Centaur Token", 2);
|
||||
currentGame
|
||||
Assert.assertTrue(currentGame
|
||||
.getBattlefield()
|
||||
.getAllActivePermanents()
|
||||
.stream()
|
||||
.filter(permanent -> "Centaur Token".equals(permanent.getName()))
|
||||
.noneMatch(permanent -> permanent.getCounters(currentGame).getCount(CounterType.P1P1) != 0);
|
||||
.noneMatch(permanent -> permanent.getCounters(currentGame).getCount(CounterType.P1P1) != 0));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,11 +111,9 @@ class BecomeMonstrousSourceEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
private String setText(int monstrosityValue) {
|
||||
StringBuilder sb = new StringBuilder("Monstrosity ");
|
||||
sb.append(monstrosityValue == Integer.MAX_VALUE ? "X" : monstrosityValue)
|
||||
.append(". <i>(If this creature isn't monstrous, put ")
|
||||
.append(monstrosityValue == Integer.MAX_VALUE ? "X" : CardUtil.numberToText(monstrosityValue))
|
||||
.append(" +1/+1 counters on it and it becomes monstrous.)</i>").toString();
|
||||
return sb.toString();
|
||||
return "Monstrosity " + (monstrosityValue == Integer.MAX_VALUE ? "X" : monstrosityValue) +
|
||||
". <i>(If this creature isn't monstrous, put " +
|
||||
(monstrosityValue == Integer.MAX_VALUE ? "X" : CardUtil.numberToText(monstrosityValue)) +
|
||||
" +1/+1 counters on it and it becomes monstrous.)</i>";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public abstract class TargetImpl implements Target {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
int min = getMinNumberOfTargets();
|
||||
int max = getMaxNumberOfTargets();
|
||||
if (min != 1 || max != 1) {
|
||||
if (!getTargetName().startsWith("X") && (min != 1 || max != 1)) {
|
||||
if (min < max && max != Integer.MAX_VALUE) {
|
||||
if (min == 1 && max == 2) {
|
||||
sb.append("one or ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue