* Fixed a bug of abilities that trigger if a player cycles a card causing a "Game exception occurred: java.util.NoSuchElementException" error.

This commit is contained in:
LevelX2 2016-02-18 15:42:31 +01:00
parent 226a3f2e6b
commit 930b27226b

View file

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
@ -41,7 +40,6 @@ import mage.game.stack.StackObject;
*
* @author LevelX2
*/
public class CycleAllTriggeredAbility extends TriggeredAbilityImpl {
public CycleAllTriggeredAbility(Effect effect, boolean optional) {
@ -59,9 +57,12 @@ public class CycleAllTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getState().getStack().isEmpty()) {
return false;
}
StackObject item = game.getState().getStack().getFirst();
if (item instanceof StackAbility
&& ((StackAbility)item).getStackAbility() instanceof CyclingAbility) {
&& ((StackAbility) item).getStackAbility() instanceof CyclingAbility) {
return true;
}
return false;