Access for SVN checkins?
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
6 posts
• Page 1 of 1
Access for SVN checkins?
by 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:

Thanks again for the project and the chance to contribute.
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 **************************
- 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;
}
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?
by DennisBergkamp » 01 Aug 2010, 04:01
Welcome to the forums
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.
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.
-

DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Access for SVN checkins?
by 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.
- SaintWaldo
- Posts: 6
- Joined: 30 Jul 2010, 08:57
- Has thanked: 0 time
- Been thanked: 0 time
Re: Access for SVN checkins?
by Chris H. » 01 Aug 2010, 12:11
`SaintWaldo wrote:Happy testing, more to come, thanks again.
Thank you.
-

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?
by 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.
You could test for something like:
You could test for something like:
- Code: Select all
canPlayAI() {
return humanTokens < computerTokens && computerTokens.size() > 2;
}
-

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?
by 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.
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
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 39 guests