mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
rewrite Lurking Informant (AI was crashing when trying to use it)
This commit is contained in:
@@ -123,62 +123,46 @@ public class CardFactory_Creatures {
|
|||||||
|
|
||||||
//*************** START *********** START **************************
|
//*************** START *********** START **************************
|
||||||
else if(cardName.equals("Lurking Informant")) {
|
else if(cardName.equals("Lurking Informant")) {
|
||||||
final SpellAbility a1 = new Ability_Tap(card, "2") {
|
Target target = new Target("Select target player", new String[] {"Player"});
|
||||||
|
Ability_Cost abCost = new Ability_Cost("2 T", cardName, true);
|
||||||
|
final SpellAbility a1 = new Ability_Activated(card, abCost, target) {
|
||||||
private static final long serialVersionUID = 1446529067071763245L;
|
private static final long serialVersionUID = 1446529067071763245L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
Player player = getTargetPlayer();
|
Player player = getTargetPlayer();
|
||||||
|
if(player == null) player = AllZone.HumanPlayer;
|
||||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
||||||
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
|
Card c = lib.get(0);
|
||||||
CardList libList = new CardList(lib.getCards());
|
|
||||||
Card c = libList.get(0);
|
|
||||||
String[] choices = {"Yes", "No"};
|
|
||||||
if(card.getController().equals(AllZone.HumanPlayer)) {
|
if(card.getController().equals(AllZone.HumanPlayer)) {
|
||||||
Object o = AllZone.Display.getChoice("Mill " + c.getName() + " ?", choices);
|
if(GameActionUtil.showYesNoDialog(card, "Mill "+c.getName()+"?")) {
|
||||||
if(o.equals("Yes")) {
|
AllZone.GameAction.moveToGraveyard(c);
|
||||||
lib.remove(c);
|
}
|
||||||
grave.add(c);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
CardList landlist = new CardList();
|
CardList landlist = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
|
||||||
landlist.addAll(AllZone.Human_Battlefield.getCards());
|
//AI will just land starve or land feed human. Perhaps this could use overall card ranking
|
||||||
// i have no better idea how AI could use it then letting draw unneeded lands
|
if(landlist.size() >= 5 && !c.getType().contains("Land")) {
|
||||||
// this part will be good place to use card values lists or card values deck info
|
AllZone.GameAction.moveToGraveyard(c);
|
||||||
if(countLands(card) > 5 && !c.getType().contains("Land")) {
|
|
||||||
lib.remove(c);
|
|
||||||
grave.add(c);
|
|
||||||
}
|
}
|
||||||
if(countLands(card) <= 5) {
|
else if(landlist.size() < 5 && c.getType().contains("Land")) {
|
||||||
lib.remove(c);
|
AllZone.GameAction.moveToGraveyard(c);
|
||||||
grave.add(c);
|
}
|
||||||
|
else if(lib.size() <= 5) {
|
||||||
|
AllZone.GameAction.moveToGraveyard(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private int countLands(Card c) {
|
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, c.getController());
|
|
||||||
CardList lands = new CardList(play.getCards());
|
|
||||||
lands = lands.getType("Land");
|
|
||||||
return lands.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
Player player = getTargetPlayer();
|
CardList libList = AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer);
|
||||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
|
||||||
CardList libList = new CardList(lib.getCards());
|
|
||||||
return libList.size() > 0;
|
return libList.size() > 0;
|
||||||
}
|
}
|
||||||
};//SpellAbility
|
};//SpellAbility
|
||||||
card.addSpellAbility(a1);
|
card.addSpellAbility(a1);
|
||||||
a1.setDescription("2, tap: Look at the top card of target player's library. You may put that card into that player's graveyard.");
|
a1.setDescription(abCost+"Look at the top card of target player's library. You may put that card into that player's graveyard.");
|
||||||
a1.setStackDescription("Lurking Informant ability");
|
a1.setStackDescription(cardName+" - Look at the top card of target player's library. You may put that card into that player's graveyard.");
|
||||||
a1.setBeforePayMana(new Input_PayManaCost(a1));
|
|
||||||
a1.setBeforePayMana(CardFactoryUtil.input_targetPlayer(a1));
|
|
||||||
}//*************** END ************ END **************************
|
}//*************** END ************ END **************************
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user