-
Notifications
You must be signed in to change notification settings - Fork 884
Player Hidden Keywords related to SearchLibrary #10219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kojotak
wants to merge
4
commits into
Card-Forge:master
Choose a base branch
from
kojotak:issue/4760/searchLibrary
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
98f3002
StaticAbilityCantSearchLibrary
kojotak 6200bd6
refactoring renamed StaticAbilityCantSearchLibrary
kojotak d318e09
Leonin Arbiter: added Continuos mode for IgnoreEffectCost$
kojotak 4de14fc
StaticAbilitySearchLibrary#cantSearchLibrary considers getIgnoreEffec…
kojotak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
54 changes: 54 additions & 0 deletions
54
forge-game/src/main/java/forge/game/staticability/StaticAbilitySearchLibrary.java
This file contains hidden or 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,54 @@ | ||
| package forge.game.staticability; | ||
|
|
||
| import forge.game.player.Player; | ||
| import forge.game.zone.ZoneType; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| import static forge.game.staticability.StaticAbilityMode.CantSearchLibrary; | ||
| import static forge.game.staticability.StaticAbilityMode.LimitSearchLibrary; | ||
| import static forge.game.staticability.StaticAbilityMode.CantCauseToSearchLibrary; | ||
|
|
||
|
|
||
| public class StaticAbilitySearchLibrary { | ||
|
|
||
| /** | ||
| * @return maximum number of cards which can be fetched from a library considering its size and search limit or null if there is no limit | ||
| */ | ||
| public static Integer limitSearchLibraryConsideringSize(Player player) { | ||
| Integer limit = limitSearchLibrary(player); | ||
| if (limit != null) { | ||
| return Math.min(player.getCardsIn(ZoneType.Library).size(), limit); | ||
| } else { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @return maximum number of cards which can be revealed from a library or null if there is no limit | ||
| */ | ||
| public static Integer limitSearchLibrary(Player player) { | ||
| return findStaticAbilityForValidPlayer(player, LimitSearchLibrary) | ||
| .map(stAb -> Integer.valueOf(stAb.getParam("LimitNum"))) | ||
| .orElse(null); | ||
| } | ||
|
|
||
| public static boolean cantSearchLibrary(Player player) { | ||
| return findStaticAbilityForValidPlayer(player, CantSearchLibrary) | ||
| .filter(stAb -> !stAb.getIgnoreEffectPlayers().contains(player)) | ||
| .isPresent(); | ||
| } | ||
|
|
||
| public static boolean cantCauseToSearchLibrary(Player player) { | ||
| return findStaticAbilityForValidPlayer(player, CantCauseToSearchLibrary).isPresent(); | ||
| } | ||
|
|
||
| private static Optional<StaticAbility> findStaticAbilityForValidPlayer(final Player player, final StaticAbilityMode mode) { | ||
| return player.getGame() | ||
| .getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES) | ||
| .stream() | ||
| .flatMap(card -> card.getStaticAbilities().stream()) | ||
| .filter(stAb -> stAb.checkConditions(mode) && stAb.matchesValidParam("ValidPlayer", player)) | ||
| .findAny(); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,5 +4,5 @@ Types:Creature Bird Wizard | |
| PT:2/1 | ||
| K:Flash | ||
| K:Flying | ||
| S:Mode$ Continuous | Affected$ Player.Opponent | AddKeyword$ LimitSearchLibrary | Description$ If an opponent would search a library, that player searches the top four cards of that library instead. | ||
| S:Mode$ LimitSearchLibrary | ValidPlayer$ Player.Opponent | LimitNum$ 4 | Description$ If an opponent would search a library, that player searches the top four cards of that library instead. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically this is a replacement effect |
||
| Oracle:Flash\nFlying\nIf an opponent would search a library, that player searches the top four cards of that library instead. | ||
This file contains hidden or 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 hidden or 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,5 +1,5 @@ | ||
| Name:Mindlock Orb | ||
| ManaCost:3 U | ||
| Types:Artifact | ||
| S:Mode$ Continuous | Affected$ Player | AddKeyword$ CantSearchLibrary | Description$ Players can't search libraries. | ||
| S:Mode$ CantSearchLibrary | ValidPlayer$ Player | Description$ Players can't search libraries. | ||
| Oracle:Players can't search libraries. |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.