Page 1 of 1

More tutor cards

PostPosted: 30 Jun 2009, 13:33
by Sloth
I would like to help to add a few more tutor cards to the game. First of all Imperial Seal and Sylvan Tutor can be added quite easily by adding this to card.txt:

Code: Select all
Sylvan Tutor
G
Sorcery
Search your library for a creature card and reveal that card. Shuffle your library, then put the revealed card back on top of it.

Imperial Seal
B
Sorcery
Search your library for a card, then shuffle your library and put that card on top of it. You lose 2 life.
and replacing 2 lines in cardfactory with the following lines:

Code: Select all
if(cardName.equals("Vampiric Tutor") || cardName.equals("Cruel Tutor") || cardName.equals("Imperial Seal"))
Code: Select all
if(cardName.equals("Worldly Tutor") || cardName.equals("Sylvan Tutor"))
The next one is:

Code: Select all
Grim Tutor
1 B B
Sorcery
Search your library for a card and put that card into your hand. Then shuffle your library. You lose 3 life.
together with this replacement:
Code: Select all
//*************** START *********** START **************************
    if(cardName.equals("Demonic Tutor") || cardName.equals("Diabolic Tutor") || cardName.equals("Grim Tutor"))
    {
      final SpellAbility spell = new Spell(card)
      {
      private static final long serialVersionUID = 1481169060428051519L;
      
      public void resolve()
        {
          String player = card.getController();
          if(player.equals(Constant.Player.Human))
            humanResolve();
          else
            computerResolve();
        }
        public void humanResolve()
        {
          Object check = AllZone.Display.getChoiceOptional("Select card", AllZone.Human_Library.getCards());
          if(check != null)
          {
            PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
            AllZone.GameAction.moveTo(hand, (Card)check);
          }
          AllZone.GameAction.shuffle(Constant.Player.Human);
         
          //lose 3 life
          if(cardName.equals("Grim Tutor"))
          {    
           String player = Constant.Player.Human;
           PlayerLife life = AllZone.GameAction.getPlayerLife(player);
           life.subtractLife(3);
          }
        }
        public void computerResolve()
        {
          Card[] library = AllZone.Computer_Library.getCards();
          CardList list = new CardList(library);

          //pick best creature
          Card c = CardFactoryUtil.AI_getBestCreature(list);
          if(c == null)
            c = library[0];
          //System.out.println("comptuer picked - " +c);
          AllZone.Computer_Library.remove(c);
          AllZone.Computer_Hand.add(c);
         
          //lose 3 life
          if(cardName.equals("Grim Tutor"))
          {   
           String player = Constant.Player.Computer;
           PlayerLife life = AllZone.GameAction.getPlayerLife(player);
           life.subtractLife(3);
          }
        }
        public boolean canPlay()
        {
          PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
         
          return library.getCards().length != 0 && AllZone.Phase.getActivePlayer().equals(card.getController())
          && !AllZone.Phase.getPhase().equals("End of Turn");
        }
        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 **************************
Another thing I found interesting is that Demonic tutor & co use CardFactoryUtil.AI_getBestCreature(list) to pick a card, while the other tutors do not. I haven't looked into this function but it seems to be useable by Worldly tutor (and Sylvan tutor) too, so I would suggest to replace:
Code: Select all
Card c = creature.get(0);
with
Code: Select all
Card c = CardFactoryUtil.AI_getBestCreature(creature);
As long as it won't cause any errors, the selection can only improve.

Re: More tutor cards

PostPosted: 30 Jun 2009, 16:24
by mtgrares
Well I programmed both Demonic Tutor and Worldly Tutor, ha. Sometimes you have one idea and another times you have another one. Some of CardFactory is a little random, like using different colored crayons, lol.

Thanks for the code.