It is currently 09 Sep 2025, 04:45
   
Text Size

Some cards from Rize of the Eldrazi

Post MTG Forge Related Programming Questions Here

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

Some cards from Rize of the Eldrazi

Postby cyclope » 18 May 2010, 19:32

Hello , i think you could add this card from Rize of the Eldrazi:
Code: Select all
Cadaver Imp
In CardFactory_Creatures.java:
//*************** START *********** START **************************
        else if(cardName.equals("Cadaver Imp")) {
            final SpellAbility ability = new Ability(card, "0") {
                @Override
                public void resolve() {
                    PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
                    if(AllZone.GameAction.isCardInZone(getTargetCard(), grave)) {
                        PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
                        AllZone.GameAction.moveTo(hand, getTargetCard());
                    }
                }//resolve()
            };
            Command intoPlay = new Command() {
                private static final long serialVersionUID = -7433708170033536384L;
               
                public void execute() {
                    PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
                    CardList list = new CardList(grave.getCards());
                    list = list.getType("Creature");
                   
                    if(list.isEmpty()) return;
                   
                    if(card.getController().equals(Constant.Player.Human)) {
                        Object o = AllZone.Display.getChoiceOptional("Select target card", list.toArray());
                        if(o != null) {
                            ability.setTargetCard((Card) o);
                            AllZone.Stack.add(ability);
                        }
                    }//if
                    else//computer
                    {
                        Card best = CardFactoryUtil.AI_getBestCreature(list);
                        ability.setTargetCard(best);
                        AllZone.Stack.add(ability);
                    }
                }//execute()
            };//Command
            card.addComesIntoPlayCommand(intoPlay);
        }//*************** END ************ END **************************

in Cards.txt:
Cadaver Imp
1 B B
Creature Imp
When Cadaver Imp enters the battlefield, you may return target creature card from your graveyard to your hand.
1/1
Flying
it's the same as Gravedigger
cyclope
 
Posts: 69
Joined: 28 Sep 2009, 18:08
Has thanked: 0 time
Been thanked: 0 time

Re: Some cards from Rize of the Eldrazi

Postby DennisBergkamp » 18 May 2010, 19:38

Thanks, cyclope, we missed that one!

But, easier would be to code it like this (by just adding the OR cardName.equals("Cadaver Imp") to Gravedigger's code ) :

Code: Select all
 //*************** START *********** START **************************
        else if(cardName.equals("Gravedigger") || cardName.equals("Cadaver Imp")) {
            final SpellAbility ability = new Ability(card, "0") {
                @Override
                public void resolve() {
                    PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
                    if(AllZone.GameAction.isCardInZone(getTargetCard(), grave)) {
                      etc. etc.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Some cards from Rize of the Eldrazi

Postby cyclope » 18 May 2010, 19:44

Thanks Dennis.
I think you could add Mnemonic Wall .
It's similar to Gravedigger...
I think the line which should be changed is "list = list.getType("Creature");" but i don't know how to include the two words "Instant" and "Sorcery" in that sort of request...
cyclope
 
Posts: 69
Joined: 28 Sep 2009, 18:08
Has thanked: 0 time
Been thanked: 0 time

Re: Some cards from Rize of the Eldrazi

Postby DennisBergkamp » 18 May 2010, 19:47

Instead of "list = list.getType("Creature");" use a CardListFilter:

Code: Select all

list = list.filter(new CardListFilter() {
        public boolean addCard(Card crd)
        {
                return crd.isInstant() || crd.isSorcery();
        }
});

EDIT: forgot a few parentheses/braces.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Some cards from Rize of the Eldrazi

Postby Chris H. » 19 May 2010, 11:58

cyclope wrote:Thanks Dennis.
I think you could add Mnemonic Wall .
It's similar to Gravedigger...
I think the line which should be changed is "list = list.getType("Creature");" but i don't know how to include the two words "Instant" and "Sorcery" in that sort of request...
`
Hello, Cyclope. It is good to hear from you again. :D

We can add the Mnemonic Wall to the card object which contains Gravedigger and Cadaver Imp.

Code: Select all
        //*************** START *********** START **************************
        else if(cardName.equals("Gravedigger") || cardName.equals("Cadaver Imp") || cardName.equals("Mnemonic Wall")) {
            final SpellAbility ability = new Ability(card, "0") {
                @Override
                public void resolve() {
                    PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
                    if(AllZone.GameAction.isCardInZone(getTargetCard(), grave)) {
                        PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
                        AllZone.GameAction.moveTo(hand, getTargetCard());
                    }
                }//resolve()
            };
            Command intoPlay = new Command() {
                private static final long serialVersionUID = -7433708170033536384L;
               
                public void execute() {
                    PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
                    CardList list = new CardList(grave.getCards());
                   
                    list = list.filter(new CardListFilter() {
                        public boolean addCard(Card crd) {
                            return ((card.getName().equals("Gravedigger") || card.getName().equals("Cadaver Imp")) && crd.isCreature())
                                        ||
                                    (card.getName().equals("Mnemonic Wall") && (crd.isInstant() || crd.isSorcery()));
                        }
                    });
                    // list = list.getType("Creature");
                   
                    if(list.isEmpty()) return;
                   
                    if(card.getController().equals(Constant.Player.Human)) {
                        Object o = AllZone.Display.getChoiceOptional("Select target card", list.toArray());
                        if(o != null) {
                            ability.setTargetCard((Card) o);
                            AllZone.Stack.add(ability);
                        }
                    }//if
                    else//computer
                    {
                        Card best = card;
                        if (card.getName().equals("Gravedigger") || card.getName().equals("Cadaver Imp")) {
                            best = CardFactoryUtil.AI_getBestCreature(list);
                        } else {
                            // compy will select a random Instant or Sorcery
                            list.shuffle();
                            best = list.get(0);
                        }
                        ability.setTargetCard(best);
                        AllZone.Stack.add(ability);
                    }
                }//execute()
            };//Command
            card.addComesIntoPlayCommand(intoPlay);
        }//*************** END ************ END **************************
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Some cards from Rize of the Eldrazi

Postby cyclope » 19 May 2010, 17:03

Thanks Chris... I've been very busy ... but I have followed all that you have all done... You can be very proud of you all...
When I'll have more time , i'll try to help with "simple" things...

You give me the answer about how to programm the AI with Mnemonic Wall... Thanks...
cyclope
 
Posts: 69
Joined: 28 Sep 2009, 18:08
Has thanked: 0 time
Been thanked: 0 time

Re: Some cards from Rize of the Eldrazi

Postby Chris H. » 19 May 2010, 18:05

cyclope wrote:Thanks Chris... I've been very busy ... but I have followed all that you have all done... You can be very proud of you all...
When I'll have more time , i'll try to help with "simple" things...

You give me the answer about how to programm the AI with Mnemonic Wall... Thanks...
`
You are welcome.

There are several more cards that are similar and could be added with just a few lines of code placed in this card object. If you can find some free time you might want to try to add one or two of them. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Some cards from Rize of the Eldrazi

Postby cyclope » 19 May 2010, 19:08

When I 've looked to the code of Stoneforge Mystic , i 'm sure you could add Totem-Guide Hartebeest

Here is my code:
Code: Select all
In CardFactory_Creatures.java:
//*************** START *********** START **************************
else if(cardName.equals("Totem-Guide Hartebeest))
{
final SpellAbility ability = new Ability(card, "0") {
@Override
public void resolve() {
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
if(AllZone.GameAction.isCardInZone(getTargetCard(), lib)) {
Card c = getTargetCard();
AllZone.GameAction.shuffle(card.getController());
lib.remove(c);
hand.add(c);

}
}//resolve()
};
Command intoPlay = new Command() {

private static final long serialVersionUID = ;

public void execute() {
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
CardList cards = new CardList(lib.getCards());
CardList auras = new CardList();

for(int i = 0; i < cards.size(); i++) {
if(cards.get(i).getType().contains("Enchantement Aura")) {
auras.add(cards.get(i));
}
}

String controller = card.getController();

if(auras.size() == 0) return;

if(controller.equals(Constant.Player.Human)) {
Object o = AllZone.Display.getChoiceOptional("Select target card", auras.toArray());
if(o != null) {
ability.setTargetCard((Card) o);
AllZone.Stack.add(ability);
}
} else //computer
{
auras.shuffle();
ability.setTargetCard(arts.get(0));
AllZone.Stack.add(ability);
}

}//execute()
};//Command
card.addComesIntoPlayCommand(intoPlay);

}//*************** END ************ END **************************

in Cards.txt:
Totem-Guide Hartebeest
4 W
Creature Antelope
When Totem-Guard Hartbeest enters the battlefield, you may search your library for an Aura card, reveal it, put it into your hand, then shuffle your library.
2/5
Tell me if I've made some mistakes...
cyclope
 
Posts: 69
Joined: 28 Sep 2009, 18:08
Has thanked: 0 time
Been thanked: 0 time

Re: Some cards from Rize of the Eldrazi

Postby Chris H. » 22 May 2010, 22:49

When I 've looked to the code of Stoneforge Mystic , i 'm sure you could add Totem-Guide Hartebeest
Tell me if I've made some mistakes...
`
I found several small problems but they were easy to fix. :D I changed your code slighly and I will merge it into the SVN. Thank you for the code.


Code: Select all
        //*************** START *********** START **************************
        else if (cardName.equals("Totem-Guide Hartebeest")) {
           final SpellAbility ability = new Ability(card, "0") {

              @Override
              public void resolve() {
                 PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
                 PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
                 if (AllZone.GameAction.isCardInZone(getTargetCard(), lib)) {
                    Card c = getTargetCard();
                    AllZone.GameAction.shuffle(card.getController());
                    lib.remove(c);
                    hand.add(c);
                 }
              }//resolve()
           };//spell ability

           Command intoPlay = new Command() {
            private static final long serialVersionUID = -4230274815515610713L;

            public void execute() {
                 PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
                 CardList cards = new CardList(lib.getCards());
                 CardList auras = new CardList();

                 for (int i = 0; i < cards.size(); i++) {
                    if (cards.get(i).getType().contains("Enchantment") && cards.get(i).getType().contains("Aura")) {
                       auras.add(cards.get(i));
                    }
                 }

                 String controller = card.getController();

                 if(auras.size() == 0) return;

                 if (controller.equals(Constant.Player.Human)) {
                    Object o = AllZone.Display.getChoiceOptional("Select target card", auras.toArray());
                    if (o != null) {
                       ability.setTargetCard((Card) o);
                       AllZone.Stack.add(ability);
                    }
                 } else {    //computer   
                    auras.shuffle();
                    ability.setTargetCard(auras.get(0));
                    AllZone.Stack.add(ability);
                 }
              }//execute()
           };//Command
           
           card.addComesIntoPlayCommand(intoPlay);
        }//*************** END ************ END **************************
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 32 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 32 users online :: 0 registered, 0 hidden and 32 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 32 guests

Login Form