It is currently 16 Apr 2024, 10:22
   
Text Size

BW spells

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

BW spells

Postby DennisBergkamp » 24 Sep 2008, 22:41

In this topic I will add some black / white multicolored spells.

I'll start with Gerrard's Verdict:
I found it's impossible to have the computer discard any land cards (without setting the bool smoothManaCurve to false, thanks JPB!). But the AI can use this spell on you, and will gain 3 life per land card you discard.

In cards.txt:

Code: Select all
Gerrard's Verdict
W B
Sorcery
Target player discards two cards. You gain 3 life for each land card discarded this way.
Then, in CardFactory.java:

Code: Select all
 //*************** START *********** START **************************
    if(cardName.equals("Gerrard's Verdict"))
    {
      SpellAbility spell = new Spell(card)
      {
        
       public boolean canPlayAI()
       {
          PlayerZone humanHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human);
          if (humanHand.size() >= 2)
             return true;
          else
             return false;
       }
        
       public void resolve()
        {
          String player = card.getController();
          if(player.equals(Constant.Player.Human))
            humanResolve();
          else
            computerResolve();
        }
        public void humanResolve()
        {
          PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
          CardList list = new CardList(hand.getCards());
          list.shuffle();
         
          if (list.size()== 0)
             return;
         
          Card c1 = list.get(0);
          list.remove(c1);
          AllZone.Computer_Graveyard.add(c1);
          AllZone.Computer_Hand.remove(c1);         
         
          if (list.size()== 0)
             return;
         
          Card c2 = list.get(0);
          list.remove(c2);
          AllZone.Computer_Graveyard.add(c2);
          AllZone.Computer_Hand.remove(c2);   
         
          if (c1.getType().contains("Land")) {
             PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Human);
             life.addLife(3);
          }
         
          if (c2.getType().contains("Land")) {
             PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Human);
             life.addLife(3);
          }         
         

        }//resolve()
        public void computerResolve()
        {
           PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human);
           PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, Constant.Player.Human);
            CardList list = new CardList(hand.getCards());
           
            Object o = AllZone.Display.getChoiceOptional("First card to discard", list.toArray());
           
            Card c = (Card)o;
            list.remove(c);

            hand.remove(c);
            grave.add(c);
            
            if(c.getType().contains("Land")) {
               PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
               life.addLife(3);
            }
            
            Object o2 = AllZone.Display.getChoiceOptional("Second card to discard", list.toArray());
           
            Card c2 = (Card)o2;
            list.remove(c2);

            hand.remove(c2);
            grave.add(c2);
            
            if(c2.getType().contains("Land")) {
               PlayerLife life = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
               life.addLife(3);
            }
           
           
        }
      };
      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: BW spells

Postby DennisBergkamp » 26 Sep 2008, 21:18

Now for a simple, yet really powerful spell: Vindicate:

cards.txt:

Code: Select all
Vindicate
1 W B
Sorcery
Destroy target permanent.
In CardFactory.java:

Code: Select all
//*************** START *********** START **************************
    if(cardName.equals("Vindicate"))
    {
      final SpellAbility spell = new Spell(card)
      {
        public boolean canPlayAI()
        {
          CardList human = CardFactoryUtil.AI_getHumanCreature();
          return 4 < AllZone.Phase.getTurn() && 0 < human.size();
        }
        public void chooseTargetAI()
        {
          CardList human = CardFactoryUtil.AI_getHumanCreature();
          setTargetCard(CardFactoryUtil.AI_getBestCreature(human));
        }

        public void resolve()
        {
          if(AllZone.GameAction.isCardInPlay(getTargetCard()))
          {
            if(getTargetCard().isToken())
              AllZone.getZone(getTargetCard()).remove(getTargetCard());
            else
            {
              PlayerZone graveyard = AllZone.getZone(Constant.Zone.Graveyard, getTargetCard().getOwner());
              AllZone.GameAction.moveTo(graveyard, getTargetCard());
            }
          }//if
        }//resolve()
      };//SpellAbility
      Input target = new Input()
      {
        public void showMessage()
        {
          AllZone.Display.showMessage("Select target permanent for " +spell.getSourceCard());
          ButtonUtil.enableOnlyCancel();
        }
        public void selectButtonCancel() {stop();}
        public void selectCard(Card card, PlayerZone zone)
        {
          if(zone.is(Constant.Zone.Play))
          {
            spell.setTargetCard(card);
            stopSetNext(new Input_PayManaCost(spell));
          }
        }
      };//Input

      spell.setBeforePayMana(target);
      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: BW spells

Postby Rob Cashwalker » 27 Sep 2008, 03:39

One of my methods in coding cards, is finding common code amongst cards. I think "Destroy target _______" might be one of them.

Keyword possibility-

DestroyTarget:Land
DestroyTarget:Artifact
DestroyTarget:Creature

DestroyTarget is the keyword, and the targeting restriction is the parameter. Put DestroyTarget:Artifact and DestroyTarget:Land on a single sorcery spell, and MTGForge will display the choice between the two actions, which is functionally the same, but easier to code than DestroyTarget:ArtifactOrLand. (Demolish)

I have to think about how to handle the more complex Terror - there are other spells with the no-regen clause, but not necessarily the non-black part. Pillage is artifact or land, and no-regen.... And there's Ghostly Visit, which just non-black. So there might be some difficulties along the way. on a preliminary search, there are roughly 450 cards that say "destroy target ______"
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: BW spells

Postby GandoTheBard » 27 Sep 2008, 14:26

Fumerole has two nonmodal effects DestroyTarget: Creature, AND DestroyTarget: Land. If I remember correctly.

Also for terror there are a number of clones (Dark Banishing, Expunge come to mind). As far non=color There are some white cards that say Non-white. Fear in various cards works different for the different colors (ie: insert color word).
visit my personal homepage here: http://outofthebrokensky.com

Listen to my podcast with famed AJ_Impy "Freed from the Real" on http://puremtgo.com
User avatar
GandoTheBard
Tester
 
Posts: 1043
Joined: 06 Sep 2008, 18:43
Has thanked: 0 time
Been thanked: 0 time

Re: BW spells

Postby DennisBergkamp » 30 Sep 2008, 16:05

Another BW card, Culling Sun.
Not the most useful card, Pyroclasm often does a better job.

cards.txt:

Code: Select all
Culling Sun
2 W W B
Sorcery
Destroy each creature with converted manacost 3 or less.
CardFactory.java:

Code: Select all
//*************** START *********** START **************************
    if(cardName.equals("Culling Sun"))
    {
     SpellAbility spell = new Spell(card)
    {
    public void resolve()
    {
    CardList all = new CardList();
    all.addAll(AllZone.Human_Play.getCards());
    all.addAll(AllZone.Computer_Play.getCards());

    for(int i = 0; i < all.size(); i++)
    {
      Card c = all.get(i);
      int convertedManaCost = CardUtil.getConvertedManaCost(c.getManaCost());
      if(c.isCreature() && (convertedManaCost <= 3))
        AllZone.GameAction.destroy(c);
    }
    }//resolve()
    public boolean canPlayAI()
    {
    CardList human    = new CardList(AllZone.Human_Play.getCards());
    CardList computer = new CardList(AllZone.Computer_Play.getCards());

    human    = human.getType("Creature");
    computer = computer.getType("Creature");

    //the computer will at least destroy 2 more human creatures
    return computer.size() < human.size()-1  || (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
    }
    };//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


Return to Forge

Who is online

Users browsing this forum: No registered users and 56 guests


Who is online

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

Login Form