%% ---------------------------------------------------------------------------
%% @doc 星辰系统头文件.
%% @author zmh
%% @since  20200816
%% ---------------------------------------------------------------------------


%%相关数据
-define(SQL_GALAXY_GET, <<"SELECT `pos_list`,`skin`,`display`,`refresh_time`,`refresh_times`,`item_list` FROM `role_galaxy` WHERE `rid` = ~p">>).
-define(SQL_GALAXY_SAVE, <<"REPLACE INTO `role_galaxy` (`rid`,`pos_list`,`skin`,`display`,`refresh_time`,`refresh_times`,`item_list`) VALUES ( ~p, '~ts',~p, ~p,~p,~p,'~ts')">>).
-define(SQL_GALAXY_SKIN_GET, <<"SELECT `skin`,`star` FROM `role_galaxy_skin` WHERE `rid` = ~p">>).
-define(SQL_GALAXY_SKIN_REPLACE, <<"REPLACE INTO role_galaxy_skin (`rid`, `skin`, `star`) VALUES (~p, ~p, ~p)">>).
-define(SQL_GALAXY_SKIN_UPDATE, <<"UPDATE `role_galaxy` SET `skin`= ~p WHERE `rid` = ~p">>).
-define(SQL_GALAXY_COLLECT_GET, <<"SELECT `type`,`subtype`,`gain`,`state` FROM `player_galaxy` WHERE `rid`=~p ">>).
-define(SQL_GALAXY_COLLECT_REPLACE, <<"REPLACE INTO `player_galaxy` (`rid`,`type`,`subtype`,`gain`,`state`) VALUES (~p, ~p, ~p,'~ts',~p)">>).
-define(SQL_GALAXY_DISPLAY_UPDATE,  <<"UPDATE `role_galaxy` SET `display`= ~p WHERE `rid` = ~p">>).

-define(POS_OPEN, 1). %% 星辰上阵槽位已开
-define(POS_NOT_OPEN, 0). %% 星辰上阵槽位没开

-define(MAIN_GALAXY,  0). %% 阵位星辰
-define(MINOR_GALAXY, 1). %% 星位星辰

%% 星辰系统数据
-record(role_galaxy, {
    power       = 0
    ,attrs      = []             %% 星辰属性汇总
    ,skill_list = []             %% 技能列表[{SkillId, Lev}]
    ,skin_skills= []
    ,pos_list   = []             %% 槽位开启信息

    ,work_galaxy = []            %% 运转中的星辰 整理好给figure
    ,display  = 0                %% 幻化星辰(星辰自身显化状态1显)
    ,skin = 0                    %% 幻化皮肤

    ,skin_list = []             %% 皮肤列表[#galaxy_skin{}]
    ,skin_attr = []             %% 已激活皮肤属性列表

    ,collects  = []             %% 收集

    %% -------------------------下面字段是市场相关数据
    ,refresh_time = 0           %% 刷新时间戳
    ,refresh_times = 0          %% 刷新次数
    ,item_list = []             %% 市场物品列表[#fs_item{}]
    ,save_items = 0             %% 下线市场物品列表是否需要保存到数据库:1需要0不需要
}).



%% 星辰配置
-record(base_galaxy, {
    id = 0                      %% Id
    ,type = 0                   %% 星群
    ,subtype = 0                %% 星团
    ,color = 0                  %% 品质
    ,attrs =  []                %% 属性列表
    ,skill = 0                  %% 固定天赋技能
    ,rand_skills = []           %% 随机天赋技能
    ,skill_max = 0              %% 随机天赋技能数量
    ,resolve = []               %% 分解回收返还材料
}).


%% 星辰等级配置
-record(base_galaxy_lv, {
    color = 0                   %% 品质
    ,lv = 0                     %% 等级
    ,cost = []                  %% 升级消耗
    ,attrs = []                 %% 属性
    ,broken= 0                   %% 是否突破
    ,next_lv = 0                %% 下一级
}).

%% 星辰槽位
-record(base_galaxy_pos, {
    id   = 0,
    type = 0,  %%0阵位1星位
    own  = 0,  %%上级槽位
    cost = []  %%开启开销
}).



%% 星辰技能数据
-record(f_s, {
     pos = 0                    %% 技能槽位Id
    ,skill_id = 0               %% 技能Id
    ,lev = 0                    %% 技能等级
    ,is_settled = 0             %% 是否为固定技能-1是0不是
}).



%% 星辰技能配置
-record(base_galaxy_skill, {
    id = 0                      %% 技能Id
    ,lv = 0                     %% 技能等级
    ,cost = []                  %% 学习消耗
    ,item = 0
    ,color = 0
    ,is_repeate = 0             %%是否可重复
}).

%% 皮肤配置
-record(base_galaxy_skin, {
    id = 0                      %% 皮肤Id
    ,star = 0                   %% 星数
    ,next = 0                   %% 下一星数
    ,skill = 0                  %% 激活技能
    ,attrs = []                 %% 属性
    ,costs = []                 %% 消耗道具
    ,name = <<>>                %% 名称
    ,model = 0                  %% 形象Id
}).

%%皮肤
-record(galaxy_skin, {
    skin = 0                    %% 皮肤Id
    ,star = 0                   %% 星级
}).


%% 刷新配置
-record(galaxy_shop_item, {
    id = 0                      %% 唯一Id
    ,pos = 0                    %% 槽位Id
    ,award = []                 %% 物品
    ,cost = []
    ,weight = 0                 %% 权重
    ,times_weight = []
}).


%%市场物品
-record(sale_item, {
    pos = 0                     %% 商店槽位Id
    ,id = 0                     %% Id
    ,status = 0                 %% 是否已购买-1:是0:不是
}).


%%图鉴配置
-record(base_galaxy_collect, {
    type = 0,
    tname = "",
    subtype = 0,
    sname = "",
    items = [],
    awards = []
}).


-record(galaxy_collect, {
    key  = {0,0},
    state = 0,
    gains = []
}).