Page 1 of 1

Eladamri's Call

PostPosted: 25 Sep 2008, 23:27
by DennisBergkamp
I haven't really tested this with the AI yet, but I think it should work?

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.
CardFactory.Java:

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 **************************

Re: Eladamri's Call

PostPosted: 26 Sep 2008, 04:59
by jpb
Should remove the System.out.println.

Re: Eladamri's Call

PostPosted: 26 Sep 2008, 20:14
by DennisBergkamp
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?

Re: Eladamri's Call

PostPosted: 27 Sep 2008, 03:13
by jpb
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").

Re: Eladamri's Call

PostPosted: 28 Sep 2008, 19:23
by DennisBergkamp
Ahh, I see it just ends up on the console. Very good to know, thanks :)