// ==> This file will deal with skillspoints
#include "../mud.h"
#include "../character.h"
#include "../account.h"
#include "../storage.h"
#include "../auxiliary.h"
#include "../handler.h"
#include "../socket.h"
#include "../utils.h"
#include "../save.h"
#include "../set_val/set_val.h"
#include "skillpoints.h"
/************************************************************************
* auxiliary data for skillpoints *
************************************************************************/
typedef struct skillpoints_data {
int skillpoints;
} SKILLPOINTS_DATA;
SKILLPOINTS_DATA *newSkillpointsData() {
SKILLPOINTS_DATA *data = malloc(sizeof(SKILLPOINTS_DATA));
data->skillpoints = 0;
return data;
}
void deleteSkillpointsData(SKILLPOINTS_DATA *data) {
free(data);
}
void skillpointsDataCopyTo(SKILLPOINTS_DATA *from, SKILLPOINTS_DATA *to) {
to->skillpoints = from->skillpoints;
}
SKILLPOINTS_DATA *skillpointsDataCopy(SKILLPOINTS_DATA *data) {
SKILLPOINTS_DATA *new_data = newSkillpointsData();
skillpointsDataCopyTo(data, new_data);
return new_data;
}
STORAGE_SET *skillpointsDataStore(SKILLPOINTS_DATA *data) {
STORAGE_SET *set = new_storage_set();
store_int(set, "skillpoints", data->skillpoints);
return set;
}
SKILLPOINTS_DATA *skillpointsDataRead(STORAGE_SET *set) {
SKILLPOINTS_DATA *data = newSkillpointsData();
data->skillpoints = read_int(set, "skillpoints");
return data;
}
int charGetSkillpoints(CHAR_DATA *ch)
{
SKILLPOINTS_DATA *data = charGetAuxiliaryData(ch, "skillpoints_aux_data");
return data->skillpoints;
}
void charSetSkillpoints(CHAR_DATA *ch, int new_skillpoints)
{
SKILLPOINTS_DATA *skillpointsdata = charGetAuxiliaryData(ch, "skillpoints_aux_data");
skillpointsdata->skillpoints = new_skillpoints;
return;
}
/************************************************************************
Below here are all of the init_ functions for this file.
*************************************************************************/
void init_skillpoints(void)
{
add_set("skillpoints", SET_CHAR, SET_TYPE_INT, charSetSkillpoints, NULL);
auxiliariesInstall("skillpoints_aux_data", newAuxiliaryFuncs(AUXILIARY_TYPE_CHAR, newSkillpointsData,
deleteSkillpointsData, skillpointsDataCopyTo, skillpointsDataCopy, skillpointsDataStore, skillpointsDataRead));
}