External Activation and Triggers
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
External Activation and Triggers
by friarsol » 27 Apr 2014, 20:38
Ok, so I was looking at this last night and here's the deal:
Here's the (relatively new) block of code that is called form PhaseHandler to wait for activating an ability to be activated and returned or not.
Here's the (relatively new) block of code that is called form PhaseHandler to wait for activating an ability to be activated and returned or not.
- Code: Select all
@Override
public SpellAbility chooseSpellAbilityToPlay() {
PhaseType phase = game.getPhaseHandler().getPhase();
boolean maySkipPriority = mayAutoPass(phase) || isUiSetToSkipPhase(game.getPhaseHandler().getPlayerTurn(), phase);
if (game.getStack().isEmpty() && maySkipPriority) {
return null;
}
else {
autoPassCancel(); // probably cancel, since something has happened
}
InputPassPriority defaultInput = new InputPassPriority(player);
defaultInput.showAndWait();
return defaultInput.getChosenSa();
}
- Code: Select all
@Override
protected void onCardSelected(final Card card, final MouseEvent triggerEvent) {
List<SpellAbility> abilities = card.getAllPossibleAbilities(player, false);
if (abilities.isEmpty()) {
flashIncorrectAction();
return;
}
selectAbility(player.getController().getAbilityToPlay(abilities, triggerEvent));
}
- Code: Select all
ZoneAction flashBackAction = new ZoneAction(player.getZone(ZoneType.Graveyard), MatchConstants.HUMANFLASHBACK) {
@Override
protected List<Card> getCardsAsIterable() {
return player.getCardsActivableInExternalZones();
}
@Override
protected void doAction(final Card c) {
// activate cards only via your own flashback button
if (player.getLobbyPlayer() != CField.this.viewer) {
return;
}
final Game game = player.getGame();
// TODO: "can play" check needed!
// should I check for who owns these cards? Are there any abilities to be played from opponent's graveyard?
final SpellAbility ab = player.getController().getAbilityToPlay(c.getAllPossibleAbilities(player, true));
if ( null != ab) {
game.getAction().invoke(new Runnable(){
@Override public void run() {
HumanPlay.playSpellAbility(player, ab);
game.getStack().addAllTirggeredAbilitiesToStack(); // This line Sloth just added
}});
}
}
};
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: External Activation and Triggers
by friarsol » 28 Apr 2014, 00:54
Ok, I just checked in r25657 to attempt to fix this. I'll revert if it doesn't seem like it works, but it appeared to be triggering when I used a 40 Island deck with an Oracle of Mul Daya and Fastbond. I'll continue playing with the change tonight, but please let me know if the Flashback button is acting weird due to this, or anything else seems to not appreciate the flip
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: Jamesdit and 48 guests