Scry

One of the new spPumpTgt cards I want to add is Ferocious Charge. Simple, except for the Scry 2.
I have spent the evening devising a method which I think should work. I would like to propose that it shall be handled similarly to the "Draw a card." revision. There are a few cards that use Scry in an odd way, (damn Future Sight) but complex cards can always be hardcoded and still make use this generic scry method.
It uses a very simplistic AI to dig past basic lands and creatures if there are more than 5 of either of them in play.
I haven't put this into the SVN yet, I wanted to post it for review first.
GameAction.java
I have spent the evening devising a method which I think should work. I would like to propose that it shall be handled similarly to the "Draw a card." revision. There are a few cards that use Scry in an odd way, (damn Future Sight) but complex cards can always be hardcoded and still make use this generic scry method.
It uses a very simplistic AI to dig past basic lands and creatures if there are more than 5 of either of them in play.
I haven't put this into the SVN yet, I wanted to post it for review first.
GameAction.java
- Code: Select all
public void scry(String player, int numScry)
{
CardList topN = new CardList();
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
for (int i = 0; i < numScry; i++)
{
topN.add(library.get(0));
library.remove(0);
}
int N = topN.size();
if (player.equals(Constant.Player.Human))
{
for (int i = 0; i < N; i++)
{
Object o;
o = AllZone.Display.getChoiceOptional("Choose a card to put on the bottom of your library.", topN.toArray());
if (o != null)
{
Card c = (Card)o;
topN.remove(c);
library.add(c);
}
else // no card chosen for the bottom
break;
}
N = topN.size();
if (N > 0)
for (int i = 0; i < N; i++)
{
Object o;
o = AllZone.Display.getChoice("Choose a card to put on the top of your library.", topN.toArray());
if (o != null)
{
Card c = (Card)o;
topN.remove(c);
library.add(c, 0);
}
// no else - a card must have been chosen
}
}
else // computer
{
for (int i = 0; i < N; i++)
{
boolean b = false;
if (topN.get(i).getType().contains("Basic"))
{
CardList bl = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
bl = bl.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
if (c.getType().contains("Basic"))
return true;
return false;
}
});
if (bl.size() > 5) // if control more than 5 Basic land, probably don't need more
b = true;
}
else if (topN.get(i).getType().contains("Creature"))
{
CardList cl = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
cl = cl.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
if (c.getType().contains("Creature"))
return true;
return false;
}
});
if (cl.size() > 5) // if control more than 5 Creatures, probably don't need more
b = true;
}
if (b == true)
{
library.add(topN.get(i));
topN.remove(i);
}
}
N = topN.size();
if (N > 0)
for (int i=0; i<N; i++) // put the rest on top in random order
{
Random rndm = new Random();
int r = rndm.nextInt(topN.size());
library.add(topN.get(r), 0);
topN.remove(r);
}
}
}