mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
Fix Adventures exiling themselves before applying their effects (#10793)
* Rework adventures to exiles themself after applying other effects * fix duelist * finalize all adventures * apply review * add card name to error * fix remaining adventures * finalize the last adventures.
This commit is contained in:
parent
3ed0dd4f84
commit
fe165f1fd0
108 changed files with 322 additions and 18 deletions
|
|
@ -26,6 +26,10 @@ public abstract class AdventureCard extends CardImpl {
|
|||
this.spellCard = new AdventureCardSpellImpl(ownerId, setInfo, adventureName, typesSpell, costsSpell, this);
|
||||
}
|
||||
|
||||
public void finalizeAdventure() {
|
||||
spellCard.finalizeAdventure();
|
||||
}
|
||||
|
||||
public AdventureCard(AdventureCard card) {
|
||||
super(card);
|
||||
this.spellCard = card.getSpellCard().copy();
|
||||
|
|
|
|||
|
|
@ -7,4 +7,6 @@ public interface AdventureCardSpell extends SubCard<AdventureCard> {
|
|||
|
||||
@Override
|
||||
AdventureCardSpell copy();
|
||||
|
||||
void finalizeAdventure();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ public class AdventureCardSpellImpl extends CardImpl implements AdventureCardSpe
|
|||
this.adventureCardParent = adventureCardParent;
|
||||
}
|
||||
|
||||
public void finalizeAdventure() {
|
||||
if (spellAbility instanceof AdventureCardSpellAbility) {
|
||||
((AdventureCardSpellAbility) spellAbility).finalizeAdventure();
|
||||
}
|
||||
}
|
||||
|
||||
protected AdventureCardSpellImpl(final AdventureCardSpellImpl card) {
|
||||
super(card);
|
||||
this.adventureCardParent = card.adventureCardParent;
|
||||
|
|
@ -100,18 +106,35 @@ public class AdventureCardSpellImpl extends CardImpl implements AdventureCardSpe
|
|||
|
||||
class AdventureCardSpellAbility extends SpellAbility {
|
||||
|
||||
String nameFull;
|
||||
private String nameFull;
|
||||
private boolean finalized = false;
|
||||
|
||||
public AdventureCardSpellAbility(final SpellAbility baseSpellAbility, String adventureName, CardType[] cardTypes, String costs) {
|
||||
super(baseSpellAbility);
|
||||
this.setName(cardTypes, adventureName, costs);
|
||||
this.addEffect(ExileAdventureSpellEffect.getInstance());
|
||||
this.setCardName(adventureName);
|
||||
}
|
||||
|
||||
// The exile effect needs to be added last.
|
||||
public void finalizeAdventure() {
|
||||
if (finalized) {
|
||||
throw new IllegalStateException("Wrong code usage. "
|
||||
+ "Adventure (" + cardName + ") "
|
||||
+ "need to call finalizeAdventure() exactly once.");
|
||||
}
|
||||
this.addEffect(ExileAdventureSpellEffect.getInstance());
|
||||
this.finalized = true;
|
||||
}
|
||||
|
||||
protected AdventureCardSpellAbility(final AdventureCardSpellAbility ability) {
|
||||
super(ability);
|
||||
this.nameFull = ability.nameFull;
|
||||
if (!ability.finalized) {
|
||||
throw new IllegalStateException("Wrong code usage. "
|
||||
+ "Adventure (" + cardName + ") "
|
||||
+ "need to call finalizeAdventure() at the very end of the card's constructor.");
|
||||
}
|
||||
this.finalized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -155,7 +178,7 @@ class AdventureCardSpellAbility extends SpellAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility copy() {
|
||||
public AdventureCardSpellAbility copy() {
|
||||
return new AdventureCardSpellAbility(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue