-define(SQL_ROLE_LEGION_GET,"SELECT `post`,`score`,`rank_score`,`arms`,`process`,`dot_list`,`click_role`,`day_award`,`tasks`,`ltime`,`p_utime`,`advance_awards` FROM `role_legion` WHERE `rid` = ~p").
-define(SQL_ROLE_LEGION_INS,<<"REPLACE INTO `role_legion`(`rid`,`post`,`score`,`rank_score`,`arms`,`process`,`dot_list`,`click_role`,`day_award`,`tasks`,`ltime`,`p_utime`,`advance_awards`) VALUES (~p,~p,~p,~p,~p,~p,'~ts','~ts',~p,'~ts',~p,~p,'~ts')">>).
-define(SQL_ROLE_LEGION_UPDATE1, <<"UPDATE `role_legion` SET `process`= '~p', `tasks`= '~ts',`ltime`=~p WHERE `rid`=~p">>).
-define(SQL_ROLE_LEGION_UPDATE2, <<"UPDATE `role_legion` SET `rank_score`=~p,`score`= ~p,`ltime`=~p, `p_utime`=~p WHERE `rid`=~p">>).
-define(SQL_ROLE_LEGION_UPDATE3, <<"UPDATE `role_legion` SET `process`= '~p',`dot_list`='~ts',`day_award`=~p,`ltime`=~p WHERE `rid`=~p">>).
-define(SQL_ROLE_LEGION_UPDATE4, <<"UPDATE `role_legion` SET `click_role`= '~ts',`ltime`=~p WHERE `rid`=~p">>).
-define(SQL_ROLE_LEGION_UPDATE5, <<"UPDATE `role_legion` SET `arms`= ~p WHERE `rid`=~p">>).
-define(SQL_ROLE_LEGION_UPDATE6, <<"UPDATE `role_legion` SET `arms`= ~p,`rank_score`=~p WHERE `rid`=~p">>).
-define(SQL_ROLE_LEGION_UPDATE7, <<"UPDATE `role_legion` SET `post`= ~p,`score`=~p, `p_utime`=~p WHERE `rid`=~p">>).
-define(SQL_ROLE_LEGION_UPDATE8, <<"UPDATE `role_legion` SET `advance_awards`= '~ts' WHERE `rid`=~p">>).


-define(SQL_LEGION_RANK_INS1, <<"REPLACE INTO `legion_rank_now`(`rid`,`name`,`zone`,`fact`,`server_id`,`server_num`,`sex`,`career`,`turn`,`lv`,`vip`,`sup_vip`,`dress_list`,`profile_photo_id`,`post`,`gname`,`score`,`rank`,`time`) VALUES (~p,'~ts',~p,~p,~p,~p,~p,~p,~p,~p,~p,~p,'~ts',~p,~p,'~ts',~p,~p,~p)">>).
-define(SQL_LEGION_RANK_DEL, <<"DELETE FROM `legion_rank_now` WHERE `rid`=~p">>).


-define(SQL_LEGION_RANK_GETN,"SELECT * FROM `legion_rank_now`").
-define(SQL_LEGION_RANK_GETL,"SELECT * FROM `legion_rank_last`").
-define(SQL_LEGION_RANK_GETW,"SELECT * FROM `legion_rank_week`").

-define(SQL_LEGION_RANK_DEL2, <<"DELETE FROM `legion_rank_now` WHERE `zone`=~p">>).
-define(SQL_LEGION_RANK_DEL3, <<"DELETE FROM `legion_rank_week` WHERE `zone`=~p">>).

-define(SQL_LEGION_RANK_BATCHL,"REPLACE INTO `legion_rank_last`(`rid`,`name`,`zone`,`fact`,`server_id`,`server_num`,`sex`,`career`,`turn`,`lv`,`vip`,`sup_vip`,`dress_list`,`profile_photo_id`,`post`,`gname`,`score`,`rank`,`time`) VALUES ~ts").
-define(SQL_LEGION_RANK_BATCHW,"REPLACE INTO `legion_rank_week`(`rid`,`name`,`zone`,`fact`,`server_id`,`server_num`,`sex`,`career`,`turn`,`lv`,`vip`,`sup_vip`,`dress_list`,`profile_photo_id`,`post`,`gname`,`score`,`rank`,`time`) VALUES ~ts").

-define(SQL_ROLE_LEGION_RESET,<<"UPDATE `role_legion` SET `rank_score`= 0,`arms`= 0">>).

-define(SQL_LEGION_DIRECTOR_GET, "SELECT * FROM `legion_director`").
-define(SQL_LEGION_DIRECTOR_INS,<<"REPLACE INTO `legion_director`(zone,fact,pos,rid,name,sex,career) VALUES (~p,~p,~p,~p,'~ts',~p,~p)">>).
-define(SQL_LEGION_DIRLOG_GET, "SELECT * FROM `legion_director_log` WHERE `issue`> ~p").
-define(SQL_LEGION_DIRLOG_BATCH,"REPLACE INTO `legion_director_log`(`issue`,`server_num`,`pos`,`rid`,`name`,`sex`,`career`,`lv`,`turn`,`vip`,`sup_vip`,`dress_list`,`profile_photo_id`,`time`) VALUES ~ts").


-define(SQL_LEGION_DIRECTOR_DELS,<<"DELETE FROM `legion_director` WHERE zone=~p and fact=~p">>).

-define(SQL_LEGION_RANK_UPD1, <<"UPDATE `legion_rank_now` SET `zone`= ~p,`fact`=~p WHERE `zone`=~p and `fact`=~p">>).
-define(SQL_LEGION_RANK_UPD2, <<"UPDATE `legion_rank_last` SET `zone`= ~p,`fact`=~p WHERE `zone`=~p and `fact`=~p">>).
-define(SQL_LEGION_RANK_UPD3, <<"UPDATE `legion_rank_now` SET `zone`= ~p WHERE `zone`=~p">>).
-define(SQL_LEGION_RANK_UPD4, <<"UPDATE `legion_rank_last` SET `zone`= ~p WHERE `zone`=~p">>).



-define(LEGION_INIT,0).
-define(LEGION_FINISH,1).
-define(LEGION_GOT,2).

%%榜单数据
-record(legion_rank, {
	id = 0,
	server_id = 0,
	server_num = 0,
	zone = 0,
	fact = 0,
	figure = 0,
	gname = "",
	score = 0,
	rank = 0,
	time = 0
}).

-record(legion_mgr, {
	directors     = #{} %%指挥官
}).

-record(time_history, {
	time = 0,
	servers = []  %%#server_log{}
}).

-record(server_log, {
	server_num = 0,
	logs = []   %%#history_role{}
}).

-record(history_role, {
	id = 0,
	pos = 0,
	time = 0,
	figure = 0
}).

%%指挥室成员
-record(director_role,{
	pos = 0,
	rid = 0,
	zone = 0,
	fact = 0,
	figure = 0,
	time = 0
}).


%%个人战团数据
-record(role_legion, {

	post = 0,        %%军衔
	score = 0,       %%升级使用军功

	rank_score = 0,  %%榜单军功值 随赛季重置
	arms = 0,        %%军备值 随赛季重置

	process= 0,      %%活跃进度
	dot_list  = [],  %%已领取的节点id列表

	click_role = [],  %%膜拜人
	day_award  = 0,  %%每日领取情况

	ltime = 0,       %%上次更新
	post_utime = 0,  %% 军衔上次更新时间

	advance_awards = [] %%预告奖励  按天领取 可领前一天
}).

%%已接任务
-record(legion_task, {
	id = 0,
	bar = 0,
	state = 0
}).

%%任务配置
-record(base_legion_task, {
	id = 0,
	color = 0, %品质
	desc = "", %描述
	content = {0,0,0}, %%任务内容
	awards = [], %%奖励
	active = 0 %%增加活跃
}).


%%任务积分奖励配置
-record(base_legion_active_award, {
	id = 0,
	round = 0,
	active = 0, %活跃需求
	awards = [] %%奖励
}).



%%军衔进阶配置
-record(base_legion_post, {
	lv = 0,
	next = 0,
	need = 0,
	attr = [],
	cost = []
}).