Log in

API for Magic Coding in C

Args in all caps should use special constants as the arguments (see manalink.h for a list of constants)

Please leave subs in alphabetical order for easier scanning.

Card Status Functions


Game State Functions

  • int can_be_played_as_sorcery(int player)
  • count_graveyard(player)
  • has_mana(player, COLOR, amount)
  • has_mana_multi(player, colorless, black, blue, green, red, white)
  • has_threshold(player)
  • is_artifact_in_play() [unimplemented]


Cost Paying Functions

  • charge_mana(player, COLOR, amount)
  • charge_mana_multi(player, colorless, black, blue, green, red, white)
  • tap_card(player, card)


Targeting Functions It is recommended you use the targeting system instead of this sub.

  • target_player(player, card, event)


Abilities

  • void boost_creature_type(int player, int card, event_t event, creature_type_t type, int power, int toughness, int abilities, int flags);
  • check_legend_rule(player, card, event) [I think this should be renamed legendary, since the sub actually kills the legend]
  • void echo(int player, int card, event_t event, int colorless, int black, int blue, int green, int red, int white)
  • void fading(int player, int card, event_t event, int fading_number)
  • int basic_equipment(int player, int card, event_t event, int equip_cost)
  • void haste(int, int);
  • int hybrid_XX(int player, int card, event_t event, int hybrid, int colorless)
  • void indestructible(int player, int card, event_t event)
  • islandhome(player, card, event)
  • int lifelink(int, int, event_t);
  • int mana_producer(int player, int card, event_t event)
  • void vigilance(int player, int card);


Actions

  • add_one_mana_any_color(player)
  • int damage_creature(int target_controller, int target_card, int amount, int source_controller, int source_card)
  • int damage_creature_or_player(int player, int card, event_t event, int damage_amount, int ??? [use 3]);
  • void draw_a_card(int player)
  • void draw_cards(int player, int amount)
  • void discard(int player, int is_random, int unknown) [The last param appears to be unused]
  • gain_life(player, amount)
  • generate_token***(player, manalink.csv card id);
  • kill_card(player, card, KILL_METHOD)
  • produce_mana(player, COLOR, amount)

Random Stuff

  • affect_me(player, card)
  • int do_dialog(int player, int player2, int card, int unknown1, int unknown2, char *text, int AI_choice)




int get_attack_power(int player, int card)
Returns the actual attack power of a single creature. It's used to implement Doran, the Siege Tower power/toughness switching.

int get_counter_type_by_id(int id)
You need to define the appearance of the "special counters" that can be added on a specific card via "add_ccounter" in this function. Each single card is identified by its CSV ID. Available values range from 0 to 23

int get_id_by_name(const char * name)
A really useful function that return the CSV ID of a specific card from his name.

void obliterate_card(int player, int card)
Completely annihilate a card. It will NOT be added to the Removed From Game zone.

int duh_mode(int player)
Used for some cards that have in their original text abilities with options that noboy will normally use or that cannot be used in Manalink. If you activate the Duh Mode in the Settings, you won't be asked of making unnecessary choices for these cards.
For AI, duh_mode return always 1.

int zendikar(void)
Used to identify which version we're actually playing (Costructed, Limited or some other mods like Golden Years). It checks specific CSV IDs and it's mainly used to "shutdown" Challenge Mode when we're not playing Costructed version.

int custom(void)
Some as above, used to check if we're playing the Custom version.

int has_combat_damage_been_inflicted(int player, int card, event_t event)
Used for cards that do something when they deal combat damage to a player (Hypnotic Specter, Invasion's Dragons and so on).

int indestructible(int player, int card, event_t event)
Pretty self-explanatory, makes a permanent Indestructible.

void deathtouch(int player, int card, event_t event)
Gives to a creature the Deathtouch abilit. Since it uses the "info_slot", avoid using it for other purposes if you're coding a creature with Deathtouch.

void wither(int player, int card, event_t event)
Gives the Wither ability to a creature.

int get_cmc_by_id(int id)
Return the Converted Mana Cost of a card given its CSV ID. Useful for Tutoring functions.

int create_card_name_legacy(int player, int card, int id)
Creates a label on a permanent with the name of a card specified by its CSV ID. Useful for permanents with Imprint of for cards like Oblivion Ring. The function returns the Card ID of the label, so it coul be stored or removed at any time.

int reveal_top_card(int player, int card, event_t event)
Creates a label on a permanent that shows the name of the first card of its controller's deck. The function automatically changes it.