mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Prevent returning ability that can't be played
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user