diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index b7a8d3d..179329a 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -15,15 +15,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v2
- with:
- java-version: '8'
- distribution: 'adopt'
- - name: Build with Maven
- run: mvn -B package --file pom.xml
-
+ - uses: actions/checkout@v2
+ - name: Set up JDK 8
+ uses: actions/setup-java@v2
+ with:
+ java-version: '8'
+ distribution: 'adopt'
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
+
test:
needs: build
runs-on: ubuntu-latest
@@ -39,31 +39,31 @@ jobs:
with:
name: codecov
-
+
sonar:
needs: test
runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 11
- uses: actions/setup-java@v2
- with:
- java-version: '11'
- distribution: 'adopt'
- - name: Cache SonarCloud packages
- uses: actions/cache@v2.1.6
- with:
- path: ~/.sonar/cache
- key: ${{ runner.os }}-sonar
- restore-keys: ${{ runner.os }}-sonar
- - name: Cache Maven packages
- uses: actions/cache@v2.1.6
- with:
- path: ~/.m2
- key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
- - name: Build and analyze
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ingmargoudt_referee
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v2
+ with:
+ java-version: '11'
+ distribution: 'adopt'
+ - name: Cache SonarCloud packages
+ uses: actions/cache@v2.1.6
+ with:
+ path: ~/.sonar/cache
+ key: ${{ runner.os }}-sonar
+ restore-keys: ${{ runner.os }}-sonar
+ - name: Cache Maven packages
+ uses: actions/cache@v2.1.6
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+ - name: Build and analyze
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ingmargoudt_referee
diff --git a/README.md b/README.md
index c1e824d..3756b0e 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
# referee
+
[](https://codecov.io/gh/ingmargoudt/referee)
[](https://sonarcloud.io/dashboard?id=ingmargoudt_referee)
diff --git a/pom.xml b/pom.xml
index 3b86f16..f4d6d25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,6 @@
-
4.0.0
@@ -101,7 +101,6 @@
-
diff --git a/src/main/java/io/github/ingmargoudt/referee/cards/e/EssenceScatter.java b/src/main/java/io/github/ingmargoudt/referee/cards/e/EssenceScatter.java
new file mode 100644
index 0000000..4525c47
--- /dev/null
+++ b/src/main/java/io/github/ingmargoudt/referee/cards/e/EssenceScatter.java
@@ -0,0 +1,16 @@
+package io.github.ingmargoudt.referee.cards.e;
+
+import io.github.ingmargoudt.referee.game.CardType;
+import io.github.ingmargoudt.referee.game.effects.CounterEffect;
+import io.github.ingmargoudt.referee.game.objects.Card;
+import io.github.ingmargoudt.referee.game.targets.Filter;
+import io.github.ingmargoudt.referee.game.targets.TargetSpell;
+
+public class EssenceScatter extends Card {
+
+ public EssenceScatter() {
+ super("Essence Scatter");
+ cardtypes.add(CardType.INSTANT);
+ getSpellEffects().add(new CounterEffect(new TargetSpell(Filter.by(CardType.CREATURE.getPredicate()))));
+ }
+}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/CardType.java b/src/main/java/io/github/ingmargoudt/referee/game/CardType.java
index 988435a..3cc234d 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/CardType.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/CardType.java
@@ -1,8 +1,15 @@
package io.github.ingmargoudt.referee.game;
-public enum CardType {
+import io.github.ingmargoudt.referee.game.targets.CardTypePredicate;
+import io.github.ingmargoudt.referee.game.targets.Predicate;
+
+public enum CardType implements Predicatable {
CREATURE,
ENCHANTMENT,
INSTANT,
- LAND
+ LAND;
+
+ public Predicate getPredicate() {
+ return new CardTypePredicate(this);
+ }
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/CardTypes.java b/src/main/java/io/github/ingmargoudt/referee/game/CardTypes.java
index 1157b3c..d001add 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/CardTypes.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/CardTypes.java
@@ -40,4 +40,8 @@ public boolean isLand() {
public void clear() {
cardtypesList.clear();
}
+
+ public boolean has(CardType cardType) {
+ return cardtypesList.contains(cardType);
+ }
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/Game.java b/src/main/java/io/github/ingmargoudt/referee/game/Game.java
index 34defb9..8ff6fc7 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/Game.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/Game.java
@@ -100,8 +100,7 @@ public void start() {
public void assignActivePlayer() {
if (activePlayer == null) {
activePlayer = players[0].getId();
- }
- else {
+ } else {
for (int i = 0; i < players.length; i++) {
if (players[i].getId().equals(activePlayer)) {
setActive(players[(i + 1) % players.length].getId());
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/Predicatable.java b/src/main/java/io/github/ingmargoudt/referee/game/Predicatable.java
new file mode 100644
index 0000000..23f8d90
--- /dev/null
+++ b/src/main/java/io/github/ingmargoudt/referee/game/Predicatable.java
@@ -0,0 +1,8 @@
+package io.github.ingmargoudt.referee.game;
+
+import io.github.ingmargoudt.referee.game.targets.Predicate;
+
+public interface Predicatable {
+
+ Predicate getPredicate();
+}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/abilities/Indestructible.java b/src/main/java/io/github/ingmargoudt/referee/game/abilities/Indestructible.java
index d0907bc..2fab62d 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/abilities/Indestructible.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/abilities/Indestructible.java
@@ -8,7 +8,7 @@ private Indestructible() {
super();
}
- public static Indestructible getInstance(){
+ public static Indestructible getInstance() {
return instance;
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/abilities/StaticAbility.java b/src/main/java/io/github/ingmargoudt/referee/game/abilities/StaticAbility.java
index 354fed6..f643e55 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/abilities/StaticAbility.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/abilities/StaticAbility.java
@@ -11,7 +11,7 @@ public class StaticAbility extends Ability {
List effects = new ArrayList<>();
- public StaticAbility(){
+ public StaticAbility() {
super();
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/effects/DamageTargetEffect.java b/src/main/java/io/github/ingmargoudt/referee/game/effects/DamageTargetEffect.java
index 6be09f6..4cb8d3c 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/effects/DamageTargetEffect.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/effects/DamageTargetEffect.java
@@ -5,7 +5,6 @@
import io.github.ingmargoudt.referee.game.objects.MagicObject;
import io.github.ingmargoudt.referee.game.properties.Damageable;
import io.github.ingmargoudt.referee.game.targets.Target;
-import io.github.ingmargoudt.referee.game.targets.TargetAny;
public class DamageTargetEffect extends OneShotEffect implements TargetEffect {
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/objects/MagicObject.java b/src/main/java/io/github/ingmargoudt/referee/game/objects/MagicObject.java
index 92c50e1..f952611 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/objects/MagicObject.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/objects/MagicObject.java
@@ -5,12 +5,12 @@
import io.github.ingmargoudt.referee.game.abilities.Ability;
import io.github.ingmargoudt.referee.game.effects.OneShotEffect;
import io.github.ingmargoudt.referee.game.effects.ReplacementEffect;
-import io.github.ingmargoudt.referee.players.Player;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
@@ -27,7 +27,7 @@ public class MagicObject extends BaseObject {
protected String name;
protected ManaCost manaCost;
- protected Color color;
+ protected Set color;
protected Color colorIndicator;
protected CardTypes cardtypes;
protected SubTypes subTypes;
@@ -70,7 +70,7 @@ public void addAbility(Ability ability) {
abilities.add(ability);
}
- public void removeAbility(Class extends Ability> abilityClass){
+ public void removeAbility(Class extends Ability> abilityClass) {
abilities.remove(abilityClass);
}
@@ -85,4 +85,8 @@ public boolean isBasic() {
public boolean isControlledBy(UUID thePlayer) {
return getController().equals(thePlayer);
}
+
+ public boolean hasColor(Color color) {
+ return this.color.contains(color);
+ }
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/objects/Permanent.java b/src/main/java/io/github/ingmargoudt/referee/game/objects/Permanent.java
index dce66e8..7caa900 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/objects/Permanent.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/objects/Permanent.java
@@ -120,4 +120,6 @@ public void damage(int amount) {
public int getReceivedDamage() {
return damageReceived;
}
+
+
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/objects/Spell.java b/src/main/java/io/github/ingmargoudt/referee/game/objects/Spell.java
index 6bf86c2..5c45cc8 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/objects/Spell.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/objects/Spell.java
@@ -13,18 +13,21 @@
public class Spell extends MagicObject implements Stackable, Counterable, Targetable {
@Getter
- Card card;
+ private Card card;
+
public Spell(Card card) {
super(card.getName());
this.card = card;
+ this.cardtypes = card.getCardtypes();
+ this.spellEffects = card.getSpellEffects();
}
public void resolve(Game game) {
if (card.isPermanent()) {
game.moveToBattlefield(card);
} else {
- card.getSpellEffects().forEach(effect -> effect.apply(this, game));
+ getSpellEffects().forEach(effect -> effect.apply(this, game));
}
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/targets/CardTypePredicate.java b/src/main/java/io/github/ingmargoudt/referee/game/targets/CardTypePredicate.java
new file mode 100644
index 0000000..323149a
--- /dev/null
+++ b/src/main/java/io/github/ingmargoudt/referee/game/targets/CardTypePredicate.java
@@ -0,0 +1,23 @@
+package io.github.ingmargoudt.referee.game.targets;
+
+import io.github.ingmargoudt.referee.game.CardType;
+import io.github.ingmargoudt.referee.game.Game;
+import io.github.ingmargoudt.referee.game.objects.Spell;
+import io.github.ingmargoudt.referee.game.properties.Targetable;
+
+public class CardTypePredicate implements Predicate {
+
+ CardType theCardType;
+
+ public CardTypePredicate(CardType cardType) {
+ this.theCardType = cardType;
+ }
+
+ @Override
+ public boolean evaluate(Targetable target, Game game) {
+ if (target instanceof Spell) {
+ return ((Spell) target).getCard().getCardtypes().has(theCardType);
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/targets/Filter.java b/src/main/java/io/github/ingmargoudt/referee/game/targets/Filter.java
new file mode 100644
index 0000000..efb9fb7
--- /dev/null
+++ b/src/main/java/io/github/ingmargoudt/referee/game/targets/Filter.java
@@ -0,0 +1,33 @@
+package io.github.ingmargoudt.referee.game.targets;
+
+import io.github.ingmargoudt.referee.game.Game;
+import io.github.ingmargoudt.referee.game.properties.Targetable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Filter {
+
+ List predicates = new ArrayList<>();
+
+ private Filter() {
+
+ }
+
+ public static Filter by(Predicate predicate) {
+ return new Filter().addPredicate(predicate);
+ }
+
+ public static Filter empty() {
+ return new Filter();
+ }
+
+ public Filter addPredicate(Predicate predicate) {
+ predicates.add(predicate);
+ return this;
+ }
+
+ public boolean evaluate(Targetable target, Game game) {
+ return predicates.stream().allMatch(predicate -> predicate.evaluate(target, game));
+ }
+}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/targets/Predicate.java b/src/main/java/io/github/ingmargoudt/referee/game/targets/Predicate.java
new file mode 100644
index 0000000..137d333
--- /dev/null
+++ b/src/main/java/io/github/ingmargoudt/referee/game/targets/Predicate.java
@@ -0,0 +1,10 @@
+package io.github.ingmargoudt.referee.game.targets;
+
+import io.github.ingmargoudt.referee.game.Game;
+import io.github.ingmargoudt.referee.game.properties.Targetable;
+
+@FunctionalInterface
+public interface Predicate {
+
+ boolean evaluate(Targetable target, Game game);
+}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/targets/Target.java b/src/main/java/io/github/ingmargoudt/referee/game/targets/Target.java
index 6daa88b..080fcb6 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/targets/Target.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/targets/Target.java
@@ -10,6 +10,8 @@
public abstract class Target {
+ Filter filter = Filter.empty();
+
public abstract List validTargets(Game game);
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetAny.java b/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetAny.java
index 62dc28d..24f3605 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetAny.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetAny.java
@@ -18,7 +18,7 @@ public class TargetAny extends Target {
@Override
public List validTargets(Game game) {
- return Stream.concat(game.getPlayers().stream().map(Targetable.class::cast),
+ return Stream.concat(game.getPlayers().stream().map(Targetable.class::cast).filter(p -> filter.evaluate(p, game)),
game.getBattlefield().getAll().stream().map(Targetable.class::cast)).collect(Collectors.toList());
}
diff --git a/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetSpell.java b/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetSpell.java
index 685a702..a873fb1 100644
--- a/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetSpell.java
+++ b/src/main/java/io/github/ingmargoudt/referee/game/targets/TargetSpell.java
@@ -6,23 +6,31 @@
import io.github.ingmargoudt.referee.game.objects.Spell;
import io.github.ingmargoudt.referee.game.properties.Stackable;
import io.github.ingmargoudt.referee.game.properties.Targetable;
+import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
+@NoArgsConstructor
public class TargetSpell extends Target {
Targetable theTarget;
+
+ public TargetSpell(Filter filter) {
+ super();
+ this.filter = filter;
+ }
+
@Override
public List validTargets(Game game) {
- return game.getStack().show().stream().filter(Spell.class::isInstance).collect(Collectors.toList());
+ return game.getStack().show().stream().filter(Spell.class::isInstance).filter(spell -> filter.evaluate(spell, game)).collect(Collectors.toList());
}
@Override
public Optional resolve(Game game) {
- return game.getStack().show().stream().filter(Spell.class::isInstance).filter(spell -> spell.getId().equals(theTarget.getId())).findFirst();
+ return game.getStack().show().stream().filter(Spell.class::isInstance).filter(spell -> spell.getId().equals(theTarget.getId())).filter(spell -> filter.evaluate(spell, game)).findFirst();
}
@Override
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index 20d0f03..d26bacc 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,6 +1,5 @@
# Set root logger level to INFO and its only appender to stdout.
log4j.rootLogger=INFO, stdout
-
# Define the stdout appender to output logs to the console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
diff --git a/src/main/resources/log4j2.properties b/src/main/resources/log4j2.properties
index 5d121c6..911eb86 100644
--- a/src/main/resources/log4j2.properties
+++ b/src/main/resources/log4j2.properties
@@ -1,9 +1,8 @@
-appenders = console
-appender.console.type = Console
-appender.console.name = STDOUT
-appender.console.layout.type = PatternLayout
-appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n
-
-rootLogger.level = debug
-rootLogger.appenderRefs = stdout
-rootLogger.appenderRef.stdout.ref = STDOUT
\ No newline at end of file
+appenders=console
+appender.console.type=Console
+appender.console.name=STDOUT
+appender.console.layout.type=PatternLayout
+appender.console.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n
+rootLogger.level=debug
+rootLogger.appenderRefs=stdout
+rootLogger.appenderRef.stdout.ref=STDOUT
\ No newline at end of file
diff --git a/src/test/java/io/github/ingmargoudt/referee/Test_Manapool.java b/src/test/java/io/github/ingmargoudt/referee/Test_Manapool.java
index a7c0117..79c4336 100644
--- a/src/test/java/io/github/ingmargoudt/referee/Test_Manapool.java
+++ b/src/test/java/io/github/ingmargoudt/referee/Test_Manapool.java
@@ -9,7 +9,7 @@
class Test_Manapool {
@Test
- void addMana(){
+ void addMana() {
Manapool manapool = new Manapool();
manapool.add(ManaType.BLACK);
assertThat(manapool.getPool()).containsEntry(ManaType.BLACK, 1);
diff --git a/src/test/java/io/github/ingmargoudt/referee/Test_SimpleCast.java b/src/test/java/io/github/ingmargoudt/referee/Test_SimpleCast.java
index 874bcbc..b188a75 100644
--- a/src/test/java/io/github/ingmargoudt/referee/Test_SimpleCast.java
+++ b/src/test/java/io/github/ingmargoudt/referee/Test_SimpleCast.java
@@ -5,14 +5,18 @@
import io.github.ingmargoudt.referee.cards.c.CathedralSanctifier;
import io.github.ingmargoudt.referee.cards.c.CounterSpell;
import io.github.ingmargoudt.referee.cards.d.DarksteelMyr;
+import io.github.ingmargoudt.referee.cards.e.EssenceScatter;
import io.github.ingmargoudt.referee.cards.g.GloriousAnthem;
import io.github.ingmargoudt.referee.cards.g.GrizzlyBears;
import io.github.ingmargoudt.referee.cards.l.LightningBolt;
-import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.Phase;
+import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.zones.Zone;
import org.junit.jupiter.api.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
class Test_SimpleCast extends BaseGame {
private final Card bears = new GrizzlyBears();
@@ -88,22 +92,22 @@ void creatureHasToughness() {
}
@Test
- void castSpellWithSingleTarget(){
+ void castSpellWithSingleTarget() {
Card bolt = new LightningBolt();
addCard(Zone.HAND, player1, bolt);
- castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, player2);
+ castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, player2);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
assertLife(player2, 17);
}
@Test
- void castSpellWithSingleTargetCreature(){
+ void castSpellWithSingleTargetCreature() {
Card bolt = new LightningBolt();
Card bears = new GrizzlyBears();
addCard(Zone.HAND, player1, bolt);
addCard(Zone.BATTLEFIELD, player2, bears);
- castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, bears);
+ castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, bears);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
assertLife(player2, 20);
@@ -111,12 +115,12 @@ void castSpellWithSingleTargetCreature(){
}
@Test
- void indestructible_does_not_die_from_lethal_damage(){
+ void indestructible_does_not_die_from_lethal_damage() {
Card bolt = new LightningBolt();
Card darksteelmyr = new DarksteelMyr();
addCard(Zone.HAND, player1, bolt);
addCard(Zone.BATTLEFIELD, player2, darksteelmyr);
- castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, darksteelmyr);
+ castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, darksteelmyr);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
assertLife(player2, 20);
@@ -124,14 +128,14 @@ void indestructible_does_not_die_from_lethal_damage(){
}
@Test
- void castSpellWithSingleTargetCreature_counteruponresolution(){
+ void castSpellWithSingleTargetCreature_counteruponresolution() {
Card bolt = new LightningBolt();
Card bolt2 = new LightningBolt();
Card bears = new GrizzlyBears();
addCard(Zone.HAND, player1, bolt);
addCard(Zone.HAND, player2, bolt2);
addCard(Zone.BATTLEFIELD, player2, bears);
- castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, bears);
+ castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, bears);
castSpell(1, Phase.PRECOMBAT_MAINPHASE, player2, bolt2, bears);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
@@ -140,18 +144,32 @@ void castSpellWithSingleTargetCreature_counteruponresolution(){
}
@Test
- void castSpellWithSingleTargetSpell(){
+ void castSpellWithSingleTargetSpell() {
Card bolt = new LightningBolt();
Card counterspell = new CounterSpell();
addCard(Zone.HAND, player1, bolt);
- addCard(Zone.HAND, player2, counterspell );
- castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, player2);
+ addCard(Zone.HAND, player2, counterspell);
+ castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, player2);
castSpell(1, Phase.PRECOMBAT_MAINPHASE, player2, counterspell, bolt);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
assertGraveyard(player1, bolt);
}
+ @Test
+ void castSpellWithSingleTargetSpellFilter() {
+ Card bolt = new LightningBolt();
+ Card essenceScatter = new EssenceScatter();
+ addCard(Zone.HAND, player1, bolt);
+ addCard(Zone.HAND, player2, essenceScatter);
+ castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, bolt, player2);
+ castSpell(1, Phase.PRECOMBAT_MAINPHASE, player2, essenceScatter, bolt);
+ stopAt(1, Phase.PRECOMBAT_MAINPHASE);
+ Throwable throwable = assertThrows(AssertionError.class, this::start);
+ assertThat(throwable.getMessage()).isEqualTo("Player 2 has remaining actions: Cast Essence Scatter targeting Lightning Bolt");
+ assertLife(player2, 17);
+ }
+
@Test
void gloriousAnthemBoosts() {
disablePlayerActionLogging();
@@ -177,7 +195,7 @@ void gloriousAnthemNotBoostsOtherPlayersCreature() {
}
@Test
- void change_active_player_on_next_turn(){
+ void change_active_player_on_next_turn() {
disablePlayerActionLogging();
stopAt(2, Phase.PRECOMBAT_MAINPHASE);
start();
diff --git a/src/test/java/io/github/ingmargoudt/referee/base/BaseGame.java b/src/test/java/io/github/ingmargoudt/referee/base/BaseGame.java
index 9e00a33..74b28bc 100644
--- a/src/test/java/io/github/ingmargoudt/referee/base/BaseGame.java
+++ b/src/test/java/io/github/ingmargoudt/referee/base/BaseGame.java
@@ -1,7 +1,8 @@
package io.github.ingmargoudt.referee.base;
import io.github.ingmargoudt.referee.framework.EventBus;
-import io.github.ingmargoudt.referee.game.*;
+import io.github.ingmargoudt.referee.game.Phase;
+import io.github.ingmargoudt.referee.game.SubTypes;
import io.github.ingmargoudt.referee.game.abilities.Ability;
import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.objects.Permanent;
@@ -15,10 +16,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
-import java.util.ArrayList;
-import java.util.Optional;
-
import java.util.*;
+import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,6 +30,14 @@ public class BaseGame {
private Map startingLifes = new HashMap<>();
+ public BaseGame() {
+ game = new TestGame();
+ player1 = new TestPlayer("Player 1", game, createLibraries());
+ player2 = new TestPlayer("Player 2", game, createLibraries());
+ game.addPlayer(player1);
+ game.addPlayer(player2);
+ }
+
private Library createLibraries() {
ArrayList cards = new ArrayList<>();
for (int i = 0; i < 60; i++) {
@@ -48,20 +55,12 @@ void before(TestInfo testInfo) {
});
}
+
@AfterEach
- void after(){
+ void after() {
log.info("");
}
-
- public BaseGame() {
- game = new TestGame();
- player1 = new TestPlayer("Player 1", game, createLibraries());
- player2 = new TestPlayer("Player 2", game, createLibraries());
- game.addPlayer(player1);
- game.addPlayer(player2);
- }
-
protected void castSpell(int turn, Phase phase, TestPlayer player, Card card) {
player.addAction(new CastSpellAction(turn, phase, card));
}
@@ -71,7 +70,7 @@ protected void castSpell(int turn, Phase phase, TestPlayer player, Card card, Ta
}
- protected void playLand(TestPlayer player, int turnNumber, Phase phase, Card card){
+ protected void playLand(TestPlayer player, int turnNumber, Phase phase, Card card) {
player.addAction(new PlayLandAction(turnNumber, phase, card));
}
@@ -87,27 +86,26 @@ protected void start() {
game.start();
boolean ok = true;
+ String message = "";
if (player1.hasRemainingActions()) {
- log.error(player1.getName() + " has remaining actions: "+player1.getActions());
- ok = false;
+ message += (player1.getName() + " has remaining actions: " + player1.getActions().stream().map(Object::toString).collect(Collectors.joining()));
}
if (player2.hasRemainingActions()) {
- log.error(player2.getName() + " has remaining actions: "+player2.getActions());
- ok = false;
+ message += (player2.getName() + " has remaining actions: " + player2.getActions().stream().map(Object::toString).collect(Collectors.joining()));
}
- if (!ok) {
- Fail.fail("Not all actions executed");
+ if (!message.isEmpty()) {
+ Fail.fail(message);
}
}
- protected void addCard(Zone zone, TestPlayer player, Card card){
+ protected void addCard(Zone zone, TestPlayer player, Card card) {
addCard(zone, player, card, 1);
}
protected void addCard(Zone zone, TestPlayer player, Card card, int amount) {
card.setController(player.getId());
card.setOwner(player.getId());
- for(int i = 0; i theAbility){
- for(Permanent permanent : game.getBattlefield().getAll()){
- if(permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())){
- assertThat(permanent.hasAbility(theAbility)).as(theCard.getName() + " does not have the " +theAbility.getSimpleName()).isTrue();
- log.info(theCard.getName() + " of "+thePlayer.getName() + " has the "+theAbility.getSimpleName());
+
+ protected void assertPermanentHasAbility(TestPlayer thePlayer, Card theCard, Class extends Ability> theAbility) {
+ for (Permanent permanent : game.getBattlefield().getAll()) {
+ if (permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())) {
+ assertThat(permanent.hasAbility(theAbility)).as(theCard.getName() + " does not have the " + theAbility.getSimpleName()).isTrue();
+ log.info(theCard.getName() + " of " + thePlayer.getName() + " has the " + theAbility.getSimpleName());
}
}
}
- protected void assertLife(TestPlayer testPlayer, int amount){
+ protected void assertLife(TestPlayer testPlayer, int amount) {
assertThat(testPlayer.getLife()).isEqualTo(amount);
}
- public List getPlayers(){
+ public List getPlayers() {
return game.getPlayers();
}
- protected void assertTapped(TestPlayer thePlayer, Card theCard){
- for(Permanent permanent : game.getBattlefield().getAll()){
- if(permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())){
- assertThat(permanent.isTapped()).as(permanent.getName()+ " is expected to be tapped").isTrue();
- log.info(theCard.getName() + " of "+thePlayer.getName() + " is tapped");
+ protected void assertTapped(TestPlayer thePlayer, Card theCard) {
+ for (Permanent permanent : game.getBattlefield().getAll()) {
+ if (permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())) {
+ assertThat(permanent.isTapped()).as(permanent.getName() + " is expected to be tapped").isTrue();
+ log.info(theCard.getName() + " of " + thePlayer.getName() + " is tapped");
return;
}
}
- Fail.fail("No permanent named "+theCard.getName() + " under control of "+thePlayer);
+ Fail.fail("No permanent named " + theCard.getName() + " under control of " + thePlayer);
}
- protected void assertUntapped(TestPlayer thePlayer, Card theCard){
- for(Permanent permanent : game.getBattlefield().getAll()){
- if(permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())){
- assertThat(permanent.isTapped()).as(permanent.getName()+ " is expected to be untapped").isFalse();
- log.info(theCard.getName() + " of "+thePlayer.getName() + " is untapped");
+ protected void assertUntapped(TestPlayer thePlayer, Card theCard) {
+ for (Permanent permanent : game.getBattlefield().getAll()) {
+ if (permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())) {
+ assertThat(permanent.isTapped()).as(permanent.getName() + " is expected to be untapped").isFalse();
+ log.info(theCard.getName() + " of " + thePlayer.getName() + " is untapped");
return;
}
}
- Fail.fail("No permanent named "+theCard.getName() + " under control of "+thePlayer);
+ Fail.fail("No permanent named " + theCard.getName() + " under control of " + thePlayer);
}
- protected void assertSubTypes(TestPlayer thePlayer, Card theCard, SubTypes thesubtypes){
- for(Permanent permanent : game.getBattlefield().getAll()){
- if(permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())){
- assertThat(permanent.getSubTypes()).as(permanent.getName()+ " has wrong set of subtypes").isEqualTo(thesubtypes);
- log.info(theCard.getName() + " of "+thePlayer.getName() + " has subtypes "+thesubtypes);
+ protected void assertSubTypes(TestPlayer thePlayer, Card theCard, SubTypes thesubtypes) {
+ for (Permanent permanent : game.getBattlefield().getAll()) {
+ if (permanent.isControlledBy(thePlayer) && permanent.getName().equals(theCard.getName())) {
+ assertThat(permanent.getSubTypes()).as(permanent.getName() + " has wrong set of subtypes").isEqualTo(thesubtypes);
+ log.info(theCard.getName() + " of " + thePlayer.getName() + " has subtypes " + thesubtypes);
return;
}
}
- Fail.fail("No permanent named "+theCard.getName() + " under control of "+thePlayer);
+ Fail.fail("No permanent named " + theCard.getName() + " under control of " + thePlayer);
}
- protected void setOption(TestPlayer testPlayer, String option){
+ protected void setOption(TestPlayer testPlayer, String option) {
testPlayer.addOption(option);
}
- private Optional findPermanentByCard(TestPlayer thePlaer, Card theCard){
+ private Optional findPermanentByCard(TestPlayer thePlaer, Card theCard) {
return game.getBattlefield().getAll().stream().filter(permanent -> permanent.isControlledBy(thePlaer) && permanent.getName().equals(theCard.getName())).findFirst();
}
- protected void assertGraveyard(TestPlayer player, Card theCard){
+ protected void assertGraveyard(TestPlayer player, Card theCard) {
assertThat(player.getGraveyard().contains(theCard)).isTrue();
}
- protected void setLife(TestPlayer player, int lifeTotal){
+ protected void setLife(TestPlayer player, int lifeTotal) {
player.addAction(new TestSetLifeAction(1, Phase.PRECOMBAT_MAINPHASE, lifeTotal));
}
- protected void assertActivePlayer(TestPlayer testPlayer){
+ protected void assertActivePlayer(TestPlayer testPlayer) {
game.getActivePlayer().ifPresent(player -> {
assertThat(player.getId()).isEqualTo(testPlayer.getId());
});
diff --git a/src/test/java/io/github/ingmargoudt/referee/base/CastSpellAction.java b/src/test/java/io/github/ingmargoudt/referee/base/CastSpellAction.java
index dd80935..daea2e7 100644
--- a/src/test/java/io/github/ingmargoudt/referee/base/CastSpellAction.java
+++ b/src/test/java/io/github/ingmargoudt/referee/base/CastSpellAction.java
@@ -1,7 +1,7 @@
package io.github.ingmargoudt.referee.base;
-import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.Phase;
+import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.properties.Targetable;
import lombok.Getter;
@@ -16,23 +16,31 @@ public class CastSpellAction extends TestPlayerAction {
private List targets;
- public CastSpellAction(int turn, Phase phase, Card card){
+ public CastSpellAction(int turn, Phase phase, Card card) {
super(turn, phase);
this.card = card;
}
- public CastSpellAction(int turn, Phase phase, Card card, Targetable target){
+ public CastSpellAction(int turn, Phase phase, Card card, Targetable target) {
super(turn, phase);
this.card = card;
targets = new ArrayList<>();
targets.add(target);
}
- public Targetable consumeTarget(){
+ public Targetable consumeTarget() {
return targets.remove(0);
}
+ public String toString() {
+ String cast = "Cast " + card.getName();
+ if (!targets.isEmpty()) {
+ cast += " targeting " + targets.get(0).getName();
+ }
+ return cast;
+ }
+
@Override
public void execute(TestPlayer player) {
player.castSpell(card);
diff --git a/src/test/java/io/github/ingmargoudt/referee/base/PlayLandAction.java b/src/test/java/io/github/ingmargoudt/referee/base/PlayLandAction.java
index 8e39bf8..1266882 100644
--- a/src/test/java/io/github/ingmargoudt/referee/base/PlayLandAction.java
+++ b/src/test/java/io/github/ingmargoudt/referee/base/PlayLandAction.java
@@ -1,7 +1,7 @@
package io.github.ingmargoudt.referee.base;
-import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.Phase;
+import io.github.ingmargoudt.referee.game.objects.Card;
import lombok.Getter;
public class PlayLandAction extends TestPlayerAction {
@@ -10,7 +10,7 @@ public class PlayLandAction extends TestPlayerAction {
private Card card;
- public PlayLandAction(int turn, Phase phase, Card card){
+ public PlayLandAction(int turn, Phase phase, Card card) {
super(turn, phase);
this.card = card;
}
diff --git a/src/test/java/io/github/ingmargoudt/referee/base/TestGame.java b/src/test/java/io/github/ingmargoudt/referee/base/TestGame.java
index e2dd97f..72fcaab 100644
--- a/src/test/java/io/github/ingmargoudt/referee/base/TestGame.java
+++ b/src/test/java/io/github/ingmargoudt/referee/base/TestGame.java
@@ -2,11 +2,10 @@
import io.github.ingmargoudt.referee.game.Game;
import io.github.ingmargoudt.referee.game.zones.Battlefield;
-import io.github.ingmargoudt.referee.players.Player;
public class TestGame extends Game {
- public Battlefield getBattlefield(){
+ public Battlefield getBattlefield() {
return battlefield;
}
diff --git a/src/test/java/io/github/ingmargoudt/referee/base/TestPlayer.java b/src/test/java/io/github/ingmargoudt/referee/base/TestPlayer.java
index 33ac289..4c3f7f0 100644
--- a/src/test/java/io/github/ingmargoudt/referee/base/TestPlayer.java
+++ b/src/test/java/io/github/ingmargoudt/referee/base/TestPlayer.java
@@ -20,20 +20,19 @@ public class TestPlayer extends Player {
private List options = new ArrayList<>();
-
public TestPlayer(String name, TestGame game, Library library) {
super(name, game, library);
}
- void addAction(TestPlayerAction playerAction){
+ void addAction(TestPlayerAction playerAction) {
actions.add(playerAction);
}
- void addOption(String option){
+ void addOption(String option) {
options.add(option);
}
- public Hand getHand(){
+ public Hand getHand() {
return hand;
}
@@ -43,42 +42,40 @@ public void mulligan() {
}
@Override
- public void shuffle(){
+ public void shuffle() {
}
-
- public boolean hasRemainingActions(){
+ public boolean hasRemainingActions() {
return !actions.isEmpty();
}
-
@Override
public void doAction() {
Iterator playerActionIterator = actions.listIterator();
- while(playerActionIterator.hasNext()){
+ while (playerActionIterator.hasNext()) {
TestPlayerAction action = playerActionIterator.next();
currenAction = action;
- if(action.phase == gameReference.getCurrentPhase() && action.turn == gameReference.getTurnNumber())
- {
- if(action instanceof CastSpellAction && gameReference.isPlayable(this, ((CastSpellAction) action).getCard())){
+ if (action.phase == gameReference.getCurrentPhase() && action.turn == gameReference.getTurnNumber()) {
+ if (action instanceof CastSpellAction && gameReference.isPlayable(this, ((CastSpellAction) action).getCard())) {
action.execute(this);
playerActionIterator.remove();
return;
}
- if(action instanceof PlayLandAction && gameReference.isPlayable(this, ((PlayLandAction) action).getCard())){
+ if (action instanceof PlayLandAction && gameReference.isPlayable(this, ((PlayLandAction) action).getCard())) {
action.execute(this);
playerActionIterator.remove();
return;
}
- if(action instanceof TestSetLifeAction ){
+ if (action instanceof TestSetLifeAction) {
action.execute(this);
playerActionIterator.remove();
return;
}
- };
+ }
+ ;
}
passPriority();
@@ -86,10 +83,10 @@ public void doAction() {
@Override
public Targetable chooseTarget(List validTargets) {
- if(currenAction instanceof CastSpellAction){
+ if (currenAction instanceof CastSpellAction) {
return ((CastSpellAction) currenAction).consumeTarget();
}
- return Fail.fail("Current action has no target");
+ return Fail.fail("Current action has no target");
}
@Override
diff --git a/src/test/java/io/github/ingmargoudt/referee/base/TestPlayerAction.java b/src/test/java/io/github/ingmargoudt/referee/base/TestPlayerAction.java
index 7ead536..e61e469 100644
--- a/src/test/java/io/github/ingmargoudt/referee/base/TestPlayerAction.java
+++ b/src/test/java/io/github/ingmargoudt/referee/base/TestPlayerAction.java
@@ -7,10 +7,11 @@ public abstract class TestPlayerAction {
int turn;
Phase phase;
- public TestPlayerAction(int turn , Phase phase){
- this.turn = turn;
+ public TestPlayerAction(int turn, Phase phase) {
+ this.turn = turn;
this.phase = phase;
}
- public abstract void execute(TestPlayer player);
+ public abstract void execute(TestPlayer player);
+
}
diff --git a/src/test/java/io/github/ingmargoudt/referee/base/TestSetLifeAction.java b/src/test/java/io/github/ingmargoudt/referee/base/TestSetLifeAction.java
index 46246b0..8b40a9a 100644
--- a/src/test/java/io/github/ingmargoudt/referee/base/TestSetLifeAction.java
+++ b/src/test/java/io/github/ingmargoudt/referee/base/TestSetLifeAction.java
@@ -6,12 +6,12 @@ public class TestSetLifeAction extends TestPlayerAction {
int life;
- public TestSetLifeAction(int turn , Phase phase, int life){
- super(turn, phase);
+ public TestSetLifeAction(int turn, Phase phase, int life) {
+ super(turn, phase);
this.life = life;
- }
+ }
- public void execute(TestPlayer player){
- player.setLife(life);
- }
+ public void execute(TestPlayer player) {
+ player.setLife(life);
+ }
}
diff --git a/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_100_General/Test_100.java b/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_100_General/Test_100.java
index fccf849..0142b0f 100644
--- a/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_100_General/Test_100.java
+++ b/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_100_General/Test_100.java
@@ -13,7 +13,7 @@ class Test_100 extends BaseGame {
//100.1a A two-player game is a game that begins with only two players.
@Test
- void _1a(){
+ void _1a() {
assertThat(getPlayers()).hasSize(2);
}
@@ -22,7 +22,7 @@ void _1a(){
//“Multiplayer Rules.”
@Disabled("Not yet implemented")
@Test
- void _1b(){
+ void _1b() {
}
@@ -30,5 +30,4 @@ void _1b(){
//any tokens and counters, and some way to clearly track life totals.
-
}
diff --git a/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_105_Colors/Test_105.java b/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_105_Colors/Test_105.java
index 0156dec..dee92ce 100644
--- a/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_105_Colors/Test_105.java
+++ b/src/test/java/io/github/ingmargoudt/referee/comprehensiverules/_1_Game_Concepts/_105_Colors/Test_105.java
@@ -12,12 +12,12 @@ class Test_105 {
//105.1. There are five colors in the Magic game: white, blue, black, red, and green.
@Test
- void _1051(){
+ void _1051() {
assertThat(Color.values()).hasSize(5);
- assertThat(Arrays.stream(Color.values()).map(p->p.toString().toLowerCase()).collect(Collectors.toList())).contains("white");
- assertThat(Arrays.stream(Color.values()).map(p->p.toString().toLowerCase()).collect(Collectors.toList())).contains("blue");
- assertThat(Arrays.stream(Color.values()).map(p->p.toString().toLowerCase()).collect(Collectors.toList())).contains("black");
- assertThat(Arrays.stream(Color.values()).map(p->p.toString().toLowerCase()).collect(Collectors.toList())).contains("red");
- assertThat(Arrays.stream(Color.values()).map(p->p.toString().toLowerCase()).collect(Collectors.toList())).contains("green");
+ assertThat(Arrays.stream(Color.values()).map(p -> p.toString().toLowerCase()).collect(Collectors.toList())).contains("white");
+ assertThat(Arrays.stream(Color.values()).map(p -> p.toString().toLowerCase()).collect(Collectors.toList())).contains("blue");
+ assertThat(Arrays.stream(Color.values()).map(p -> p.toString().toLowerCase()).collect(Collectors.toList())).contains("black");
+ assertThat(Arrays.stream(Color.values()).map(p -> p.toString().toLowerCase()).collect(Collectors.toList())).contains("red");
+ assertThat(Arrays.stream(Color.values()).map(p -> p.toString().toLowerCase()).collect(Collectors.toList())).contains("green");
}
}
diff --git a/src/test/java/io/github/ingmargoudt/referee/etb/Test_EnterTheBattlefield.java b/src/test/java/io/github/ingmargoudt/referee/etb/Test_EnterTheBattlefield.java
index 7bd6890..7b837e6 100644
--- a/src/test/java/io/github/ingmargoudt/referee/etb/Test_EnterTheBattlefield.java
+++ b/src/test/java/io/github/ingmargoudt/referee/etb/Test_EnterTheBattlefield.java
@@ -10,7 +10,7 @@
class Test_EnterTheBattlefield extends BaseGame {
@Test
- void test_InspiringCleric(){
+ void test_InspiringCleric() {
Card inspiringCleric = new InspiringCleric();
addCard(Zone.HAND, player1, inspiringCleric);
castSpell(1, Phase.PRECOMBAT_MAINPHASE, player1, inspiringCleric);
diff --git a/src/test/java/io/github/ingmargoudt/referee/lands/Test_ReplacementEffect.java b/src/test/java/io/github/ingmargoudt/referee/lands/Test_ReplacementEffect.java
index 5878f84..2d81a2f 100644
--- a/src/test/java/io/github/ingmargoudt/referee/lands/Test_ReplacementEffect.java
+++ b/src/test/java/io/github/ingmargoudt/referee/lands/Test_ReplacementEffect.java
@@ -6,17 +6,17 @@
import io.github.ingmargoudt.referee.cards.b.BloodCrypt;
import io.github.ingmargoudt.referee.cards.b.BloodMoon;
import io.github.ingmargoudt.referee.cards.f.ForsakenSanctuary;
-import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.Phase;
import io.github.ingmargoudt.referee.game.SubType;
import io.github.ingmargoudt.referee.game.SubTypes;
+import io.github.ingmargoudt.referee.game.objects.Card;
import io.github.ingmargoudt.referee.game.zones.Zone;
import org.junit.jupiter.api.Test;
class Test_ReplacementEffect extends BaseGame {
@Test
- void tap_land_comes_into_play_tapped(){
+ void tap_land_comes_into_play_tapped() {
Card forsakenSanctuary = new ForsakenSanctuary();
addCard(Zone.HAND, player1, forsakenSanctuary);
playLand(player1, 1, Phase.PRECOMBAT_MAINPHASE, forsakenSanctuary);
@@ -26,7 +26,7 @@ void tap_land_comes_into_play_tapped(){
}
@Test
- void tap_land_comes_into_play_untapped_with_bloodmoon(){
+ void tap_land_comes_into_play_untapped_with_bloodmoon() {
Card forsakenSanctuary = new ForsakenSanctuary();
Card bloodmoon = new BloodMoon();
addCard(Zone.HAND, player1, forsakenSanctuary);
@@ -41,24 +41,24 @@ void tap_land_comes_into_play_untapped_with_bloodmoon(){
}
@Test
- void shock_land_comes_into_play_untapped_with_bloodmoon(){
+ void shock_land_comes_into_play_untapped_with_bloodmoon() {
Card bloodcrypt = new BloodCrypt();
Card bloodmoon = new BloodMoon();
addCard(Zone.HAND, player1, bloodcrypt);
addCard(Zone.BATTLEFIELD, player1, bloodmoon);
playLand(player1, 1, Phase.PRECOMBAT_MAINPHASE, bloodcrypt);
- setOption(player1,"Yes");
+ setOption(player1, "Yes");
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
assertUntapped(player1, bloodcrypt);
}
@Test
- void shock_land_comes_into_play_untapped_after_cost(){
+ void shock_land_comes_into_play_untapped_after_cost() {
Card bloodcrypt = new BloodCrypt();
addCard(Zone.HAND, player1, bloodcrypt);
playLand(player1, 1, Phase.PRECOMBAT_MAINPHASE, bloodcrypt);
- setOption(player1,"Yes");
+ setOption(player1, "Yes");
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
assertUntapped(player1, bloodcrypt);
@@ -66,18 +66,18 @@ void shock_land_comes_into_play_untapped_after_cost(){
}
@Test
- void shock_land_comes_into_play_tapped_after_not_paying_cost(){
+ void shock_land_comes_into_play_tapped_after_not_paying_cost() {
Card bloodcrypt = new BloodCrypt();
addCard(Zone.HAND, player1, bloodcrypt);
playLand(player1, 1, Phase.PRECOMBAT_MAINPHASE, bloodcrypt);
- setOption(player1,"No");
+ setOption(player1, "No");
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
start();
assertTapped(player1, bloodcrypt);
}
@Test
- void shock_land_comes_into_play_tapped_after_not_possible_paying_cost(){
+ void shock_land_comes_into_play_tapped_after_not_possible_paying_cost() {
Card bloodcrypt = new BloodCrypt();
addCard(Zone.HAND, player1, bloodcrypt);
setLife(player1, 1);
diff --git a/src/test/java/io/github/ingmargoudt/referee/lands/Test_lands_have_mana_abilities.java b/src/test/java/io/github/ingmargoudt/referee/lands/Test_lands_have_mana_abilities.java
index 3fb0c28..238c7b8 100644
--- a/src/test/java/io/github/ingmargoudt/referee/lands/Test_lands_have_mana_abilities.java
+++ b/src/test/java/io/github/ingmargoudt/referee/lands/Test_lands_have_mana_abilities.java
@@ -6,22 +6,22 @@
import io.github.ingmargoudt.referee.cards.m.Mountain;
import io.github.ingmargoudt.referee.cards.p.Plains;
import io.github.ingmargoudt.referee.cards.s.Swamp;
+import io.github.ingmargoudt.referee.game.Phase;
import io.github.ingmargoudt.referee.game.abilities.*;
import io.github.ingmargoudt.referee.game.objects.Card;
-import io.github.ingmargoudt.referee.game.Phase;
import io.github.ingmargoudt.referee.game.zones.Zone;
import org.junit.jupiter.api.Test;
class Test_lands_have_mana_abilities extends BaseGame {
- private static final Card mountain= new Mountain();
+ private static final Card mountain = new Mountain();
private static final Card plains = new Plains();
private static final Card swamp = new Swamp();
private static final Card island = new Island();
private static final Card forest = new Forest();
@Test
- void mountain(){
+ void mountain() {
disablePlayerActionLogging();
addCard(Zone.BATTLEFIELD, player1, mountain, 1);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
@@ -30,7 +30,7 @@ void mountain(){
}
@Test
- void plains(){
+ void plains() {
disablePlayerActionLogging();
addCard(Zone.BATTLEFIELD, player1, plains, 1);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
@@ -39,7 +39,7 @@ void plains(){
}
@Test
- void swamp(){
+ void swamp() {
disablePlayerActionLogging();
addCard(Zone.BATTLEFIELD, player1, swamp, 1);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
@@ -48,7 +48,7 @@ void swamp(){
}
@Test
- void island(){
+ void island() {
disablePlayerActionLogging();
addCard(Zone.BATTLEFIELD, player1, island, 1);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
@@ -57,7 +57,7 @@ void island(){
}
@Test
- void forest(){
+ void forest() {
disablePlayerActionLogging();
addCard(Zone.BATTLEFIELD, player1, forest, 1);
stopAt(1, Phase.PRECOMBAT_MAINPHASE);
diff --git a/src/test/resources/log4j2.properties b/src/test/resources/log4j2.properties
index 5d121c6..911eb86 100644
--- a/src/test/resources/log4j2.properties
+++ b/src/test/resources/log4j2.properties
@@ -1,9 +1,8 @@
-appenders = console
-appender.console.type = Console
-appender.console.name = STDOUT
-appender.console.layout.type = PatternLayout
-appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n
-
-rootLogger.level = debug
-rootLogger.appenderRefs = stdout
-rootLogger.appenderRef.stdout.ref = STDOUT
\ No newline at end of file
+appenders=console
+appender.console.type=Console
+appender.console.name=STDOUT
+appender.console.layout.type=PatternLayout
+appender.console.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} - %msg%n
+rootLogger.level=debug
+rootLogger.appenderRefs=stdout
+rootLogger.appenderRef.stdout.ref=STDOUT
\ No newline at end of file