|
|
- %%%------------------------------------
- %%% @Module : common_rank.hrl
- %%% @Author : hejiahua
- %%% @Created : 2015-12-18
- %%% @Description: 通用榜单
- %%%------------------------------------
- %% --------------------#common_rank_role.rank_type 类型---------------------
- -define(RANK_TYPE_COMBAT, 2000). %% 战力排行榜
- -define(RANK_TYPE_COMBAT_1, 2001). %% 职业1战力榜
- -define(RANK_TYPE_COMBAT_2, 2002). %% 职业2战力榜
- -define(RANK_TYPE_COMBAT_3, 2003). %% 职业3战力榜
- -define(RANK_TYPE_COMBAT_4, 2004). %% 职业4战力榜
-
- -define(RANK_TYPE_LV, 3000). %% 等级排行榜
- -define(RANK_TYPE_LV_1, 3001). %% 职业1等级榜
- -define(RANK_TYPE_LV_2, 3002). %% 职业2等级榜
- -define(RANK_TYPE_LV_3, 3003). %% 职业3等级榜
- -define(RANK_TYPE_LV_4, 3004). %% 职业4等级榜
-
- -define(RANK_TYPE_GUILD, 407). %% 公会排行榜
-
- -define(RANK_TYPE_DESIGNATION, 411). %% 称号排行榜
- -define(RANK_TYPE_FASHION, 413). %% 时装排行榜
-
- -define(RANK_TYPE_FHORSE, 1461). %% 座驾排行榜
- -define(RANK_TYPE_FWING, 1462). %% 炫翼排行榜
- -define(RANK_TYPE_FPEARL, 1463). %% 宝具排行榜
- -define(RANK_TYPE_FWEAPON, 1464). %% 武器排行榜
- -define(RANK_TYPE_FJARVIS, 1465). %% AI娘排行榜
- -define(RANK_TYPE_FGUN, 1466). %% 磁炮排行榜
- -define(RANK_TYPE_FCLOUD, 1467). %% 星翼排行榜
- -define(RANK_TYPE_FARMOUR, 1468). %% 幻甲排行榜
- -define(RANK_TYPE_FOSTERS, 14600). %% 进阶总榜
- -define(RANK_TYPE_AIGIRLS, 14601). %% AI娘总榜
-
- -define(RANK_TYPE_DRESS, 112). %% 装扮排行榜
- -define(RANK_TYPE_BABY, 163). %% 宝宝排行榜
-
- -define(RANK_TYPE_CHARM_WEEK, 2231). %% 魅力(人气)榜
- -define(RANK_TYPE_GENEROURS, 2232). %% 慷慨(豪气,即名望)榜
-
- -define (RANK_TYPE_WARSOUL, 143). %% 战魂排行榜
-
- -define(RANK_TYPE_EQUIP, 1520). %% 装备排行榜
- -define(RANK_TYPE_EQUIP_1, 1521). %% 职业1装备榜
- -define(RANK_TYPE_EQUIP_2, 1522). %% 职业2装备榜
- -define(RANK_TYPE_EQUIP_3, 1523). %% 职业3装备榜
- -define(RANK_TYPE_EQUIP_4, 1524). %% 职业4装备榜
-
- -define(RANK_TYPE_GUILD_LABOR, 4001). %% 社团活跃榜
- -define(RANK_TYPE_GUILD_LABOR_LAST, 4002). %% 社团上期活跃榜
-
-
- -define(RANK_GUILD_LIST,[
- ?RANK_TYPE_GUILD
- ,?RANK_TYPE_GUILD_LABOR
- ,?RANK_TYPE_GUILD_LABOR_LAST
- ]).
-
- %% 个人榜单列表
- -define(RANK_TYPE_LIST, [
- ?RANK_TYPE_COMBAT,
- ?RANK_TYPE_COMBAT_1,
- ?RANK_TYPE_COMBAT_2,
- ?RANK_TYPE_COMBAT_3,
- ?RANK_TYPE_COMBAT_4,
- ?RANK_TYPE_LV,
- ?RANK_TYPE_LV_1,
- ?RANK_TYPE_LV_2,
- ?RANK_TYPE_LV_3,
- ?RANK_TYPE_LV_4,
- ?RANK_TYPE_FASHION,
- ?RANK_TYPE_DESIGNATION,
- ?RANK_TYPE_FOSTERS,
- ?RANK_TYPE_AIGIRLS,
- ?RANK_TYPE_FHORSE,
- ?RANK_TYPE_FWING,
- ?RANK_TYPE_FPEARL,
- ?RANK_TYPE_FWEAPON,
- ?RANK_TYPE_FJARVIS,
- ?RANK_TYPE_FGUN,
- ?RANK_TYPE_FCLOUD,
- ?RANK_TYPE_FARMOUR,
- ?RANK_TYPE_BABY,
- ?RANK_TYPE_CHARM_WEEK,
- ?RANK_TYPE_GENEROURS,
- ?RANK_TYPE_EQUIP,
- ?RANK_TYPE_EQUIP_1,
- ?RANK_TYPE_EQUIP_2,
- ?RANK_TYPE_EQUIP_3,
- ?RANK_TYPE_EQUIP_4,
- ?RANK_TYPE_WARSOUL,
- ?RANK_TYPE_DRESS
- ]).
-
- %% 进阶系统榜
- -define(RANK_TYPE_FOSTER, [
- ?RANK_TYPE_FHORSE,
- ?RANK_TYPE_FWING,
- ?RANK_TYPE_FPEARL,
- ?RANK_TYPE_FWEAPON,
- ?RANK_TYPE_FJARVIS,
- ?RANK_TYPE_FGUN,
- ?RANK_TYPE_FCLOUD,
- ?RANK_TYPE_FARMOUR
- ]).
-
- -define(RANK_TYPE_FOSTER_1, [
- ?RANK_TYPE_FHORSE,
- ?RANK_TYPE_FWING,
- ?RANK_TYPE_FPEARL,
- ?RANK_TYPE_FWEAPON
- ]).
-
- -define(RANK_TYPE_FOSTER_2, [
- ?RANK_TYPE_FJARVIS,
- ?RANK_TYPE_FGUN,
- ?RANK_TYPE_FCLOUD,
- ?RANK_TYPE_FARMOUR
- ]).
-
- %% 战力综合+战力职业
- -define(RANK_TYPE_ALL_COMBATS, [
- ?RANK_TYPE_COMBAT,
- ?RANK_TYPE_COMBAT_1,
- ?RANK_TYPE_COMBAT_2,
- ?RANK_TYPE_COMBAT_3,
- ?RANK_TYPE_COMBAT_4
- ]).
-
- %% 等级综合+等级职业
- -define(RANK_TYPE_ALL_LVS, [
- ?RANK_TYPE_LV,
- ?RANK_TYPE_LV_1,
- ?RANK_TYPE_LV_2,
- ?RANK_TYPE_LV_3,
- ?RANK_TYPE_LV_4
- ]).
-
- %% 装备综合+装备职业
- -define(RANK_TYPE_ALL_EQUIPS, [
- ?RANK_TYPE_EQUIP,
- ?RANK_TYPE_EQUIP_1,
- ?RANK_TYPE_EQUIP_2,
- ?RANK_TYPE_EQUIP_3,
- ?RANK_TYPE_EQUIP_4
- ]).
-
- %% 有职业区分的榜单
- -define(RANK_TYPE_CAREER, [
- ?RANK_TYPE_COMBAT_1,
- ?RANK_TYPE_COMBAT_2,
- ?RANK_TYPE_COMBAT_3,
- ?RANK_TYPE_COMBAT_4,
- ?RANK_TYPE_LV_1,
- ?RANK_TYPE_LV_2,
- ?RANK_TYPE_LV_3,
- ?RANK_TYPE_LV_4,
- ?RANK_TYPE_EQUIP_1,
- ?RANK_TYPE_EQUIP_2,
- ?RANK_TYPE_EQUIP_3,
- ?RANK_TYPE_EQUIP_4
- ]).
-
- %% EQUIP+COMBAT+LV
- -define(RANK_TYPE_ECL, [
- ?RANK_TYPE_EQUIP,
- ?RANK_TYPE_COMBAT,
- ?RANK_TYPE_LV
- ]).
-
- %% 需要显示榜单上额外值second_value的榜单列表
- -define(SHOW_RANK_SECVAL_LIST, [
- ?RANK_TYPE_EQUIP
- ]).
-
- %% 进阶总榜
- -define(RANK_TYPE_14600, [
- ?RANK_TYPE_FHORSE,
- ?RANK_TYPE_FWING,
- ?RANK_TYPE_FPEARL,
- ?RANK_TYPE_FWEAPON
- ]).
-
- %% AI娘总榜
- -define(RANK_TYPE_14601, [
- ?RANK_TYPE_FJARVIS,
- ?RANK_TYPE_FGUN,
- ?RANK_TYPE_FCLOUD,
- ?RANK_TYPE_FARMOUR
- ]).
-
- -define(WORLD_LV_LEN, 20). %% 全服等级榜前20名玩家的长度
- -define(REFRESH_SERVERLV_TIME, 3600*1000). %% 世界等级刷新时长
-
-
- %% 点赞规则:
- %% 1.每个独立榜单1次
- %% 2.每日只有1次
- -define(MAX_PRAISE_NUM, data_ranking:get_value(max_praise_num)).
- -define(RANK_DAILY_PRAISE, 1).
-
- %% 点赞类型
- -define(PRAISE_0, 0). %% 个人
- -define(PRAISE_1, 1). %% 社团
-
- %% 排行榜配置
- -record(rank_config, {
- type = 0,
- rank_name = "",
- rank_max = 0,
- rank_limit = 0,
- title_id = 0
- }).
-
- -record(base_common_rank_kv, {
- id = 0,
- key = "",
- value = 0,
- desc = ""
- }).
-
-
- %% 排行榜目标奖励配置
- -record(base_common_rank_target_reward, {
- type = 0, %% 榜单类型
- index = 0, %% 映射id
- target = 0, %% 达成目标
- name = <<>>, %% 榜单名称
- reward = [] %% 奖励
- }).
-
- %% 通用榜单的角色信息
- %% 注意:需要排序的话,使用value、second_value、third_value,不要用其他字段
- -record(common_rank_role, {
- role_key = undefined, % 玩家的唯一键 {RankType, id}
- rank_type = 0, % 榜单类型
- role_id = 0, % 角色Id
- value = 0, % 值
- second_value = 0, % 值(保留)
- third_value = 0, % 值(保留)
- extra_value = [], % 额外值(保留)
- display_value = 0, % 客户端显示值
- time = 0, % 时间
- online = 0, % 是否在线
- off_time = 0, % 离线时间
- rank = 0 % 名次
- }).
-
- %% 跨服排行角色信息
- -record(cross_common_rank_role, {
- role_key = undefined, % 玩家唯一键
- rank_type = 0, % 榜单类型
- role_id = 0, % 角色id
- value = 0, % 值
- second_value = 0, % 第二值
- vip = 0, % vip
- sup_vip = 0, % sup_vip
- name = 0, % 名字
- gender = 0, % 性别
- rank = 0,
- server_num = 0, % 服务器编号
- server_id = 0 % 服务器id
- }).
-
- -record(common_rank_guild, {
- guild_key = undefine, % 唯一键{RankType, guild_id}
- rank_type = 0, % 榜单类型
- guild_id = 0, % 公会id
- flag = 0,
- guild_name = "", % 公会名称
- chairman_id = 0, % 会长Id
- chairman_name = "", % 会长名字
- lv = 0, % 公会等级
- members_num = 0, % 成员数量
- value = 0, % 值
- second_value = 0, % 值(保留)
- third_value = 0, % 值(保留)
- time = 0, % 时间
- rank = 0 % 名次
- ,add_mem_num = 0 % 社团竞榜增加人数
- ,create_time = 0 % 社团创建时间(判断评级为待定 时使用)
- ,labor_refresh_time = 0 % 社团活跃刷新时间(判断评级为待定 时使用)
- }).
-
- %% 通用榜单的进程状态
- -record(common_rank_state, {
- % role_maps = maps:new(), % Key:RankType Value:[#common_rank_role{}|...]
- guild_maps = maps:new(),
- old_first_guild = 0, % 存昨天第一的公会id
- rank_limit = maps:new(),
- praise_maps = maps:new(), % key: role_id value: praise_num
- ref_average_lv = none, % 世界等级刷新定时器
- first_top = maps:new(), % 首度达成目标数据
- first_top_role = [], % 首度目标辅助数据 [{{RoleId, RankType, Target}, Val}]
- timer = undefined
- }).
-
- %% 跨服排行榜数据
- -record(cross_rank_state, {
- % role_maps = #{}, % Key:{ZoneId, RankType} Value:[#cross_common_rank_role{}|...]
- rank_limit = #{}, %
- srv_zones = #{}, % 游戏服分区映射
- srv_upload_status = #{}, % 分区游戏服上传数据状态 ZoneId => [{ServerId, Status},...]
- upload_status = [], % [{ZoneId, Status},...]
- maps = #{} % 其他数据
- }).
-
- -define(RANK_INIT, 1).
- -define(FORCE_UPDATE_PRE, 2).
- -define(FORCE_UPDATE, 3).
- -define(INTERVAL_UPDATE_REF,4).
-
- -define(RANK_INTERVAL, 300000).
-
- -define(RANK_TYPE_KEY(RankType), {common_rank_type, RankType}).
- -define(CROSS_RANK_TYPE_KEY(RankKey), {cross_rank_type, RankKey}).
-
- -define(sql_common_rank_guild_select,
- <<"SELECT rank_type, guild_id, guild_name, flag, chairman_id, chairman_name, lv, members_num, value, second_value, third_value, time FROM common_rank_guild">>).
-
- -define(sql_common_rank_role_select,
- <<"SELECT rank_type, player_id, value, second_value, third_value, extra_value, time, off_time FROM common_rank_role">>).
-
- -define(sql_common_rank_praise_select,
- <<"SELECT type, id, praise_num FROM common_rank_praise">>).
-
- -define(sql_common_rank_first_top_select,
- <<"SELECT rank_type, target, role_id, time FROM common_rank_first_top">>).
-
- -define(sql_common_rank_role_first_top_select,
- <<"SELECT rank_type, target FROM role_first_top_reward WHERE role_id = ~p">>).
-
- -define(sql_common_rank_role_save,
- <<"replace into common_rank_role(rank_type, player_id, value, second_value, third_value, extra_value, time, off_time) values(~p, ~p, ~p, ~p, ~p, '~ts', ~p,~p)">>).
-
- -define(sql_common_rank_praise_save,
- <<"replace into common_rank_praise(type, id, praise_num) values(~p, ~p, ~p)">>).
-
- -define(sql_common_rank_guild_save,
- <<"replace into common_rank_guild(rank_type, guild_id, guild_name,flag, chairman_id, chairman_name, lv, members_num, value, second_value, third_value, time) values(~p, ~p , '~ts', ~p,~p, '~ts', ~p, ~p, ~p, ~p, ~p, ~p)">>).
-
- -define(sql_common_rank_role_delete_by_role_id,
- <<"delete from common_rank_role where rank_type = ~p and player_id = ~p">>).
-
- -define(sql_common_rank_guild_delete_by_guild_id,
- <<"delete from common_rank_guild where rank_type = ~p and guild_id = ~p">>).
-
-
- -define(sql_common_rank_role_delete_by_value,
- <<"delete from common_rank_role where rank_type = ~p and value < ~p ">>).
-
- -define(sql_common_rank_guild_delete_by_value,
- <<"delete from common_rank_guild where rank_type = ~p and value < ~p ">>).
-
- -define(sql_common_rank_role_delete_by_rank_type,
- <<"delete from common_rank_role where rank_type = ~p">>).
-
-
- -define(SQL_COMMON_GUILD_RANK_DEL_TYPE,
- <<"delete from common_rank_guild where rank_type=~p">>).
-
- -define(SQL_COMMON_GUILD_RANK_BATCH,
- <<"REPLACE INTO common_rank_guild(rank_type, guild_id, guild_name, flag, chairman_id, chairman_name, lv, members_num, value, second_value, third_value, time) VALUES ~ts">>).
-
- -define(SQL_COMMON_RANK_FIRST_TOP,
- <<"REPLACE INTO common_rank_first_top(rank_type, target, role_id, time) VALUES ~ts">>).
-
- -define(REPLACE_INTO_COMMON_RANK_FIRST_TOP,
- <<"REPLACE INTO role_first_top_reward SET role_id = ~p, rank_type = ~p, target = ~p">>).
-
-
- -define(SQL_SELECT_COMMON_PRAISE_ROLE,
- <<"SELECT rank_type, praise_id, time FROM role_praise_target WHERE role_id = ~p">>).
-
- -define(SQL_REPLACE_COMMON_PRAISE_ROLE,
- <<"REPLACE INTO role_praise_target SET role_id = ~p, rank_type = ~p, praise_id = ~p, time = ~p">>).
-
- -define(SQL_DELETE_COMMON_PRAISE_ROLE,
- <<"TRUNCATE TABLE role_praise_target">>).
-
- -define(SQL_BTACH_DELETE_COMMON_PRAISE_ROLE,
- <<"DELETE FROM role_praise_target WHERE role_id = ~p, rank_type = ~p">>).
|