card request - Vampiric Tutor
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
card request - Vampiric Tutor
by jpb » 19 Oct 2008, 09:14
Could someone please implement this card for me? I absolutely love it.
- jpb
- Posts: 132
- Joined: 05 Sep 2008, 13:12
- Has thanked: 0 time
- Been thanked: 0 time
Re: card request - Vampiric Tutor
by DennisBergkamp » 19 Oct 2008, 20:13
Sure, I'll do Vampiric Tutor
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: card request - Vampiric Tutor
by DennisBergkamp » 22 Oct 2008, 15:55
The AI code is a bit nonsensical for this card, since it will only try to find the best creature. Something left to do is to actually have the computer find a useful non-creature card.
In cards.txt:
In cards.txt:
- Code: Select all
Vampiric Tutor
B
Instant
Search your library for a card, then shuffle your library and put that card on top of it. You lose 2 life.
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Vampiric Tutor"))
{
SpellAbility spell = new Spell(card)
{
public boolean canPlayAI()
{
if (4 < AllZone.Phase.getTurn() && AllZone.Computer_Library.size() > 0)
return true;
else
return false;
}
public void resolve()
{
String player = card.getController();
if(player.equals(Constant.Player.Human))
humanResolve();
else
computerResolve();
}
public void computerResolve()
{
//TODO: somehow select a good non-creature card for AI
CardList creature = new CardList(AllZone.Computer_Library.getCards());
creature = creature.getType("Creature");
if(creature.size() != 0)
{
Card c = CardFactoryUtil.AI_getBestCreature(creature);
if(c == null)
{
creature.shuffle();
c = creature.get(0);
}
AllZone.GameAction.shuffle(card.getController());
//move to top of library
AllZone.Computer_Library.remove(c);
AllZone.Computer_Library.add(c, 0);
//lose 2 life
String player = Constant.Player.Computer;
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
life.subtractLife(2);
}
}//computerResolve()
public void humanResolve()
{
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
CardList list = new CardList(library.getCards());
if(list.size() != 0)
{
Object o = AllZone.Display.getChoiceOptional("Select a card", list.toArray());
AllZone.GameAction.shuffle(card.getController());
if(o != null)
{
//put card on top of library
library.remove(o);
library.add((Card)o, 0);
//lose 2 life
String player = Constant.Player.Human;
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
life.subtractLife(2);
}
}//if
}//resolve()
};
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
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 60 guests