It is currently 28 Oct 2025, 12:46
   
Text Size

Access for SVN checkins?

Post MTG Forge Related Programming Questions Here

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

Access for SVN checkins?

Postby SaintWaldo » 01 Aug 2010, 03:08

Howdy, all!

I've just finished implementing my first card. I've tested it, and it seems to be working in my deck. The card is Parallel Evolution, something every self respecting squirrels deck demands.

Let me give some implementation details to demonstrate I know WTF I'm up to:

1. I added a "no text" stub with the basic cost and card type to "cards.txt"

2. Once I saw the card was parsed into the library, I found the portion of CardFactory that had the squirrel summon cards (just my favorite tokens, there may be a better place), and whipped up the following:

Code: Select all
//*************** START *********** START **************************
        else if(cardName.equals("Parallel Evolution")) {
            SpellAbility spell = new Spell(card) {
               
                private static final long serialVersionUID = 3456160935845779623L;
               
                @Override
                public void resolve() {
               
               // for each play zone add a copy of each creature token card
               CardList creature = new CardList();
               creature.addAll(AllZone.Human_Play.getCards());
               creature.addAll(AllZone.Computer_Play.getCards());
               
               creature = creature.getType("Creature");
               
               creature = creature.filter(new CardListFilter()
                  {
                     public boolean addCard(Card crd)
                     {
                        return crd.isToken();
                     }
                  });
               
               CardFactoryUtil.copyTokens(creature);
            
            }
            };
           
            spell.setDescription("For each creature token on the battlefield, its controller puts a token that's a copy of that creature onto the battlefield.");
            spell.setStackDescription("For each creature token on the battlefield, its controller puts a token that's a copy of that creature onto the battlefield.");
           
            card.setFlashback(true);
            card.clearSpellAbility();
            card.addSpellAbility(spell);
            card.addSpellAbility(CardFactoryUtil.ability_Flashback(card, "4 G G G", "0"));
           
        }
//*************** END ************ END **************************
3. If you look near the end of the resolve() function, you'll see a call to CardFactoryUtil.copyTokens that takes a CardList. This is where the actual calls to makeToken happen, just in case someone else has card text that copies a list of tokens of arbitrary type. The function looks like this:
Code: Select all
   
    public static CardList copyTokens(CardList tokenList)
    {
       CardList list = new CardList();
       
       for(int tokenAdd = 0; tokenAdd < tokenList.size(); tokenAdd++){
         Card thisToken = tokenList.getCard(tokenAdd);
         
         ArrayList<String> tal = thisToken.getType();
         String tokenTypes [] = new String [tal.size ()];
         tal.toArray (tokenTypes);

         ArrayList<String> kal = thisToken.getIntrinsicKeyword();
         String tokenKeywords [] = new String [kal.size ()];
         kal.toArray(tokenKeywords);
         
         list.add(makeToken(thisToken.getName(), thisToken.getImageName(), thisToken.getController(), thisToken.getManaCost(), tokenTypes, thisToken.getBaseAttack(), thisToken.getBaseDefense(), tokenKeywords));      
      }
       
       return list;
    }
So, assuming the above is up to snuff for forge, my question is, do I need special credentials to do SVN commits? Should I be submitting changes to someone else for placement in the repo? Basically, what are the SVN rules and the process for sharing code back to the community? I have a bunch of cards I'm itching to add now that I've figured this out, and I'd hate to hog all the sweet, sweet Odyssey block craziness I have planned to myself. ;)

Thanks again for the project and the chance to contribute.
SaintWaldo
 
Posts: 6
Joined: 30 Jul 2010, 08:57
Has thanked: 0 time
Been thanked: 0 time

Re: Access for SVN checkins?

Postby DennisBergkamp » 01 Aug 2010, 04:01

Welcome to the forums :mrgreen:
All you need is a gmail address (or an email address associated with a google account). PM me the address, and I'll give you committer access.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Access for SVN checkins?

Postby SaintWaldo » 01 Aug 2010, 11:41

Well, this sure felt good:

Code: Select all
commit -m "Added card Parallel Evolution. ..." ./ForgeSVN/res/cards.txt ./ForgeSVN/src/forge/CardFactory.java ./ForgeSVN/src/forge/CardFactoryUtil.java
    Sending        ./ForgeSVN/res/cards.txt
    Sending        ./ForgeSVN/src/forge/CardFactory.java
    Sending        ./ForgeSVN/src/forge/CardFactoryUtil.java
    Transmitting file data ...
    Committed revision 1601.
update ./ForgeSVN -r HEAD --force
    At revision 1601.
Happy testing, more to come, thanks again. :)
SaintWaldo
 
Posts: 6
Joined: 30 Jul 2010, 08:57
Has thanked: 0 time
Been thanked: 0 time

Re: Access for SVN checkins?

Postby Chris H. » 01 Aug 2010, 12:11

SaintWaldo wrote:Happy testing, more to come, thanks again. :)
`
Thank you. 8)
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: Access for SVN checkins?

Postby Chris H. » 01 Aug 2010, 21:24

If you get a chance you might want to consider adding a canPlayAI() method. Otherwise, the computer will cast this spell if it has enough mana to pay the cost. :D

You could test for something like:

Code: Select all
canPlayAI() {
    return humanTokens < computerTokens && computerTokens.size() > 2;
}
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: Access for SVN checkins?

Postby SaintWaldo » 01 Aug 2010, 21:51

Yeah, learning to walk and all. ;)

That's good looking out; your rule seems reasonable, though I'd still pop it if I had a Glorious Anthem/Coat of Arms advantage. Power/toughness should be in the math as well, I'd think...

See, this is why I left the AI stuff to the side until I get this next card implemented, lol.

I'll put that in ASAP, possibly with my twists.
SaintWaldo
 
Posts: 6
Joined: 30 Jul 2010, 08:57
Has thanked: 0 time
Been thanked: 0 time


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 39 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 39 users online :: 0 registered, 0 hidden and 39 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 39 guests

Login Form