It is currently 26 Apr 2024, 04:09
   
Text Size

Auras and Equipment

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

Auras and Equipment

Postby mtgrares » 03 Jun 2009, 19:28

Dennis (the guy who is currently adding new cards) and Rob seem to know MTG Forge very well. This is my 2 cents about auras and equipment. It seems to me that you can basically implement them with "when this card comes into play" and "when this card leaves play". I played around with the Card class and the gui in order to make the attached card be next to the card it is attached to and add little arrows "<<" to the cards name. Since now we are showing the card picture, you could do the same thing by changing the card's text to show which card is it attached to, a hacky way of doing this could would be card.addKeyword("attached to " +card) which would show the card's name and unique number (which is important if there are multiple cards with the same name).

Also checkStateEffects() would have to see if all Aura's are attached to another card and if they aren't, put them into the graveyard. Obviously you wouldn't have to do this with equipment.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Auras and Equipment

Postby DennisBergkamp » 03 Jun 2009, 19:47

Yes, this is exactly how I did equipment. It seems to be working very well so far: I've been testing this a lot and haven't found any bugs :)

I've added a bunch of stuff to Card.java, basically to keep track of which cards are equipping what, and what cards are currently being equipped. I've also added (much like the comesIntoPlay() and destroy() commands) an equip() command and an unEquip() command. For each individual equipment card, the bonus gets set in the equip() command and the "reset" happens in the unEquip() command. For a card like Bonesplitter crd.addSemiPermanentAttackBoost(2); in equip(), and crd.addSemiPermanentAttackBoost(-2); in unEquip().
Anyway, equipment just screams to have some keywords to replace the hard-coded equipment cards I've made (a lot of copied code). Maybe once this is tested some more in the next Beta, Rob could help me create some keywords :mrgreen:

Then I made some small additions to checkStateEffects() in GameAction:
Code: Select all
Card c;
    Iterator<Card> it = creature.iterator();
    while(it.hasNext())
    {
      c = (Card)it.next();
     
      if (c.isEquipped())
      {
         for (int i=0;i < c.getEquippedBy().size(); i++)
         {
            Card equipment = c.getEquippedBy().get(i);
            if (!AllZone.GameAction.isCardInPlay(equipment))
            {
               equipment.unEquipCard(c);              
            }
         }
      }//if isEquipped()
     
      if(c.getNetDefense() <= c.getDamage() && !c.getKeyword().contains("Indestructible")){
        destroy(c);
        AllZone.Combat.removeFromCombat(c); //this is untested with instants and abilities but required for First Strike combat phase
      }
     
    }//while it.hasNext()
   
   
    //Make sure all equipment stops equipping previously equipped creatures that have left play.
    ArrayList<Card> equip = PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Equipment");
    equip.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Play, "Equipment"));
   
    Iterator<Card> iter = equip.iterator();
    while(iter.hasNext())
    {
       c = (Card)iter.next();
       if (c.isEquipping())
       {
          Card equippedCreature = c.getEquipping().get(0);
          if (!AllZone.GameAction.isCardInPlay(equippedCreature))
             c.unEquipCard(equippedCreature);
       }
    }//while iter.hasNext()
Which makes sure if equipped creature cards or equipping equipment cards leave play, an unEquip happens.

I still haven't made equipment and equipped creatures stack though, that's another thing. Not completely sure how to do this yet.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Auras and Equipment

Postby mtgrares » 03 Jun 2009, 20:28

Sounds good, you know MTG Forge very thoroughly now.

I still haven't made equipment and equipped creatures stack though, that's another thing. Not completely sure how to do this yet.
I haven't looked at the stacking code. Anything gui related is always complicated.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times


Return to Forge

Who is online

Users browsing this forum: No registered users and 209 guests


Who is online

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

Login Form