Eladamri's Call
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Eladamri's Call
by DennisBergkamp » 25 Sep 2008, 23:27
I haven't really tested this with the AI yet, but I think it should work?
cards.txt:
cards.txt:
- Code: Select all
Eladamri's Call
G W
Instant
Search your library for a creature card, reveal that card, and put it into your hand. Then shuffle your library.
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Eladamri's Call"))
{
final SpellAbility spell = new Spell(card)
{
public void resolve()
{
String player = card.getController();
if(player.equals(Constant.Player.Human))
humanResolve();
else
computerResolve();
}
public void humanResolve()
{
CardList creatures = new CardList(AllZone.Human_Library.getCards());
creatures = creatures.getType("Creature");
Object check = AllZone.Display.getChoiceOptional("Select creature", creatures.toArray());
if(check != null)
{
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
AllZone.GameAction.moveTo(hand, (Card)check);
}
AllZone.GameAction.shuffle(Constant.Player.Human);
}
public void computerResolve()
{
Card[] library = AllZone.Computer_Library.getCards();
CardList list = new CardList(library);
list = list.getType("Creature");
//pick best creature
Card c = CardFactoryUtil.AI_getBestCreature(list);
if(c == null)
c = library[0];
System.out.println("computer picked - " +c);
AllZone.Computer_Library.remove(c);
AllZone.Computer_Hand.add(c);
}
public boolean canPlay()
{
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
return library.getCards().length != 0;
}
public boolean canPlayAI()
{
CardList creature = new CardList();
creature.addAll(AllZone.Computer_Library.getCards());
creature = creature.getType("Creature");
return creature.size() != 0;
}
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
- jpb
- Posts: 132
- Joined: 05 Sep 2008, 13:12
- Has thanked: 0 time
- Been thanked: 0 time
Re: Eladamri's Call
by DennisBergkamp » 26 Sep 2008, 20:14
Ahh alright. I'm not sure the System.out.println does anything in terms of showing text on the GUI by the way, I tried it earlier to debug something, but I never saw the text show up anywhere.
What's the best way of displaying what (in this case) creature card the computer picked?
What's the best way of displaying what (in this case) creature card the computer picked?
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Eladamri's Call
by jpb » 27 Sep 2008, 03:13
System.out.println works, just need to know where your stdout is going. If you are using an IDE you'll need to look in your documentation to find out. (In eclipse it is a tab called "console").
- jpb
- Posts: 132
- Joined: 05 Sep 2008, 13:12
- Has thanked: 0 time
- Been thanked: 0 time
Re: Eladamri's Call
by DennisBergkamp » 28 Sep 2008, 19:23
Ahh, I see it just ends up on the console. Very good to know, thanks
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 75 guests