forked from External/mage
Refactored restore state code, added additional error check for mana undo param;
This commit is contained in:
parent
2eeefd91ef
commit
83f7ae377a
12 changed files with 64 additions and 40 deletions
|
|
@ -1,12 +1,6 @@
|
|||
package mage.cards;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectImpl;
|
||||
import mage.Mana;
|
||||
|
|
@ -33,6 +27,10 @@ import mage.util.SubTypeList;
|
|||
import mage.watchers.Watcher;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -352,6 +350,24 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
for (Ability subAbility : ability.getSubAbilities()) {
|
||||
abilities.add(subAbility);
|
||||
}
|
||||
|
||||
// verify check: draw effect can't be rollback after mana usage (example: Chromatic Sphere)
|
||||
// (player can cheat with cancel button to see next card)
|
||||
// verify test will catch that errors
|
||||
if (ability instanceof ActivatedManaAbilityImpl) {
|
||||
ActivatedManaAbilityImpl manaAbility = (ActivatedManaAbilityImpl) ability;
|
||||
String rule = manaAbility.getRule().toLowerCase(Locale.ENGLISH);
|
||||
if (manaAbility.getEffects().stream().anyMatch(e -> e.getOutcome().equals(Outcome.DrawCard))
|
||||
|| rule.contains("reveal ")
|
||||
|| rule.contains("draw ")) {
|
||||
if (manaAbility.isUndoPossible()) {
|
||||
throw new IllegalArgumentException("Ability contains draw/reveal effect, but isUndoPossible is true. Ability: "
|
||||
+ ability.getClass().getSimpleName() + "; " + ability.getRule());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void addAbilities(List<Ability> abilities) {
|
||||
|
|
@ -395,10 +411,10 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
* Dynamic cost modification for card (process only own abilities). Example:
|
||||
* if it need stack related info (like real targets) then must check two
|
||||
* states (game.inCheckPlayableState):
|
||||
*
|
||||
* <p>
|
||||
* 1. In playable state it must check all possible use cases (e.g. allow to
|
||||
* reduce on any available target and modes)
|
||||
*
|
||||
* <p>
|
||||
* 2. In real cast state it must check current use case (e.g. real selected
|
||||
* targets and modes)
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue