It is currently 19 May 2024, 15:56
   
Text Size

New keyword: spTutor

Post MTG Forge Related Programming Questions Here

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

New keyword: spTutor

Postby Sloth » 10 Sep 2010, 17:08

I've added a new keyword: spTutor

spTutor:<Target Restrictions>:<Destination>

<Target Restrictions>: takes all the restrictions of isValidCard.

<Destination>: Either Hand or TopOfLibrary

AI just takes a random card (That's sufficient for well designed combo decks).

Here's the Code:
Code: Select all
        // Generic Tutor cards
        if(hasKeyword(card, "spTutor") != -1) {
            int n = hasKeyword(card, "spTutor");
           
            String parse = card.getKeyword().get(n).toString();
            card.removeIntrinsicKeyword(parse);
           
            String k[] = parse.split(":");
            String Targets = k[1]; // Artifact, Creature, Enchantment, Land, Permanent, White, Blue, Black, Red, Green, Colorless, MultiColor
            // non-Artifact, non-Creature, non-Enchantment, non-Land, non-Permanent,
            //non-White, non-Blue, non-Black, non-Red, non-Green, non-Colorless, non-MultiColor
            final String Tgts[] = Targets.split(",");
                       
            final String Destination = k[2];
            card.clearSpellAbility();
           
            final SpellAbility spTtr = new Spell(card) {     
                private static final long serialVersionUID = 209109273165L;
               
                @Override
                public boolean canPlayAI() {
                    CardList list = AllZoneUtil.getPlayerCardsInLibrary(Constant.Player.Computer);
                    list = list.getValidCards(Tgts);
                     if (list.size() > 0) return true;
                    return false;
                }
               
               @Override
                public void resolve() {
                    String player = card.getController();
                    if(player.equals(Constant.Player.Human)) humanResolve();
                    else computerResolve();   
                }
               
                public void computerResolve() {
                    CardList list = AllZoneUtil.getPlayerCardsInLibrary(Constant.Player.Computer);
                    list = list.getValidCards(Tgts);
                                       
                    if(list.size() != 0) {
                        //comp will just grab the first one it finds
                        Card c = list.get(0);
                        AllZone.GameAction.shuffle(card.getController());
                        //move to hand
                        AllZone.Computer_Library.remove(c);
                        if (Destination == "Hand") AllZone.Computer_Hand.add(c);
                        else if (Destination == "TopOfLibrary") AllZone.Computer_Library.add(c, 0);
                       
                        CardList l = new CardList();
                        l.add(c);
                        AllZone.Display.getChoiceOptional("Computer picked:", l.toArray());
                    }
                }//computerResolve()
               
                public void humanResolve() {
                    CardList list = AllZoneUtil.getPlayerCardsInLibrary(Constant.Player.Human);
                    list = list.getValidCards(Tgts);
                   
                    if(list.size() != 0) {
                        Object o = AllZone.Display.getChoiceOptional("Select a card", list.toArray());
                       
                        AllZone.GameAction.shuffle(card.getController());
                        if(o != null) {
                            //put card in hand
                           AllZone.Human_Library.remove(o);
                           if (Destination.equals("Hand")) AllZone.Human_Hand.add((Card) o);
                            else if (Destination.equals("TopOfLibrary")) AllZone.Human_Library.add((Card) o, 0);
                        }
                    }//if
                }//resolve()
            }; // spell ability SpTutorTgt
           
            spTtr.setDescription(card.getSpellText());
            card.setText("");
            card.addSpellAbility(spTtr);
        }//spTutor
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: spTutor

Postby Rob Cashwalker » 10 Sep 2010, 21:07

Sloth,

It might help to post at least a few sample cards for the keywords you've posted.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: New keyword: spTutor

Postby Sloth » 10 Sep 2010, 21:25

Good idea Rob!

Samples:
Code: Select all
Personal Tutor
U
Sorcery
Search your library for a sorcery card and reveal that card. Shuffle your library, then put the card on top of it.
spTutor:Sorcery:TopOfLibrary

Idyllic Tutor
2 W
Sorcery
Search your library for an enchantment card, reveal it, and put it into your hand. Then shuffle your library.
spTutor:Enchantment:Hand
SVar:RemAIDeck:True

Merchant Scroll
1 U
Sorcery
Search your library for a blue instant card, reveal that card, and put it into your hand. Then shuffle your library.
spTutor:Instant.Blue:Hand

Safewright Quest
GW
Sorcery
Search your library for a Forest or Plains card, reveal it, and put it into your hand. Then shuffle your library.
spTutor:Forest,Plains:Hand
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 17 guests


Who is online

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

Login Form