It is currently 24 Apr 2024, 14:26
   
Text Size

More tutor cards

Post MTG Forge Related Programming Questions Here

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

More tutor cards

Postby Sloth » 30 Jun 2009, 13:33

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: More tutor cards

Postby mtgrares » 30 Jun 2009, 16:24

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.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 37 guests


Who is online

In total there are 37 users online :: 0 registered, 0 hidden and 37 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 37 guests

Login Form