Battles ~ Current Battle Structs 2022 - uchicago-cs/chiventure GitHub Wiki
Relevant Structs in Other Modules Related To Battle
We are identifying which data structures that are related to the battle class. We have located where they are and provided a short description of what they are and how we might be able to integrate our data structures with them.
Data Structures in Game State
game.h
game_t struct
This struct contains all the information you need to work on the game. It has a hash table consisting of all the items that we can use, which includes battle items that can help out in battles. It has a pointer to a current player struct, or the person who will be battling, and we can use this information when starting the battles. There’s a pointer to a global stats hashtable which we can use to extract the stats of others besides the player. Also, there’s a pointer to a hashtable of effects, which is an important part of battles because of status effects. This simply stores all the information we need in order to make the battle module function, and if we are looking to implement new and big features, we might have to modify this struct, or at least the ones it contains, in order to accommodate for this.
player.h
player_t/player_hash_t
This is the player within the game. The relevant fields they have include the player’s stats(hash table), combat skills(skill_inventory_t), non combat skills(skill_inventory_t), and an inventory (hash table of items). Currently it does not store the player’s moves. Could this be what the combat skills are? We need to change this struct and make it so that it has a way of store the players moves. Additionally the stats of a player are stored in a hash table, so when a player enters a battle, there must be a way to extract these values from the hashtable and translate it to stats in combat. We also need to find or create the conversion from the inventory into our battle_item data types.
stats.h
There are a lot of structs that have different purposes all dedicated to stats. One thing that stands out is that everything is in a hash table form.
stats_global_t/stats_global_hash_t
Makes up a hash table that keeps track of all stats available in the game. Also keeps track of all the values in the game. If we want to implement more stats, we must make sure that this global stat struct can be able to deal with other stats. Currently uses a string to store the name for the stat.
stats_t/stats_hash_t
Represents a singular stat of a player. Has a maximum value, a current value, and a modifier attached to it. Unlike the stat_t data type in Battles, this is a singular data type, almost as if it is used to make stats. In order to make this aligned, we could make a battle_stats struct instead that is dedicated for stats for battling.
stat_mod_t
Represents a modification to a stat. Has a duration as well as a pointer to the stat that it is affecting. Seems like it is similar to our stat_changes struct except it is specified to a singular stat and seems to be a linked list. Our implementations seem to be very different from one another and we will need to take time to consider how we should deal with this conflict.
item.h
item_t
A generic item struct item_t is declared. A battle item should be a subvariant of this generic item, so we need to either figure out an implementation that either pulls directly from item_t (rather than our battle struct) or that translates a generic item to a battle item (along with resolving complications that would arise from translating back).
npc_battle.h
npc_battle_t
This struct contains information used for battles with non-player characters. It consists of pointers to a stat struct and moves struct, difficulty level of ai, hostility level of the character, and the health level when the character will surrender. It also has the NPC health level, which might not be necessary considering there’s a pointer to a stat struct, which has this information in the struct. A lot of these elements could be replaced with a combatant struct as it has most of these elements in the structure.