Intuition
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Intuition
by DennisBergkamp » 04 Nov 2008, 16:27
I've been too busy with real life things lately to add more cards, but I figured I'd post a card I made awhile ago: Intuition.
AI code is untested for now.
CardFactory:
AI code is untested for now.
CardFactory:
- Code: Select all
//*************** START *********** START **************************
if(cardName.equals("Intuition"))
{
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 libraryList = new CardList(AllZone.Human_Library.getCards());
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
CardList selectedCards = new CardList();
Object o = AllZone.Display.getChoiceOptional("Select first card", libraryList.toArray());
if(o != null)
{
Card c1 = (Card)o;
libraryList.remove(c1);
selectedCards.add(c1);
}
else {
return;
}
o = AllZone.Display.getChoiceOptional("Select second card", libraryList.toArray());
if(o != null)
{
Card c2 = (Card)o;
libraryList.remove(c2);
selectedCards.add(c2);
}
else {
return;
}
o = AllZone.Display.getChoiceOptional("Select third card", libraryList.toArray());
if(o != null)
{
Card c3 = (Card)o;
libraryList.remove(c3);
selectedCards.add(c3);
}
else {
return;
}
Card choice = selectedCards.get(MyRandom.random.nextInt(2)); //comp randomly selects one of the three cards
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
library.remove(choice);
hand.add(choice);
selectedCards.remove(choice);
Card toGrave1 = selectedCards.get(0);
Card toGrave2 = selectedCards.get(1);
library.remove(toGrave1);
library.remove(toGrave2);
selectedCards.remove(toGrave2);
selectedCards.remove(toGrave2);
grave.add(toGrave1);
grave.add(toGrave2);
AllZone.GameAction.shuffle(Constant.Player.Human);
}
public void computerResolve()
{
Card[] library = AllZone.Computer_Library.getCards();
CardList list = new CardList(library);
CardList selectedCards = new CardList();
//pick best creature
Card c = CardFactoryUtil.AI_getBestCreature(list);
if(c == null) {
c = library[0];
}
list.remove(c);
selectedCards.add(c);
c = CardFactoryUtil.AI_getBestCreature(list);
if(c == null) {
c = library[0];
}
list.remove(c);
selectedCards.add(c);
c = CardFactoryUtil.AI_getBestCreature(list);
if(c == null) {
c = library[0];
}
list.remove(c);
selectedCards.add(c);
Object o = AllZone.Display.getChoiceOptional("Select card to give to computer", selectedCards.toArray());
Card choice = (Card)o;
AllZone.Computer_Library.remove(choice);
AllZone.Computer_Hand.add(choice);
}
public boolean canPlay()
{
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
return library.getCards().length >= 3;
}
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 **************************
- Code: Select all
Intuition
2 U
Instant
Search your library for any three cards and reveal them. An opponent chooses one. Put that card into your hand and the rest into your graveyard. Then shuffle your library.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 86 guests