Skip to content

Items ~ Equipment ~ Design Document

aliu65803 edited this page May 17, 2022 · 20 revisions

Battle Items and Equipment Design Document

Currently our battle_item_t struct looks like this

typedef struct battle_item {

int id;

bool is_weapon;

int effectiveness_decrement;

int quantity;

int durability;

char* name;

char* description;

bool battle;

int attack;

int defense;

int hp;

struct battle_item *next;

struct battle_item *prev;

} battle_item_t;

Here are the changes we would like to make to this data type, as well as adding an equipment data type.

Here is the definition for the equipment_type enum, which will be used for the battle_equipment struct:

enum equipment_type{
    ACCESSORY,
    ARMOR,
    WEAPON
};

Here is the definition for the battle equipment struct:

typedef struct battle_equipment{
    int id; // the id of the equipment, should be unique for each individual type of equipment.
    char *name; // the name of the equipment
    char *description; // the description of the equipment
    stat_changes_t *attributes; // the stats that are changed by the equipment
    equipment_type type; // determines the type of equipment (armor, weapon, accessory)
} battle_equipment_t;

Here is the definition for the new combatant struct:

typedef struct combatant
{
    char *name;
    bool is_friendly;
    class_t *class_type;
    stat_t *stats;
    move_t *moves;
    battle_item_t *items;
    difficulty_t ai;
    battle_equipment_t *weapon;
    battle_equipment_t *accessory;
    battle_equipment_t *armor;
    struct combatant *next;
    struct combatant *prev;
} combatant_t;

Here is the definition for the new battle item struct (a consumable):

typedef struct battle_item{
    int id; // the id of the item, should be unique for each individual type of item.
    char *name; // the name of the item
    char *description; // the description of the item
    stat_changes_t *attributes; // the stats that are changed by the item
    int attack; // determines whether the item is used as an attack against the enemy, or as a defensive item for player
    struct battle_item *next; // the next battle item
    struct battle_item *prev; // the previous battle item
} battle_item_t;
Clone this wiki locally