-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
igoudt
committed
Oct 26, 2021
1 parent
8ce8cde
commit 73e5d73
Showing
37 changed files
with
337 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected] | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Cache Maven packages | ||
uses: actions/[email protected] | ||
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/[email protected] | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Cache Maven packages | ||
uses: actions/[email protected] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# referee | ||
|
||
[](https://codecov.io/gh/ingmargoudt/referee) | ||
[](https://sonarcloud.io/dashboard?id=ingmargoudt_referee) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/io/github/ingmargoudt/referee/cards/e/EssenceScatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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())))); | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
src/main/java/io/github/ingmargoudt/referee/game/CardType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/io/github/ingmargoudt/referee/game/Predicatable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.github.ingmargoudt.referee.game; | ||
|
||
import io.github.ingmargoudt.referee.game.targets.Predicate; | ||
|
||
public interface Predicatable { | ||
|
||
Predicate getPredicate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,4 +120,6 @@ public void damage(int amount) { | |
public int getReceivedDamage() { | ||
return damageReceived; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/io/github/ingmargoudt/referee/game/targets/CardTypePredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/io/github/ingmargoudt/referee/game/targets/Filter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Predicate> 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)); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/io/github/ingmargoudt/referee/game/targets/Predicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.