Page 1 of 1

Implemented "Armored Ascension"

PostPosted: 17 Sep 2010, 10:20
by mullery
Hello,

I've added Armored Ascension to Forge, but I'm not able to commit my change (405 Method not allowed). I know that I should be able to commit because Dennis gave me the right but I don't know what I have to configure in eclipse to do so.

Anyway, someone could have a look at the code for the card :

//*************** START *********** START **************************
else if(cardName.equals("Armored Ascension")) {
final SpellAbility spell = new Spell(card) {

private static final long serialVersionUID = 3959966663907905001L;

@Override
public boolean canPlayAI() {
CardList list = new CardList(AllZone.Computer_Play.getCards());
list = list.getType("Creature");

if(list.isEmpty()) return false;

//else
CardListUtil.sortAttack(list);
CardListUtil.sortFlying(list);

for(int i = 0; i < list.size(); i++) {
if(CardFactoryUtil.canTarget(card, list.get(i))) {
setTargetCard(list.get(i));
return true;
}
}
return false;
}//canPlayAI()

@Override
public void resolve() {
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
/* Put the permanent into play*/
play.add(card);

/* Select the target of the enchantment */
Card c = getTargetCard();

/* Is it possible to target the card ? */
if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) {
/* The target is enchanted */
card.enchantCard(c);
System.out.println("Enchanted: " +getTargetCard());
}
}//resolve()
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);

Command onEnchant = new Command() {

private static final long serialVersionUID = -2365466450520529652L;

public void execute() {
String cardController = card.getController();
PlayerZone myField = AllZone.getZone(Constant.Zone.Play, cardController);
CardList someCards = new CardList();
someCards.addAll(myField.getCards());
int x = someCards.getType("Plains").size();
if(card.isEnchanting()) {
Card crd = card.getEnchanting().get(0);
crd.addSemiPermanentAttackBoost(x);
crd.addSemiPermanentDefenseBoost(x);
}
}//execute()
};//Command


Command onUnEnchant = new Command() {

private static final long serialVersionUID = 8144460293841806556L;

public void execute() {
String cardController = card.getController();
PlayerZone myField = AllZone.getZone(Constant.Zone.Play, cardController);
CardList someCards = new CardList();
someCards.addAll(myField.getCards());
int x = someCards.getType("Plains").size();
if(card.isEnchanting()) {
Card crd = card.getEnchanting().get(0);
crd.addSemiPermanentAttackBoost(-x);
crd.addSemiPermanentDefenseBoost(-x);
}
//if(card.isEnchanting()) {
// Card crd = card.getEnchanting().get(0);
// crd.addSemiPermanentAttackBoost(2);
// crd.addSemiPermanentDefenseBoost(1);
//}

}//execute()
};//Command

Command onLeavesPlay = new Command() {

private static final long serialVersionUID = -8235558710156197207L;

public void execute() {
if(card.isEnchanting()) {
Card crd = card.getEnchanting().get(0);
card.unEnchantCard(crd);
}
}
};

card.addEnchantCommand(onEnchant);
card.addUnEnchantCommand(onUnEnchant);
card.addLeavesPlayCommand(onLeavesPlay);

spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
}//*************** END ************ END **************************


Card.txt
Armored Ascension
3 W
Enchantment Aura
Enchanted creature gets +1/+1 for each Plains you control and has flying.
Enchant creature
enPump:Flying
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/armored_ascension.jpg

Re: Implemented "Armored Ascension"

PostPosted: 17 Sep 2010, 10:27
by Chris H.
mullery wrote:Hello,

I've added Armored Ascension to Forge, but I'm not able to commit my change (405 Method not allowed). I know that I should be able to commit because Dennis gave me the right but I don't know what I have to configure in eclipse to do so.
`
Check your settings and make sure that it looks like this:

https://cardforge.googlecode.com/svn
`
The "https" form is required. "http" will not allow you to make a commit. :wink:

Re: Implemented "Armored Ascension"

PostPosted: 17 Sep 2010, 10:29
by Sloth
Sorry if I'm wrong, but it looks to me, that the boost does not adapt, if the number of Plains controlled changes after the enchantment is attached.

I think you've chosen quite a hard card to code as your first.

Re: Implemented "Armored Ascension"

PostPosted: 17 Sep 2010, 10:34
by mullery
I thought it was automatic :)
Is there something like triggers in Forge which could help me a bit ?

Re: Implemented "Armored Ascension"

PostPosted: 17 Sep 2010, 11:32
by Rob Cashwalker
You will also be able to save some code by using the CardFactoryUtil.xCount method to do the counting of Plains.

You'll need to add some code to GameActionUtil to implement the part where its constantly counts Plains.

Re: Implemented "Armored Ascension"

PostPosted: 17 Sep 2010, 17:23
by mtgrares
Search for Glorious_Anthem in GameActionUtil for an example of +1/+1 effects. You will have to recount the number of Plains each time your code is called.

Basically cut and past the Glorious Anthem code in GameActionUtil so you have a new Command object. The Command object only has one method, execute(), so you have to stick all of your code inside execute().

Static effects like Glorious Anthem are harder to do that regular spells/abilities.