It is currently 18 Apr 2024, 16:00
   
Text Size

Eladamri's Call

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Eladamri's Call

Postby DennisBergkamp » 25 Sep 2008, 23:27

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 **************************
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Eladamri's Call

Postby jpb » 26 Sep 2008, 04:59

Should remove the System.out.println.
jpb
 
Posts: 132
Joined: 05 Sep 2008, 13:12
Has thanked: 0 time
Been thanked: 0 time

Re: Eladamri's Call

Postby 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?
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Eladamri's Call

Postby 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

Postby DennisBergkamp » 28 Sep 2008, 19:23

Ahh, I see it just ends up on the console. Very good to know, thanks :)
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time


Return to Forge

Who is online

Users browsing this forum: No registered users and 87 guests


Who is online

In total there are 87 users online :: 0 registered, 0 hidden and 87 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 87 guests

Login Form