%%-----------------------------------------------------------------------------
%% module  :       guild_tribe
%% @author  :      zmh
%% Created :       20200225
%% description:    社团驻地
%%----------------------------------------------------------------------------

-define(STATE_IDLE, 0).
-define(STATE_OPEN, 1).
-define(STATE_CLOSE, 2).

-define(MSTATE_NORMAL,0).    %%正常
-define(MSTATE_BURST, 1).    %%狂暴
-define(MSTATE_DEAD,  2).    %%死亡

-define(OPENDAY_BADGE,1). %%开发N天后才会结算徽章
-define(WEEKDAY_BADGE,1). %%周N结算徽章

-record(guild_tribe_mgr, {

    exchange = 0,  %%0白天1晚上
    eref  = 0,%%白夜定时器

    state = 0,
    stime = 0,
    etime = 0,
    ltime = 0,
    ref = 0,
    sref = 0,
    dots = [],
    roles = 0
}).

-record(tribe_guild, {
    id = 0,
    num = 0,     %当前场景人数
    max_num = 0,  %最大人数
    members = []
}).

-record(tribe_role, {
    id = 0,
    online = 0,
    lv = 0,
    exp = 0,
    pos = 0  %0非祝火状态 1~99为策划部署点  100为就地
    ,in_scene = 0  %% 是否在驻地 1-是 0-否
    ,enter_time = 0 %% 进入场景驻地的时间
    ,last_time = 0  %% 场景驻地逗留时间
}).

-record(guild_boss_mgr,{

    scene = 0,
    act = 0,
    mon = 0, %%当前怪
    mon_state = 0, %%0普通1无敌
    mon_ref = 0,
    mon_etime = 0,
    hp = 0,
    round = 0, %%循环状态次数
    hp_limit = 0,

    state = 0, %%0闲1活动中2结束
    stime = 0,
    etime = 0,
    ref = 0,
    rank_ref = 0,
    role_ranks = [],
    guild_ranks = [],
    boss_datas = [], %%各社团现状
    steps = [], %%BOSS要循环的状态
    click = 0,  %%统计第几次掉落
    role_map = #{},  %% 当前玩法场景里面的玩家
    roll_map = #{},  %% 玩家roll掉落数据 #{guild=>#{drop=>[{role_id,roll_num}...]}}, #{guild=>[role_id...]}
    drop_map = #{},  %% 掉落缓存数据 #{guild=>[mon_args,drop_rule,drop_list]}
    cashback = []     %%拍卖返还
}).

-record(boss_ctrl, {

    id = 0,
    mon_state = 0, %%1普通2无敌
    num = 0,       %%小怪完成数量

    box = 0        %%剩余宝箱

}).


-define(SQL_GUILD_BOSS_GET,<<"SELECT `id`,`act`,`type`,`rank`,`rid`,`gid`,`flag`,`name`,`gname`,`hurt`,`cash`,`count`,`total`,`finish`,`stime`,`etime` FROM `guild_boss` WHERE `act`=~p and `type`=~p">>).
-define(SQL_GUILD_BOSS_BATCH,"REPLACE INTO `guild_boss`(`act`,`type`,`rank`,`rid`,`gid`,`flag`,`name`,`gname`,`hurt`,`cash`,`count`,`total`,`finish`,`stime`,`etime`) VALUES ~ts").
-define(SQL_CLEAN_GUILD_BOSS,<<"DELETE FROM `guild_boss` WHERE `act`=~p">>).
-define(SQL_UPDATE_GUILD_FINISH,<<"UPDATE guild_boss SET `cash`=~p,`finish`=~p WHERE `act`=~p and `type`=~p and `gid`=~p">>).
-define(SQL_UPDATE_GUILD_COUNT,<<"UPDATE guild_boss SET `cash`=~p,`count`=~p WHERE `act`=~p and `type`=~p and `gid`=~p">>).


-record(rec_rank, {
    rank = 0,
    grank = 0,  %%结算用 记录临时社团排名
    rid  = 0,
    gid  = 0,
    flag = 0,
    name = "",
    carrer = 0,
    gname = "",
    hurt = 0,

    free_times = 0, %%免费已使用
    cost_times = 0, %%付费已使用
    inspire = 0, %%鼓舞

    rawards = [], %%个人奖励
    gawards = [], %%社团上架

    roll_rewards = [], %% roll点获得的奖励

    cash    = 0,  %%拍卖返还
    count   = 0,  %%拍卖统计
    total   = 0,  %%拍卖总计
    finish  = 0,  %%标记结算

    stime   = 0, %%个人初次出手时间
    etime   = 0  %%个人最终出手时间

    ,revive_times = 0  %% 复活次数
}).