One day, Doc went coding...

Okay, today i finally got up and started getting into coding a few new cards, thinking "How hard can it be?", seeing how i can now do them in C.
I didn't want to start with cards without code because coding is what i do. So, while thinking about which card to do first, i stumbled upon the mtg.com preview card for today, the Fauna Shaman. Easy enough, it's just changing the code for Survival of the Fittest a little, right?
I was wrong. After i wrote the code, compiled it and added the card with Skymagic, everything seemed fine at first. The game doesn't crash, i can play the creature fine, the game recognized it as an elf etc. The problem is that i can't activate it, and i have no idea why. The code pointer points to the correct code as far as i know, and i can't really find an error in my code (and i really didn't change a lot).
Could anyone tell me what's wrong here?
Please help me
I didn't want to start with cards without code because coding is what i do. So, while thinking about which card to do first, i stumbled upon the mtg.com preview card for today, the Fauna Shaman. Easy enough, it's just changing the code for Survival of the Fittest a little, right?
I was wrong. After i wrote the code, compiled it and added the card with Skymagic, everything seemed fine at first. The game doesn't crash, i can play the creature fine, the game recognized it as an elf etc. The problem is that i can't activate it, and i have no idea why. The code pointer points to the correct code as far as i know, and i can't really find an error in my code (and i really didn't change a lot).
Could anyone tell me what's wrong here?
- Code: Select all
#include "manalink.h"
int card_fauna_shaman(int player, int card, event_t event)
{
target_definition_t td;
default_target_definition(player, card, &td, TYPE_CREATURE);
td.allowed_controller = player;
td.preferred_controller = player;
td.zone = TARGET_ZONE_HAND;
td.illegal_abilities = 0;
td.allow_cancel = 0;
if(event == EVENT_CAN_ACTIVATE)
{
if( has_mana( player, COLOR_GREEN, 1 ) && target_available(player, card, &td) && !is_tapped(player, card) && !is_sick(player, card))
{
return 1;
}
}
else if(event == EVENT_ACTIVATE)
{
charge_mana( player, COLOR_GREEN, 1);
tap_card(player, card);
if( spell_fizzled != 1 )
{
select_target(player, card, &td, "Discard a creature", NULL);
card_instance_t *instance= get_card_instance(player, card);
discard_card( player, instance->targets[0].card );
}
}
else if(event == EVENT_RESOLVE_ACTIVATION)
{
int selected = pick_card_from_deck(player);
if( selected != -1)
{
int *deck = deck_ptr[player];
if ( cards_data[ deck[selected] ].type & TYPE_CREATURE )
{
add_card_to_hand(player, deck[selected] );
remove_card_from_deck(player, selected);
hand_count[player]++;
}
}
shuffle(player);
}
return 0;
}
Please help me
