Prevent returning ability that can't be played

This commit is contained in:
drdev
2013-11-11 02:22:27 +00:00
parent 4e7e14cbf3
commit 812d4ca519
2 changed files with 10 additions and 4 deletions

View File

@@ -80,9 +80,12 @@ public abstract class Ability extends SpellAbility {
} }
public static final Ability PLAY_LAND_SURROGATE = new Ability(null, (Cost)null){ public static final Ability PLAY_LAND_SURROGATE = new Ability(null, (Cost)null){
@Override
public boolean canPlay() {
return true; //if this ability is added anywhere, it can be assummed that land can be played
}
@Override @Override
public void resolve() { public void resolve() {
// TODO Auto-generated method stub
throw new RuntimeException("This ability is intended to indicate \"land to play\" choice only"); throw new RuntimeException("This ability is intended to indicate \"land to play\" choice only");
} }
@Override @Override

View File

@@ -105,7 +105,10 @@ public class PlayerControllerHuman extends PlayerController {
return null; return null;
} }
if (abilities.size() == 1 && !abilities.get(0).promptIfOnlyPossibleAbility()) { if (abilities.size() == 1 && !abilities.get(0).promptIfOnlyPossibleAbility()) {
return abilities.get(0); if (abilities.get(0).canPlay()) {
return abilities.get(0); //only return ability if it's playable, otherwise return null
}
return null;
} }
//show menu if mouse was trigger for ability //show menu if mouse was trigger for ability
@@ -120,7 +123,7 @@ public class PlayerControllerHuman extends PlayerController {
public void run() { public void run() {
CMessage.SINGLETON_INSTANCE.getInputControl().selectAbility(ab); CMessage.SINGLETON_INSTANCE.getInputControl().selectAbility(ab);
} }
}, ab.getActivatingPlayer() == null || ab.canPlay()); //check getActivatingPlayer() to account for playing lands }, ab.canPlay());
shortcut++; shortcut++;
if (shortcut > KeyEvent.VK_9) { if (shortcut > KeyEvent.VK_9) {
shortcut = 0; //stop adding shortcuts after 9 shortcut = 0; //stop adding shortcuts after 9