TheNegroShoddy
Member
I'm starting a card game project for a client and I need some advice on how I should go about storing the effects each card has. I'm currently storing info about each card in a 2D array.
Here is the current code:
Here is the current code:
Code:
/// init_card_info()
/*
Card Number | Subimage Number | Card Type | Name | Cost | Health | Armor | Attack | Description
*/
var array_width = 9; // Relative to how much info should be in each row
global.total_cards = 10; // Number relative to the amount of cards in the game
var val = 0; // The values to be added to the array
// -- Set default values --
for ( var nn = 0; nn < global.total_cards; nn++; )
{
for ( var ii = 0; ii < array_width; ii++; )
{
// Set the value to be stored in the array to either a card number or the value of noone (-4) to refer to a null or empty value.
if ii == 0 { val = ii; } else { val = noone; }
// Store default values in the array
global.card_info[ ii, nn ] = val;
}
}
// -- Add information for every card --
// Store info about each card within the global.card_info 2D array.
// Summons
add_card_info( 0, 1, 1, CARD_TYPE.CT_SUMMON, "Giant Turtle", 5, 10, 15, 1, "Giant Turtle test description." );
add_card_info( 1, 2, 2, CARD_TYPE.CT_SUMMON, "Frail Swordsman", 3, 5, 4, 4, "Frail Swordsman test description." );
add_card_info( 2, 3, 3, CARD_TYPE.CT_SUMMON, "Blue Ogre", 10, 15, 3, 10, "Blue Ogre test description." );
add_card_info( 3, 4, 4, CARD_TYPE.CT_SUMMON, "Flame Goblin", 8, 10, 4, 10, "Flame Goblin test description." );
add_card_info( 4, 5, 5, CARD_TYPE.CT_SUMMON, "Wild Dragon", 12, 15, 2, 10, "Wild Dragon test description." );
// Tools
add_card_info( 5, 6, 6, CARD_TYPE.CT_TOOL, "Wooden Sword", 2, noone, noone, noone, "Increase one unit's attack by three points." );
add_card_info( 6, 7, 7, CARD_TYPE.CT_TOOL, "Rusted Armor", 5, noone, noone, noone, "Increase one unit's armor by seven points." );
add_card_info( 7, 8, 8, CARD_TYPE.CT_TOOL, "Holy Water", 10, noone, noone, noone, "Increase one unit's health by five." );
add_card_info( 8, 9, 9, CARD_TYPE.CT_TOOL, "Degradation Cannon", 8, noone, noone, noone, "Decrease one unit's armor by six." );
add_card_info( 9, 10, 10, CARD_TYPE.CT_TOOL, "Golden Saber", 14, noone, noone, noone, "Increase one unit's attack by 20 points." );
// Events
add_card_info( 10, 11, 11, CARD_TYPE.CT_EVENT, "Sacrificial Restoration", 0, noone, noone, noone, "Sacrifice one summoned unit to restore five crystals." );
add_card_info( 11, 12, 12, CARD_TYPE.CT_EVENT, "Barrier", 3, noone, noone, noone, "Negates any damage inflicted to the user for one turn." );
add_card_info( 12, 13, 13, CARD_TYPE.CT_EVENT, "Quick Draw", 1, noone, noone, noone, "Draw two cards." );
add_card_info( 13, 14, 14, CARD_TYPE.CT_EVENT, "Earthquake", 10, noone, noone, noone, "Destroy all summoned units on the field." );
add_card_info( 14, 15, 15, CARD_TYPE.CT_EVENT, "Sleep Spell", 5, noone, noone, noone, "Select one summoned unit on your opponent's side of the field. That unit cannot attack for one turn." );
Code:
/// add_card_info( Array Coordinate, Card Number, Card Subimg, Card Type, Name, Cost, Health, Armor, Attack, Description )
var array_coord = argument0; // Second coordinate that will make up the position for specific info on each card
var card_num = argument1; // Number associated with the card. This could be used as a unique identifer (id) or for sorting purposes.
var card_subimg = argument2; // The subimage number of the card_img_spr sprite that relates to a specific card. 0 will always be the "backside" image of the card.
var card_type = argument3; // Indicates whether the card is a "Summon", "Tool" or "Event" card.
var name = argument4; // Name of the card
var cost = argument5; // How much it costs to use the card and the penalty for losing a summoned unit.
var hp = argument6; // Amount of health a Summon has. When it reaches 0, the card will be destroyed and the amount of crystals lost depends on the penalty (cost).
var armor = argument7; // Factored into the amount of damage taken from an opponent's attack. Opponent Attack - Armor = Damage
var attack = argument8; // The base damage a monster will deal while attacking
var desc = argument9; // Card description
global.card_info[ 0, array_coord ] = card_num;
global.card_info[ 1, array_coord ] = card_subimg;
global.card_info[ 2, array_coord ] = card_type;
global.card_info[ 3, array_coord ] = name;
global.card_info[ 4, array_coord ] = cost;
global.card_info[ 5, array_coord ] = hp;
global.card_info[ 6, array_coord ] = armor;
global.card_info[ 7, array_coord ] = attack;
global.card_info[ 8, array_coord ] = desc;