-
Notifications
You must be signed in to change notification settings - Fork 834
[WHO] Implement The Five Doctors #13691
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
Open
padfoothelix
wants to merge
4
commits into
magefree:master
Choose a base branch
from
padfoothelix:addthefivedoctors
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.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package mage.cards.t; | ||
|
||
import mage.MageObject; | ||
import mage.abilities.Ability; | ||
import mage.abilities.condition.common.KickedCondition; | ||
import mage.abilities.effects.OneShotEffect; | ||
import mage.abilities.keyword.KickerAbility; | ||
import mage.abilities.decorator.ConditionalOneShotEffect; | ||
import mage.cards.CardImpl; | ||
import mage.cards.Card; | ||
import mage.cards.Cards; | ||
import mage.cards.CardsImpl; | ||
import mage.cards.CardSetInfo; | ||
import mage.constants.*; | ||
import mage.filter.FilterCard; | ||
import mage.game.Game; | ||
import mage.players.Player; | ||
import mage.target.TargetCard; | ||
import mage.target.common.TargetCardInLibrary; | ||
import mage.target.common.TargetCardInYourGraveyard; | ||
import mage.util.CardUtil; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* @author padfoothelix | ||
*/ | ||
public final class TheFiveDoctors extends CardImpl { | ||
|
||
private static final FilterCard filter = new FilterCard("Doctor cards"); | ||
|
||
static { | ||
filter.add(SubType.DOCTOR.getPredicate()); | ||
} | ||
|
||
public TheFiveDoctors(UUID ownerId, CardSetInfo setInfo) { | ||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{G}"); | ||
|
||
|
||
// Kicker {5} | ||
this.addAbility(new KickerAbility("{5}")); | ||
|
||
// Search your library and/or graveyard for up to five Doctor cards, reveal them, and put them into your hand. If you search your library this way, shuffle. If this spell was kicked, put those cards onto the battlefield instead of putting them into your hand. | ||
this.getSpellAbility().addEffect( | ||
new TheFiveDoctorsSearchLibraryGraveyardEffect(5, filter) | ||
); | ||
} | ||
|
||
private TheFiveDoctors(final TheFiveDoctors card) { | ||
super(card); | ||
} | ||
|
||
@Override | ||
public TheFiveDoctors copy() { | ||
return new TheFiveDoctors(this); | ||
} | ||
} | ||
|
||
class TheFiveDoctorsSearchLibraryGraveyardEffect extends OneShotEffect { | ||
|
||
private int cardsToSearch; | ||
private FilterCard filter; | ||
|
||
public TheFiveDoctorsSearchLibraryGraveyardEffect(int cardsToSearch, FilterCard filter) { | ||
super(Outcome.Benefit); | ||
this.cardsToSearch = cardsToSearch; | ||
this.filter = filter; | ||
staticText = "search your library and/or graveyard for up to " + CardUtil.numberToText(cardsToSearch) + " " + filter.getMessage() + | ||
", reveal them, and put them into your hand. If you search your library this way, shuffle. " + | ||
"If this spell was kicked, put those cards onto the battlefield instead of putting them into you hand."; | ||
} | ||
|
||
protected TheFiveDoctorsSearchLibraryGraveyardEffect(final TheFiveDoctorsSearchLibraryGraveyardEffect effect) { | ||
super(effect); | ||
this.cardsToSearch = effect.cardsToSearch; | ||
this.filter = effect.filter; | ||
|
||
} | ||
|
||
@Override | ||
public TheFiveDoctorsSearchLibraryGraveyardEffect copy() { | ||
return new TheFiveDoctorsSearchLibraryGraveyardEffect(this); | ||
} | ||
|
||
@Override | ||
public boolean apply(Game game, Ability source) { | ||
Player controller = game.getPlayer(source.getControllerId()); | ||
MageObject sourceObject = source.getSourceObject(game); | ||
Cards cardsFound = new CardsImpl(); | ||
boolean needShuffle = false; | ||
int cardsLeftToSearch = cardsToSearch; | ||
if (controller == null || sourceObject == null) { | ||
return false; | ||
} | ||
if (controller.chooseUse(outcome, "Search your library for up to " + CardUtil.numberToText(cardsToSearch) + " " + filter.getMessage() + '?', source, game)) { | ||
TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsToSearch, filter); | ||
targetLib.clearChosen(); | ||
|
||
if (controller.searchLibrary(targetLib, source, game)) { | ||
if (!targetLib.getTargets().isEmpty()) { | ||
|
||
for (UUID cardId : targetLib.getTargets()) { | ||
Card card = game.getCard(cardId); | ||
if (card != null) { | ||
cardsFound.add(card); | ||
} | ||
} | ||
} | ||
} | ||
needShuffle = true; | ||
} | ||
cardsLeftToSearch = cardsToSearch - cardsFound.count(filter, game); | ||
if (cardsLeftToSearch > 0 && controller.chooseUse(outcome, "Search your graveyard for up to " + CardUtil.numberToText(cardsLeftToSearch) + " " + filter.getMessage() + '?', source, game)) { | ||
TargetCard targetGrave = new TargetCardInYourGraveyard(0, cardsLeftToSearch, filter, true); | ||
targetGrave.clearChosen(); | ||
if (controller.chooseTarget(outcome, controller.getGraveyard(), targetGrave, source, game)) { | ||
if (!targetGrave.getTargets().isEmpty()) { | ||
for (UUID cardId : targetGrave.getTargets()) { | ||
Card card = game.getCard(cardId); | ||
if (card != null) { | ||
cardsFound.add(card); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (cardsFound != null) { | ||
controller.revealCards(sourceObject.getIdName(), cardsFound, game); | ||
if (KickedCondition.ONCE.apply(game, source)) { | ||
controller.moveCards(cardsFound, Zone.BATTLEFIELD, source, game); | ||
} else { | ||
controller.moveCards(cardsFound, Zone.HAND, source, game); | ||
} | ||
} | ||
if (needShuffle) { | ||
controller.shuffleLibrary(source, game); | ||
} | ||
return true; | ||
} | ||
} | ||
|
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For info: up to target/choice selection logic in GUI - human can select and unselect objects until their press a done button or their select max amount. There aren’t double dones. Maybe some dialogs calls multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't seen that code, thanks for pointing it out. I'm not sure if it can be used for [[The Five Doctors]] though, because if I'm reading this correctly, it doesn't exactly let the player search the library, it just selects cards from it with the
getCards
. When a player searches his library, he/she should be able to see all the cards in it, correct ? What's more, would triggered abilities that trigger whenever a player searches trigger correctly ?The change from
choose
tochooseTarget
method is not to work around a bug, it's just that the common method that useschoose
is not meant to select more than one card.Thanks for the precision on the double done issue. I believe this might be a bug in a common class ; I'll try and understand what's going on and I'll report about it if it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, search is important, yes. Then try to use another approach instead custom classes -- use two conditional standard effects and custom text like that:

There are:
SearchLibraryGraveyardPutInHandEffect
withInvertCondition
+KickedCondition
SearchLibraryGraveyardPutOntoBattlefieldEffect
withKickedCondition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used code from those methods, but I can't use them directly, because they are coded to find just one card with a specific name. I need up to five cards with a given type. That's why I use a custom class. I didn't find a common class that does the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, then keep custom class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done a little more research and found this about the graveyard search :
I'm not sure if it's better to use option 1 or 2. Option 2 opens up the graveyard automatically, which is more user-friendly, I suppose. I'm not sure if the target/notTarget is relevant, since we search out of the battlefield anyway, and the targetcard is defined with the boolean notTarget set as true.
Let me know if you think one option is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can’t reproduce your player.choose(cards) bug in gui’s tests dialogs — it’s allow to selects any cards.
I need more details: dialog call code, target setting and cards list for choosing
P.S. target.choose is better way to choose targets - it works same way for any player type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this line (114) :
if (controller.chooseTarget(outcome, controller.getGraveyard(), targetGrave, source, game)) {
In you replace chooseTarget with choose, then you can select cards from the graveyard, but then when you click Done, nothing happens (cards are not put in hand or battlefield), unless you have selected the maximum amount of cards.
I don't think this is a bug, I think it's just the way the method is supposed to work. If I understand correctly, it returns false if you interrupt the choosing process.
PS : I used player.choose because it was the method used in
SearchLibraryGraveyardPutInHandEffect
, but I can try and use target.choose if that's better.